David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1 | /* A Bison parser, made by GNU Bison 1.875c. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3 | /* Skeleton parser for Yacc-like parsing with Bison, |
| 4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +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 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +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., 59 Temple Place - Suite 330, |
| 19 | Boston, MA 02111-1307, 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 | /* Skeleton name. */ |
| 40 | #define YYSKELETON_NAME "yacc.c" |
| 41 | |
| 42 | /* Pure parsers. */ |
| 43 | #define YYPURE 0 |
| 44 | |
| 45 | /* Using locations. */ |
| 46 | #define YYLSP_NEEDED 0 |
| 47 | |
| 48 | /* If NAME_PREFIX is specified substitute the variables and functions |
| 49 | names. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 50 | #define yyparse llvmAsmparse |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 51 | #define yylex llvmAsmlex |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 52 | #define yyerror llvmAsmerror |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 53 | #define yylval llvmAsmlval |
| 54 | #define yychar llvmAsmchar |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 55 | #define yydebug llvmAsmdebug |
| 56 | #define yynerrs llvmAsmnerrs |
| 57 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 58 | |
| 59 | /* Tokens. */ |
| 60 | #ifndef YYTOKENTYPE |
| 61 | # define YYTOKENTYPE |
| 62 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 63 | know about them. */ |
| 64 | enum yytokentype { |
| 65 | ESINT64VAL = 258, |
| 66 | EUINT64VAL = 259, |
| 67 | ESAPINTVAL = 260, |
| 68 | EUAPINTVAL = 261, |
| 69 | LOCALVAL_ID = 262, |
| 70 | GLOBALVAL_ID = 263, |
| 71 | FPVAL = 264, |
| 72 | VOID = 265, |
| 73 | INTTYPE = 266, |
| 74 | FLOAT = 267, |
| 75 | DOUBLE = 268, |
| 76 | X86_FP80 = 269, |
| 77 | FP128 = 270, |
| 78 | PPC_FP128 = 271, |
| 79 | LABEL = 272, |
| 80 | TYPE = 273, |
| 81 | LOCALVAR = 274, |
| 82 | GLOBALVAR = 275, |
| 83 | LABELSTR = 276, |
| 84 | STRINGCONSTANT = 277, |
| 85 | ATSTRINGCONSTANT = 278, |
| 86 | PCTSTRINGCONSTANT = 279, |
| 87 | ZEROINITIALIZER = 280, |
| 88 | TRUETOK = 281, |
| 89 | FALSETOK = 282, |
| 90 | BEGINTOK = 283, |
| 91 | ENDTOK = 284, |
| 92 | DECLARE = 285, |
| 93 | DEFINE = 286, |
| 94 | GLOBAL = 287, |
| 95 | CONSTANT = 288, |
| 96 | SECTION = 289, |
| 97 | ALIAS = 290, |
| 98 | VOLATILE = 291, |
| 99 | THREAD_LOCAL = 292, |
| 100 | TO = 293, |
| 101 | DOTDOTDOT = 294, |
| 102 | NULL_TOK = 295, |
| 103 | UNDEF = 296, |
| 104 | INTERNAL = 297, |
| 105 | LINKONCE = 298, |
| 106 | WEAK = 299, |
| 107 | APPENDING = 300, |
| 108 | DLLIMPORT = 301, |
| 109 | DLLEXPORT = 302, |
| 110 | EXTERN_WEAK = 303, |
| 111 | OPAQUE = 304, |
| 112 | EXTERNAL = 305, |
| 113 | TARGET = 306, |
| 114 | TRIPLE = 307, |
| 115 | ALIGN = 308, |
| 116 | DEPLIBS = 309, |
| 117 | CALL = 310, |
| 118 | TAIL = 311, |
| 119 | ASM_TOK = 312, |
| 120 | MODULE = 313, |
| 121 | SIDEEFFECT = 314, |
| 122 | CC_TOK = 315, |
| 123 | CCC_TOK = 316, |
| 124 | FASTCC_TOK = 317, |
| 125 | COLDCC_TOK = 318, |
| 126 | X86_STDCALLCC_TOK = 319, |
| 127 | X86_FASTCALLCC_TOK = 320, |
| 128 | DATALAYOUT = 321, |
| 129 | RET = 322, |
| 130 | BR = 323, |
| 131 | SWITCH = 324, |
| 132 | INVOKE = 325, |
| 133 | UNWIND = 326, |
| 134 | UNREACHABLE = 327, |
| 135 | ADD = 328, |
| 136 | SUB = 329, |
| 137 | MUL = 330, |
| 138 | UDIV = 331, |
| 139 | SDIV = 332, |
| 140 | FDIV = 333, |
| 141 | UREM = 334, |
| 142 | SREM = 335, |
| 143 | FREM = 336, |
| 144 | AND = 337, |
| 145 | OR = 338, |
| 146 | XOR = 339, |
| 147 | SHL = 340, |
| 148 | LSHR = 341, |
| 149 | ASHR = 342, |
| 150 | ICMP = 343, |
| 151 | FCMP = 344, |
| 152 | EQ = 345, |
| 153 | NE = 346, |
| 154 | SLT = 347, |
| 155 | SGT = 348, |
| 156 | SLE = 349, |
| 157 | SGE = 350, |
| 158 | ULT = 351, |
| 159 | UGT = 352, |
| 160 | ULE = 353, |
| 161 | UGE = 354, |
| 162 | OEQ = 355, |
| 163 | ONE = 356, |
| 164 | OLT = 357, |
| 165 | OGT = 358, |
| 166 | OLE = 359, |
| 167 | OGE = 360, |
| 168 | ORD = 361, |
| 169 | UNO = 362, |
| 170 | UEQ = 363, |
| 171 | UNE = 364, |
| 172 | MALLOC = 365, |
| 173 | ALLOCA = 366, |
| 174 | FREE = 367, |
| 175 | LOAD = 368, |
| 176 | STORE = 369, |
| 177 | GETELEMENTPTR = 370, |
| 178 | TRUNC = 371, |
| 179 | ZEXT = 372, |
| 180 | SEXT = 373, |
| 181 | FPTRUNC = 374, |
| 182 | FPEXT = 375, |
| 183 | BITCAST = 376, |
| 184 | UITOFP = 377, |
| 185 | SITOFP = 378, |
| 186 | FPTOUI = 379, |
| 187 | FPTOSI = 380, |
| 188 | INTTOPTR = 381, |
| 189 | PTRTOINT = 382, |
| 190 | PHI_TOK = 383, |
| 191 | SELECT = 384, |
| 192 | VAARG = 385, |
| 193 | EXTRACTELEMENT = 386, |
| 194 | INSERTELEMENT = 387, |
| 195 | SHUFFLEVECTOR = 388, |
| 196 | SIGNEXT = 389, |
| 197 | ZEROEXT = 390, |
| 198 | NORETURN = 391, |
| 199 | INREG = 392, |
| 200 | SRET = 393, |
| 201 | NOUNWIND = 394, |
| 202 | NOALIAS = 395, |
| 203 | BYVAL = 396, |
| 204 | NEST = 397, |
| 205 | DEFAULT = 398, |
| 206 | HIDDEN = 399, |
| 207 | PROTECTED = 400 |
| 208 | }; |
| 209 | #endif |
| 210 | #define ESINT64VAL 258 |
| 211 | #define EUINT64VAL 259 |
| 212 | #define ESAPINTVAL 260 |
| 213 | #define EUAPINTVAL 261 |
| 214 | #define LOCALVAL_ID 262 |
| 215 | #define GLOBALVAL_ID 263 |
| 216 | #define FPVAL 264 |
| 217 | #define VOID 265 |
| 218 | #define INTTYPE 266 |
| 219 | #define FLOAT 267 |
| 220 | #define DOUBLE 268 |
| 221 | #define X86_FP80 269 |
| 222 | #define FP128 270 |
| 223 | #define PPC_FP128 271 |
| 224 | #define LABEL 272 |
| 225 | #define TYPE 273 |
| 226 | #define LOCALVAR 274 |
| 227 | #define GLOBALVAR 275 |
| 228 | #define LABELSTR 276 |
| 229 | #define STRINGCONSTANT 277 |
| 230 | #define ATSTRINGCONSTANT 278 |
| 231 | #define PCTSTRINGCONSTANT 279 |
| 232 | #define ZEROINITIALIZER 280 |
| 233 | #define TRUETOK 281 |
| 234 | #define FALSETOK 282 |
| 235 | #define BEGINTOK 283 |
| 236 | #define ENDTOK 284 |
| 237 | #define DECLARE 285 |
| 238 | #define DEFINE 286 |
| 239 | #define GLOBAL 287 |
| 240 | #define CONSTANT 288 |
| 241 | #define SECTION 289 |
| 242 | #define ALIAS 290 |
| 243 | #define VOLATILE 291 |
| 244 | #define THREAD_LOCAL 292 |
| 245 | #define TO 293 |
| 246 | #define DOTDOTDOT 294 |
| 247 | #define NULL_TOK 295 |
| 248 | #define UNDEF 296 |
| 249 | #define INTERNAL 297 |
| 250 | #define LINKONCE 298 |
| 251 | #define WEAK 299 |
| 252 | #define APPENDING 300 |
| 253 | #define DLLIMPORT 301 |
| 254 | #define DLLEXPORT 302 |
| 255 | #define EXTERN_WEAK 303 |
| 256 | #define OPAQUE 304 |
| 257 | #define EXTERNAL 305 |
| 258 | #define TARGET 306 |
| 259 | #define TRIPLE 307 |
| 260 | #define ALIGN 308 |
| 261 | #define DEPLIBS 309 |
| 262 | #define CALL 310 |
| 263 | #define TAIL 311 |
| 264 | #define ASM_TOK 312 |
| 265 | #define MODULE 313 |
| 266 | #define SIDEEFFECT 314 |
| 267 | #define CC_TOK 315 |
| 268 | #define CCC_TOK 316 |
| 269 | #define FASTCC_TOK 317 |
| 270 | #define COLDCC_TOK 318 |
| 271 | #define X86_STDCALLCC_TOK 319 |
| 272 | #define X86_FASTCALLCC_TOK 320 |
| 273 | #define DATALAYOUT 321 |
| 274 | #define RET 322 |
| 275 | #define BR 323 |
| 276 | #define SWITCH 324 |
| 277 | #define INVOKE 325 |
| 278 | #define UNWIND 326 |
| 279 | #define UNREACHABLE 327 |
| 280 | #define ADD 328 |
| 281 | #define SUB 329 |
| 282 | #define MUL 330 |
| 283 | #define UDIV 331 |
| 284 | #define SDIV 332 |
| 285 | #define FDIV 333 |
| 286 | #define UREM 334 |
| 287 | #define SREM 335 |
| 288 | #define FREM 336 |
| 289 | #define AND 337 |
| 290 | #define OR 338 |
| 291 | #define XOR 339 |
| 292 | #define SHL 340 |
| 293 | #define LSHR 341 |
| 294 | #define ASHR 342 |
| 295 | #define ICMP 343 |
| 296 | #define FCMP 344 |
| 297 | #define EQ 345 |
| 298 | #define NE 346 |
| 299 | #define SLT 347 |
| 300 | #define SGT 348 |
| 301 | #define SLE 349 |
| 302 | #define SGE 350 |
| 303 | #define ULT 351 |
| 304 | #define UGT 352 |
| 305 | #define ULE 353 |
| 306 | #define UGE 354 |
| 307 | #define OEQ 355 |
| 308 | #define ONE 356 |
| 309 | #define OLT 357 |
| 310 | #define OGT 358 |
| 311 | #define OLE 359 |
| 312 | #define OGE 360 |
| 313 | #define ORD 361 |
| 314 | #define UNO 362 |
| 315 | #define UEQ 363 |
| 316 | #define UNE 364 |
| 317 | #define MALLOC 365 |
| 318 | #define ALLOCA 366 |
| 319 | #define FREE 367 |
| 320 | #define LOAD 368 |
| 321 | #define STORE 369 |
| 322 | #define GETELEMENTPTR 370 |
| 323 | #define TRUNC 371 |
| 324 | #define ZEXT 372 |
| 325 | #define SEXT 373 |
| 326 | #define FPTRUNC 374 |
| 327 | #define FPEXT 375 |
| 328 | #define BITCAST 376 |
| 329 | #define UITOFP 377 |
| 330 | #define SITOFP 378 |
| 331 | #define FPTOUI 379 |
| 332 | #define FPTOSI 380 |
| 333 | #define INTTOPTR 381 |
| 334 | #define PTRTOINT 382 |
| 335 | #define PHI_TOK 383 |
| 336 | #define SELECT 384 |
| 337 | #define VAARG 385 |
| 338 | #define EXTRACTELEMENT 386 |
| 339 | #define INSERTELEMENT 387 |
| 340 | #define SHUFFLEVECTOR 388 |
| 341 | #define SIGNEXT 389 |
| 342 | #define ZEROEXT 390 |
| 343 | #define NORETURN 391 |
| 344 | #define INREG 392 |
| 345 | #define SRET 393 |
| 346 | #define NOUNWIND 394 |
| 347 | #define NOALIAS 395 |
| 348 | #define BYVAL 396 |
| 349 | #define NEST 397 |
| 350 | #define DEFAULT 398 |
| 351 | #define HIDDEN 399 |
| 352 | #define PROTECTED 400 |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | /* Copy the first part of user declarations. */ |
| 358 | #line 14 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 359 | |
| 360 | #include "ParserInternals.h" |
| 361 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 362 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 363 | #include "llvm/Instructions.h" |
| 364 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 365 | #include "llvm/ValueSymbolTable.h" |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 366 | #include "llvm/AutoUpgrade.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 367 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 368 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 369 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 370 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 371 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 372 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 373 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 374 | #include <list> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 375 | #include <map> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 376 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 377 | #ifndef NDEBUG |
| 378 | #define YYDEBUG 1 |
| 379 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 380 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 381 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 382 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 383 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 384 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 385 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 386 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 387 | // GenerateError are made from inside productions and they must simulate the |
| 388 | // previous exception behavior by exiting the production immediately. We have |
| 389 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 390 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 391 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 392 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 393 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 394 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 395 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 396 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 397 | int yylex(); // declaration" of xxx warnings. |
| 398 | int yyparse(); |
| 399 | |
| 400 | namespace llvm { |
| 401 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 402 | #if YYDEBUG |
| 403 | static cl::opt<bool> |
| 404 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 405 | cl::Hidden, cl::init(false)); |
| 406 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 407 | } |
| 408 | using namespace llvm; |
| 409 | |
| 410 | static Module *ParserResult; |
| 411 | |
| 412 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 413 | // relating to upreferences in the input stream. |
| 414 | // |
| 415 | //#define DEBUG_UPREFS 1 |
| 416 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 417 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 418 | #else |
| 419 | #define UR_OUT(X) |
| 420 | #endif |
| 421 | |
| 422 | #define YYERROR_VERBOSE 1 |
| 423 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 424 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 425 | |
| 426 | |
| 427 | // This contains info used when building the body of a function. It is |
| 428 | // destroyed when the function is completed. |
| 429 | // |
| 430 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 431 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 432 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 433 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 434 | |
| 435 | static struct PerModuleInfo { |
| 436 | Module *CurrentModule; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 437 | ValueList Values; // Module level numbered definitions |
| 438 | ValueList LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 439 | std::vector<PATypeHolder> Types; |
| 440 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 441 | |
| 442 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 443 | /// 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] | 444 | /// that we can resolve them later and print error messages as appropriate. |
| 445 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 446 | |
| 447 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 448 | // references to global values. Global values may be referenced before they |
| 449 | // are defined, and if so, the temporary object that they represent is held |
| 450 | // here. This is used for forward references of GlobalValues. |
| 451 | // |
| 452 | typedef std::map<std::pair<const PointerType *, |
| 453 | ValID>, GlobalValue*> GlobalRefsType; |
| 454 | GlobalRefsType GlobalRefs; |
| 455 | |
| 456 | void ModuleDone() { |
| 457 | // If we could not resolve some functions at function compilation time |
| 458 | // (calls to functions before they are defined), resolve them now... Types |
| 459 | // are resolved when the constant pool has been completely parsed. |
| 460 | // |
| 461 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 462 | if (TriggerError) |
| 463 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 464 | |
| 465 | // Check to make sure that all global value forward references have been |
| 466 | // resolved! |
| 467 | // |
| 468 | if (!GlobalRefs.empty()) { |
| 469 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 470 | |
| 471 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 472 | I != E; ++I) { |
| 473 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 474 | I->first.second.getName() + "\n"; |
| 475 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 476 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 477 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 478 | } |
| 479 | |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 480 | // Look for intrinsic functions and CallInst that need to be upgraded |
| 481 | for (Module::iterator FI = CurrentModule->begin(), |
| 482 | FE = CurrentModule->end(); FI != FE; ) |
| 483 | UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove |
| 484 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 485 | Values.clear(); // Clear out function local definitions |
| 486 | Types.clear(); |
| 487 | CurrentModule = 0; |
| 488 | } |
| 489 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 490 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 491 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 492 | // If not, just return null. |
| 493 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 494 | // Check to see if there is a forward reference to this global variable... |
| 495 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 496 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 497 | GlobalValue *Ret = 0; |
| 498 | if (I != GlobalRefs.end()) { |
| 499 | Ret = I->second; |
| 500 | GlobalRefs.erase(I); |
| 501 | } |
| 502 | return Ret; |
| 503 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 504 | |
| 505 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 506 | // If it isn't abstract, its resolved |
| 507 | const Type* Ty = PATy->get(); |
| 508 | if (!Ty->isAbstract()) |
| 509 | return false; |
| 510 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 511 | // we don't need to traverse that leg of the type. |
| 512 | std::vector<const Type*> WorkList, SeenList; |
| 513 | WorkList.push_back(Ty); |
| 514 | while (!WorkList.empty()) { |
| 515 | const Type* Ty = WorkList.back(); |
| 516 | SeenList.push_back(Ty); |
| 517 | WorkList.pop_back(); |
| 518 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 519 | // Check to see if this is an unresolved type |
| 520 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 521 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 522 | for ( ; I != E; ++I) { |
| 523 | if (I->second.get() == OpTy) |
| 524 | return true; |
| 525 | } |
| 526 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 527 | const Type* TheTy = SeqTy->getElementType(); |
| 528 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 529 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 530 | E = SeenList.end(); |
| 531 | for ( ; I != E; ++I) |
| 532 | if (*I == TheTy) |
| 533 | break; |
| 534 | if (I == E) |
| 535 | WorkList.push_back(TheTy); |
| 536 | } |
| 537 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 538 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 539 | const Type* TheTy = StrTy->getElementType(i); |
| 540 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 541 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 542 | E = SeenList.end(); |
| 543 | for ( ; I != E; ++I) |
| 544 | if (*I == TheTy) |
| 545 | break; |
| 546 | if (I == E) |
| 547 | WorkList.push_back(TheTy); |
| 548 | } |
| 549 | } |
| 550 | } |
| 551 | } |
| 552 | return false; |
| 553 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 554 | } CurModule; |
| 555 | |
| 556 | static struct PerFunctionInfo { |
| 557 | Function *CurrentFunction; // Pointer to current function being created |
| 558 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 559 | ValueList Values; // Keep track of #'d definitions |
| 560 | unsigned NextValNum; |
| 561 | ValueList LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 562 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 563 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 564 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 565 | |
| 566 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 567 | /// track of them here. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 568 | std::map<ValID, BasicBlock*> BBForwardRefs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 569 | |
| 570 | inline PerFunctionInfo() { |
| 571 | CurrentFunction = 0; |
| 572 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 573 | Linkage = GlobalValue::ExternalLinkage; |
| 574 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | inline void FunctionStart(Function *M) { |
| 578 | CurrentFunction = M; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 579 | NextValNum = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | void FunctionDone() { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 583 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 584 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 585 | GenerateError("Undefined reference to label " + |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 586 | BBForwardRefs.begin()->second->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 587 | return; |
| 588 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 589 | |
| 590 | // Resolve all forward references now. |
| 591 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 592 | |
| 593 | Values.clear(); // Clear out function local definitions |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 594 | BBForwardRefs.clear(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 595 | CurrentFunction = 0; |
| 596 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 597 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 598 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 599 | } |
| 600 | } CurFun; // Info for the current function... |
| 601 | |
| 602 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 603 | |
| 604 | |
| 605 | //===----------------------------------------------------------------------===// |
| 606 | // Code to handle definitions of all the types |
| 607 | //===----------------------------------------------------------------------===// |
| 608 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 609 | static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) { |
| 610 | // Things that have names or are void typed don't get slot numbers |
| 611 | if (V->hasName() || (V->getType() == Type::VoidTy)) |
| 612 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 613 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 614 | // In the case of function values, we have to allow for the forward reference |
| 615 | // of basic blocks, which are included in the numbering. Consequently, we keep |
| 616 | // track of the next insertion location with NextValNum. When a BB gets |
| 617 | // inserted, it could change the size of the CurFun.Values vector. |
| 618 | if (&ValueTab == &CurFun.Values) { |
| 619 | if (ValueTab.size() <= CurFun.NextValNum) |
| 620 | ValueTab.resize(CurFun.NextValNum+1); |
| 621 | ValueTab[CurFun.NextValNum++] = V; |
| 622 | return; |
| 623 | } |
| 624 | // For all other lists, its okay to just tack it on the back of the vector. |
| 625 | ValueTab.push_back(V); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 629 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 630 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 631 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 632 | if (D.Num < CurModule.Types.size()) |
| 633 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 634 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 635 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 636 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 637 | D.destroy(); // Free old strdup'd memory... |
| 638 | return N; |
| 639 | } |
| 640 | break; |
| 641 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 642 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 643 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | // If we reached here, we referenced either a symbol that we don't know about |
| 647 | // or an id number that hasn't been read yet. We may be referencing something |
| 648 | // forward, so just create an entry to be resolved later and get to it... |
| 649 | // |
| 650 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 651 | |
| 652 | |
| 653 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 654 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 655 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 656 | return 0; |
| 657 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 658 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 659 | return 0; |
| 660 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 661 | } |
| 662 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 663 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 664 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 665 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 666 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 667 | Type *Typ = OpaqueType::get(); |
| 668 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 669 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 670 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 671 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 672 | // getExistingVal - Look up the value specified by the provided type and |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 673 | // the provided ValID. If the value exists and has already been defined, return |
| 674 | // it. Otherwise return null. |
| 675 | // |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 676 | static Value *getExistingVal(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 677 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 678 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 679 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 680 | return 0; |
| 681 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 682 | |
| 683 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 684 | case ValID::LocalID: { // Is it a numbered definition? |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 685 | // Check that the number is within bounds. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 686 | if (D.Num >= CurFun.Values.size()) |
| 687 | return 0; |
| 688 | Value *Result = CurFun.Values[D.Num]; |
| 689 | if (Ty != Result->getType()) { |
| 690 | GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" + |
| 691 | Result->getType()->getDescription() + "' does not match " |
| 692 | "expected type, '" + Ty->getDescription() + "'"); |
| 693 | return 0; |
| 694 | } |
| 695 | return Result; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 696 | } |
| 697 | case ValID::GlobalID: { // Is it a numbered definition? |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 698 | if (D.Num >= CurModule.Values.size()) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 699 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 700 | Value *Result = CurModule.Values[D.Num]; |
| 701 | if (Ty != Result->getType()) { |
| 702 | GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" + |
| 703 | Result->getType()->getDescription() + "' does not match " |
| 704 | "expected type, '" + Ty->getDescription() + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 705 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 706 | } |
| 707 | return Result; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 708 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 709 | |
| 710 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 711 | if (!inFunctionScope()) |
| 712 | return 0; |
| 713 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 714 | Value *N = SymTab.lookup(D.getName()); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 715 | if (N == 0) |
| 716 | return 0; |
| 717 | if (N->getType() != Ty) |
| 718 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 719 | |
| 720 | D.destroy(); // Free old strdup'd memory... |
| 721 | return N; |
| 722 | } |
| 723 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 724 | ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 725 | Value *N = SymTab.lookup(D.getName()); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 726 | if (N == 0) |
| 727 | return 0; |
| 728 | if (N->getType() != Ty) |
| 729 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 730 | |
| 731 | D.destroy(); // Free old strdup'd memory... |
| 732 | return N; |
| 733 | } |
| 734 | |
| 735 | // Check to make sure that "Ty" is an integral type, and that our |
| 736 | // value will fit into the specified type... |
| 737 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 738 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 739 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 740 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 741 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 742 | return 0; |
| 743 | } |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 744 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 745 | |
| 746 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 747 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 748 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 749 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 750 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 751 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 752 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 753 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 754 | } |
| 755 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 756 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 760 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 761 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 762 | return 0; |
| 763 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 764 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 765 | |
| 766 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 767 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 768 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 769 | return 0; |
| 770 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 771 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 772 | |
| 773 | case ValID::ConstUndefVal: // Is it an undef value? |
| 774 | return UndefValue::get(Ty); |
| 775 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 776 | case ValID::ConstZeroVal: // Is it a zero value? |
| 777 | return Constant::getNullValue(Ty); |
| 778 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 779 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 780 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 781 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 782 | return 0; |
| 783 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 784 | return D.ConstantValue; |
| 785 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 786 | case ValID::InlineAsmVal: { // Inline asm expression |
| 787 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 788 | const FunctionType *FTy = |
| 789 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 790 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 791 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 792 | return 0; |
| 793 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 794 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 795 | D.IAD->HasSideEffects); |
| 796 | D.destroy(); // Free InlineAsmDescriptor. |
| 797 | return IA; |
| 798 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 799 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 800 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 801 | return 0; |
| 802 | } // End of switch |
| 803 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 804 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 805 | return 0; |
| 806 | } |
| 807 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 808 | // getVal - This function is identical to getExistingVal, except that if a |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 809 | // value is not already defined, it "improvises" by creating a placeholder var |
| 810 | // that looks and acts just like the requested variable. When the value is |
| 811 | // defined later, all uses of the placeholder variable are replaced with the |
| 812 | // real thing. |
| 813 | // |
| 814 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 815 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 816 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 817 | return 0; |
| 818 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 819 | |
| 820 | // See if the value has already been defined. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 821 | Value *V = getExistingVal(Ty, ID); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 822 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 823 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 824 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 825 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 826 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 827 | return 0; |
| 828 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 829 | |
| 830 | // If we reached here, we referenced either a symbol that we don't know about |
| 831 | // or an id number that hasn't been read yet. We may be referencing something |
| 832 | // forward, so just create an entry to be resolved later and get to it... |
| 833 | // |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 834 | switch (ID.Type) { |
| 835 | case ValID::GlobalName: |
Reid Spencer | 9c9b63a | 2007-04-28 16:07:31 +0000 | [diff] [blame] | 836 | case ValID::GlobalID: { |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 837 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 838 | if (!PTy) { |
| 839 | GenerateError("Invalid type for reference to global" ); |
| 840 | return 0; |
| 841 | } |
| 842 | const Type* ElTy = PTy->getElementType(); |
| 843 | if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy)) |
| 844 | V = new Function(FTy, GlobalValue::ExternalLinkage); |
| 845 | else |
| 846 | V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage); |
| 847 | break; |
Reid Spencer | 9c9b63a | 2007-04-28 16:07:31 +0000 | [diff] [blame] | 848 | } |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 849 | default: |
| 850 | V = new Argument(Ty); |
| 851 | } |
| 852 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 853 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 854 | // to recycle these things?? |
| 855 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 856 | llvmAsmlineno))); |
| 857 | |
| 858 | if (inFunctionScope()) |
| 859 | InsertValue(V, CurFun.LateResolveValues); |
| 860 | else |
| 861 | InsertValue(V, CurModule.LateResolveValues); |
| 862 | return V; |
| 863 | } |
| 864 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 865 | /// defineBBVal - This is a definition of a new basic block with the specified |
| 866 | /// identifier which must be the same as CurFun.NextValNum, if its numeric. |
| 867 | static BasicBlock *defineBBVal(const ValID &ID) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 868 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 869 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 870 | BasicBlock *BB = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 871 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 872 | // First, see if this was forward referenced |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 873 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 874 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 875 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 876 | BB = BBI->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 877 | // The forward declaration could have been inserted anywhere in the |
| 878 | // function: insert it into the correct place now. |
| 879 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 880 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 881 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 882 | // We're about to erase the entry, save the key so we can clean it up. |
| 883 | ValID Tmp = BBI->first; |
| 884 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 885 | // Erase the forward ref from the map as its no longer "forward" |
| 886 | CurFun.BBForwardRefs.erase(ID); |
| 887 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 888 | // The key has been removed from the map but so we don't want to leave |
| 889 | // strdup'd memory around so destroy it too. |
| 890 | Tmp.destroy(); |
| 891 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 892 | // If its a numbered definition, bump the number and set the BB value. |
| 893 | if (ID.Type == ValID::LocalID) { |
| 894 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 895 | InsertValue(BB); |
| 896 | } |
| 897 | |
| 898 | ID.destroy(); |
| 899 | return BB; |
| 900 | } |
| 901 | |
| 902 | // We haven't seen this BB before and its first mention is a definition. |
| 903 | // Just create it and return it. |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 904 | std::string Name (ID.Type == ValID::LocalName ? ID.getName() : ""); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 905 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 906 | if (ID.Type == ValID::LocalID) { |
| 907 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 908 | InsertValue(BB); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 909 | } |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 910 | |
| 911 | ID.destroy(); // Free strdup'd memory |
| 912 | return BB; |
| 913 | } |
| 914 | |
| 915 | /// getBBVal - get an existing BB value or create a forward reference for it. |
| 916 | /// |
| 917 | static BasicBlock *getBBVal(const ValID &ID) { |
| 918 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 919 | |
| 920 | BasicBlock *BB = 0; |
| 921 | |
| 922 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 923 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 924 | BB = BBI->second; |
| 925 | } if (ID.Type == ValID::LocalName) { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 926 | std::string Name = ID.getName(); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 927 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 928 | if (N) |
| 929 | if (N->getType()->getTypeID() == Type::LabelTyID) |
| 930 | BB = cast<BasicBlock>(N); |
| 931 | else |
| 932 | GenerateError("Reference to label '" + Name + "' is actually of type '"+ |
| 933 | N->getType()->getDescription() + "'"); |
| 934 | } else if (ID.Type == ValID::LocalID) { |
| 935 | if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) { |
| 936 | if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID) |
| 937 | BB = cast<BasicBlock>(CurFun.Values[ID.Num]); |
| 938 | else |
| 939 | GenerateError("Reference to label '%" + utostr(ID.Num) + |
| 940 | "' is actually of type '"+ |
| 941 | CurFun.Values[ID.Num]->getType()->getDescription() + "'"); |
| 942 | } |
| 943 | } else { |
| 944 | GenerateError("Illegal label reference " + ID.getName()); |
| 945 | return 0; |
| 946 | } |
| 947 | |
| 948 | // If its already been defined, return it now. |
| 949 | if (BB) { |
| 950 | ID.destroy(); // Free strdup'd memory. |
| 951 | return BB; |
| 952 | } |
| 953 | |
| 954 | // Otherwise, this block has not been seen before, create it. |
| 955 | std::string Name; |
| 956 | if (ID.Type == ValID::LocalName) |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 957 | Name = ID.getName(); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 958 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 959 | |
| 960 | // Insert it in the forward refs map. |
| 961 | CurFun.BBForwardRefs[ID] = BB; |
| 962 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 963 | return BB; |
| 964 | } |
| 965 | |
| 966 | |
| 967 | //===----------------------------------------------------------------------===// |
| 968 | // Code to handle forward references in instructions |
| 969 | //===----------------------------------------------------------------------===// |
| 970 | // |
| 971 | // This code handles the late binding needed with statements that reference |
| 972 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 973 | // a loop body. |
| 974 | // |
| 975 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 976 | // and back patchs after we are done. |
| 977 | // |
| 978 | |
| 979 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 980 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 981 | // defs now... |
| 982 | // |
| 983 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 984 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 985 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 986 | while (!LateResolvers.empty()) { |
| 987 | Value *V = LateResolvers.back(); |
| 988 | LateResolvers.pop_back(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 989 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 990 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 991 | CurModule.PlaceHolderInfo.find(V); |
| 992 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 993 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 994 | ValID &DID = PHI->second.first; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 995 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 996 | Value *TheRealValue = getExistingVal(V->getType(), DID); |
| 997 | if (TriggerError) |
| 998 | return; |
| 999 | if (TheRealValue) { |
| 1000 | V->replaceAllUsesWith(TheRealValue); |
| 1001 | delete V; |
| 1002 | CurModule.PlaceHolderInfo.erase(PHI); |
| 1003 | } else if (FutureLateResolvers) { |
| 1004 | // Functions have their unresolved items forwarded to the module late |
| 1005 | // resolver table |
| 1006 | InsertValue(V, *FutureLateResolvers); |
| 1007 | } else { |
| 1008 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
| 1009 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
| 1010 | "' of type '" + V->getType()->getDescription() + "'", |
| 1011 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1012 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1013 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 1014 | GenerateError("Reference to an invalid definition: #" + |
| 1015 | itostr(DID.Num) + " of type '" + |
| 1016 | V->getType()->getDescription() + "'", |
| 1017 | PHI->second.second); |
| 1018 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1019 | } |
| 1020 | } |
| 1021 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1022 | LateResolvers.clear(); |
| 1023 | } |
| 1024 | |
| 1025 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 1026 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 1027 | // refering to the number can be resolved. Do this now. |
| 1028 | // |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1029 | static void ResolveTypeTo(std::string *Name, const Type *ToTy) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1030 | ValID D; |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1031 | if (Name) |
| 1032 | D = ValID::createLocalName(*Name); |
| 1033 | else |
| 1034 | D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1035 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 1036 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1037 | CurModule.LateResolveTypes.find(D); |
| 1038 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 1039 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1040 | CurModule.LateResolveTypes.erase(I); |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | // setValueName - Set the specified value to the name given. The name may be |
| 1045 | // null potentially, in which case this is a noop. The string passed in is |
| 1046 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 1047 | // |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1048 | static void setValueName(Value *V, std::string *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1049 | if (!NameStr) return; |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1050 | std::string Name(*NameStr); // Copy string |
| 1051 | delete NameStr; // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1052 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1053 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1054 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1055 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1056 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1057 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1058 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1059 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 1060 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1061 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1062 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1063 | return; |
| 1064 | } |
| 1065 | |
| 1066 | // Set the name. |
| 1067 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 1071 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1072 | static GlobalVariable * |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1073 | ParseGlobalVariable(std::string *NameStr, |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1074 | GlobalValue::LinkageTypes Linkage, |
| 1075 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1076 | bool isConstantGlobal, const Type *Ty, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 1077 | Constant *Initializer, bool IsThreadLocal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1078 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1079 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1080 | return 0; |
| 1081 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1082 | |
| 1083 | const PointerType *PTy = PointerType::get(Ty); |
| 1084 | |
| 1085 | std::string Name; |
| 1086 | if (NameStr) { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1087 | Name = *NameStr; // Copy string |
| 1088 | delete NameStr; // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1089 | } |
| 1090 | |
| 1091 | // See if this global value was forward referenced. If so, recycle the |
| 1092 | // object. |
| 1093 | ValID ID; |
| 1094 | if (!Name.empty()) { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1095 | ID = ValID::createGlobalName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1096 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 1097 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1101 | // Move the global to the end of the list, from whereever it was |
| 1102 | // previously inserted. |
| 1103 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1104 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1105 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1106 | GV->setInitializer(Initializer); |
| 1107 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1108 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1109 | GV->setConstant(isConstantGlobal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 1110 | GV->setThreadLocal(IsThreadLocal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1111 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1112 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1113 | } |
| 1114 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1115 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1116 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1117 | // if the global we're parsing has an initializer (is a definition) and |
| 1118 | // has external linkage. |
| 1119 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 1120 | // If there is already a global with external linkage with this name |
| 1121 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 1122 | // If we allow this GVar to get created, it will be renamed in the |
| 1123 | // symbol table because it conflicts with an existing GVar. We can't |
| 1124 | // allow redefinition of GVars whose linking indicates that their name |
| 1125 | // must stay the same. Issue the error. |
| 1126 | GenerateError("Redefinition of global variable named '" + Name + |
| 1127 | "' of type '" + Ty->getDescription() + "'"); |
| 1128 | return 0; |
| 1129 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | // Otherwise there is no existing GV to use, create one now. |
| 1133 | GlobalVariable *GV = |
| 1134 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 1135 | CurModule.CurrentModule, IsThreadLocal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1136 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1137 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1138 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | // setTypeName - Set the specified type to the name given. The name may be |
| 1142 | // null potentially, in which case this is a noop. The string passed in is |
| 1143 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1144 | // |
| 1145 | // This function returns true if the type has already been defined, but is |
| 1146 | // allowed to be redefined in the specified context. If the name is a new name |
| 1147 | // for the type plane, it is inserted and false is returned. |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1148 | static bool setTypeName(const Type *T, std::string *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1149 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1150 | if (NameStr == 0) return false; |
| 1151 | |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1152 | std::string Name(*NameStr); // Copy string |
| 1153 | delete NameStr; // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1154 | |
| 1155 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1156 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1157 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1158 | return false; |
| 1159 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1160 | |
| 1161 | // Set the type name, checking for conflicts as we do so. |
| 1162 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 1163 | |
| 1164 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1165 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1166 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1167 | |
| 1168 | // There is only one case where this is allowed: when we are refining an |
| 1169 | // opaque type. In this case, Existing will be an opaque type. |
| 1170 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1171 | // We ARE replacing an opaque type! |
| 1172 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 1173 | return true; |
| 1174 | } |
| 1175 | |
| 1176 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1177 | // the redefinition is identical to the original. This will be so if |
| 1178 | // Existing and T point to the same Type object. In this one case we |
| 1179 | // allow the equivalent redefinition. |
| 1180 | if (Existing == T) return true; // Yes, it's equal. |
| 1181 | |
| 1182 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 1183 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1184 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | return false; |
| 1188 | } |
| 1189 | |
| 1190 | //===----------------------------------------------------------------------===// |
| 1191 | // Code for handling upreferences in type names... |
| 1192 | // |
| 1193 | |
| 1194 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1195 | // |
| 1196 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1197 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1198 | E) != Ty->subtype_end(); |
| 1199 | } |
| 1200 | |
| 1201 | namespace { |
| 1202 | struct UpRefRecord { |
| 1203 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1204 | // this type is resolved. |
| 1205 | unsigned NestingLevel; |
| 1206 | |
| 1207 | // LastContainedTy - This is the type at the current binding level for the |
| 1208 | // type. Every time we reduce the nesting level, this gets updated. |
| 1209 | const Type *LastContainedTy; |
| 1210 | |
| 1211 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1212 | // represented with. |
| 1213 | OpaqueType *UpRefTy; |
| 1214 | |
| 1215 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1216 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1217 | }; |
| 1218 | } |
| 1219 | |
| 1220 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1221 | static std::vector<UpRefRecord> UpRefs; |
| 1222 | |
| 1223 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1224 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1225 | /// currently active types. For each type, if the up reference is contained in |
| 1226 | /// the newly completed type, we decrement the level count. When the level |
| 1227 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1228 | /// thus we can complete the cycle. |
| 1229 | /// |
| 1230 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1231 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1232 | // nothing to resolve here. |
| 1233 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1234 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1235 | PATypeHolder Ty(ty); |
| 1236 | UR_OUT("Type '" << Ty->getDescription() << |
| 1237 | "' newly formed. Resolving upreferences.\n" << |
| 1238 | UpRefs.size() << " upreferences active!\n"); |
| 1239 | |
| 1240 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1241 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1242 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1243 | // this variable. |
| 1244 | OpaqueType *TypeToResolve = 0; |
| 1245 | |
| 1246 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1247 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1248 | << UpRefs[i].second->getDescription() << ") = " |
| 1249 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1250 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1251 | // Decrement level of upreference |
| 1252 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1253 | UpRefs[i].LastContainedTy = Ty; |
| 1254 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1255 | if (Level == 0) { // Upreference should be resolved! |
| 1256 | if (!TypeToResolve) { |
| 1257 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1258 | } else { |
| 1259 | UR_OUT(" * Resolving upreference for " |
| 1260 | << UpRefs[i].second->getDescription() << "\n"; |
| 1261 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1262 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1263 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1264 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1265 | } |
| 1266 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1267 | --i; // Do not skip the next element... |
| 1268 | } |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | if (TypeToResolve) { |
| 1273 | UR_OUT(" * Resolving upreference for " |
| 1274 | << UpRefs[i].second->getDescription() << "\n"; |
| 1275 | std::string OldName = TypeToResolve->getDescription()); |
| 1276 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1277 | } |
| 1278 | |
| 1279 | return Ty; |
| 1280 | } |
| 1281 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1282 | //===----------------------------------------------------------------------===// |
| 1283 | // RunVMAsmParser - Define an interface to this parser |
| 1284 | //===----------------------------------------------------------------------===// |
| 1285 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1286 | static Module* RunParser(Module * M); |
| 1287 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1288 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1289 | set_scan_file(F); |
| 1290 | |
| 1291 | CurFilename = Filename; |
| 1292 | return RunParser(new Module(CurFilename)); |
| 1293 | } |
| 1294 | |
| 1295 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1296 | set_scan_string(AsmString); |
| 1297 | |
| 1298 | CurFilename = "from_memory"; |
| 1299 | if (M == NULL) { |
| 1300 | return RunParser(new Module (CurFilename)); |
| 1301 | } else { |
| 1302 | return RunParser(M); |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1307 | |
| 1308 | /* Enabling traces. */ |
| 1309 | #ifndef YYDEBUG |
| 1310 | # define YYDEBUG 0 |
| 1311 | #endif |
| 1312 | |
| 1313 | /* Enabling verbose error messages. */ |
| 1314 | #ifdef YYERROR_VERBOSE |
| 1315 | # undef YYERROR_VERBOSE |
| 1316 | # define YYERROR_VERBOSE 1 |
| 1317 | #else |
| 1318 | # define YYERROR_VERBOSE 0 |
| 1319 | #endif |
| 1320 | |
| 1321 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
| 1322 | #line 963 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 1323 | typedef union YYSTYPE { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1324 | llvm::Module *ModuleVal; |
| 1325 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1326 | llvm::BasicBlock *BasicBlockVal; |
| 1327 | llvm::TerminatorInst *TermInstVal; |
| 1328 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1329 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1330 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1331 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1332 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1333 | llvm::PATypeHolder *TypeVal; |
| 1334 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1335 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1336 | llvm::ArgListType *ArgList; |
| 1337 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1338 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1339 | llvm::ValueRefList *ValueRefList; |
| 1340 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1341 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1342 | std::list<std::pair<llvm::Value*, |
| 1343 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1344 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1345 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1346 | |
| 1347 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1348 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 1349 | uint16_t ParamAttrs; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 1350 | llvm::APInt *APIntVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1351 | int64_t SInt64Val; |
| 1352 | uint64_t UInt64Val; |
| 1353 | int SIntVal; |
| 1354 | unsigned UIntVal; |
| 1355 | double FPVal; |
| 1356 | bool BoolVal; |
| 1357 | |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1358 | std::string *StrVal; // This memory must be deleted |
| 1359 | llvm::ValID ValIDVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1360 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1361 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1362 | llvm::Instruction::TermOps TermOpVal; |
| 1363 | llvm::Instruction::MemoryOps MemOpVal; |
| 1364 | llvm::Instruction::CastOps CastOpVal; |
| 1365 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1366 | llvm::ICmpInst::Predicate IPredicate; |
| 1367 | llvm::FCmpInst::Predicate FPredicate; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 1368 | } YYSTYPE; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1369 | /* Line 191 of yacc.c. */ |
| 1370 | #line 1371 "llvmAsmParser.tab.c" |
| 1371 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1372 | # define YYSTYPE_IS_DECLARED 1 |
| 1373 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1374 | #endif |
| 1375 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1376 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1377 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1378 | /* Copy the second part of user declarations. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1379 | |
| 1380 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1381 | /* Line 214 of yacc.c. */ |
| 1382 | #line 1383 "llvmAsmParser.tab.c" |
Reid Spencer | b8f8505 | 2007-07-31 03:50:36 +0000 | [diff] [blame] | 1383 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1384 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 1385 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1386 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1387 | |
| 1388 | # ifdef YYSTACK_USE_ALLOCA |
| 1389 | # if YYSTACK_USE_ALLOCA |
| 1390 | # define YYSTACK_ALLOC alloca |
| 1391 | # endif |
| 1392 | # else |
| 1393 | # if defined (alloca) || defined (_ALLOCA_H) |
| 1394 | # define YYSTACK_ALLOC alloca |
| 1395 | # else |
| 1396 | # ifdef __GNUC__ |
| 1397 | # define YYSTACK_ALLOC __builtin_alloca |
| 1398 | # endif |
| 1399 | # endif |
| 1400 | # endif |
| 1401 | |
| 1402 | # ifdef YYSTACK_ALLOC |
| 1403 | /* Pacify GCC's `empty if-body' warning. */ |
| 1404 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 1405 | # else |
| 1406 | # if defined (__STDC__) || defined (__cplusplus) |
| 1407 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1408 | # define YYSIZE_T size_t |
| 1409 | # endif |
| 1410 | # define YYSTACK_ALLOC malloc |
| 1411 | # define YYSTACK_FREE free |
| 1412 | # endif |
| 1413 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 1414 | |
| 1415 | |
| 1416 | #if (! defined (yyoverflow) \ |
| 1417 | && (! defined (__cplusplus) \ |
| 1418 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 1419 | |
| 1420 | /* A type that is properly aligned for any stack member. */ |
| 1421 | union yyalloc |
| 1422 | { |
| 1423 | short yyss; |
| 1424 | YYSTYPE yyvs; |
| 1425 | }; |
| 1426 | |
| 1427 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1428 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1429 | |
| 1430 | /* The size of an array large to enough to hold all stacks, each with |
| 1431 | N elements. */ |
| 1432 | # define YYSTACK_BYTES(N) \ |
| 1433 | ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ |
| 1434 | + YYSTACK_GAP_MAXIMUM) |
| 1435 | |
| 1436 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1437 | not overlap. */ |
| 1438 | # ifndef YYCOPY |
| 1439 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 1440 | # define YYCOPY(To, From, Count) \ |
| 1441 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1442 | # else |
| 1443 | # define YYCOPY(To, From, Count) \ |
| 1444 | do \ |
| 1445 | { \ |
| 1446 | register YYSIZE_T yyi; \ |
| 1447 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1448 | (To)[yyi] = (From)[yyi]; \ |
| 1449 | } \ |
| 1450 | while (0) |
| 1451 | # endif |
| 1452 | # endif |
| 1453 | |
| 1454 | /* Relocate STACK from its old location to the new one. The |
| 1455 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1456 | elements in the stack, and YYPTR gives the new location of the |
| 1457 | stack. Advance YYPTR to a properly aligned location for the next |
| 1458 | stack. */ |
| 1459 | # define YYSTACK_RELOCATE(Stack) \ |
| 1460 | do \ |
| 1461 | { \ |
| 1462 | YYSIZE_T yynewbytes; \ |
| 1463 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1464 | Stack = &yyptr->Stack; \ |
| 1465 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1466 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1467 | } \ |
| 1468 | while (0) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 1469 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1470 | #endif |
| 1471 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1472 | #if defined (__STDC__) || defined (__cplusplus) |
| 1473 | typedef signed char yysigned_char; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1474 | #else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1475 | typedef short yysigned_char; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1476 | #endif |
| 1477 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1478 | /* YYFINAL -- State number of the termination state. */ |
| 1479 | #define YYFINAL 43 |
| 1480 | /* YYLAST -- Last index in YYTABLE. */ |
| 1481 | #define YYLAST 1685 |
| 1482 | |
| 1483 | /* YYNTOKENS -- Number of terminals. */ |
| 1484 | #define YYNTOKENS 160 |
| 1485 | /* YYNNTS -- Number of nonterminals. */ |
| 1486 | #define YYNNTS 82 |
| 1487 | /* YYNRULES -- Number of rules. */ |
| 1488 | #define YYNRULES 310 |
| 1489 | /* YYNRULES -- Number of states. */ |
| 1490 | #define YYNSTATES 594 |
| 1491 | |
| 1492 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1493 | #define YYUNDEFTOK 2 |
| 1494 | #define YYMAXUTOK 400 |
| 1495 | |
| 1496 | #define YYTRANSLATE(YYX) \ |
| 1497 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1498 | |
| 1499 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1500 | static const unsigned char yytranslate[] = |
| 1501 | { |
| 1502 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1503 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1504 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1505 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1506 | 150, 151, 148, 2, 147, 2, 2, 2, 2, 2, |
| 1507 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1508 | 155, 146, 156, 2, 2, 2, 2, 2, 2, 2, |
| 1509 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1510 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1511 | 2, 152, 149, 154, 2, 2, 2, 2, 2, 159, |
| 1512 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1513 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1514 | 153, 2, 2, 157, 2, 158, 2, 2, 2, 2, |
| 1515 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1516 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1517 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1518 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1519 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1520 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1521 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1522 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1523 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1524 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1525 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1526 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1527 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1528 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1529 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1530 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1531 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1532 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1533 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1534 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1535 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1536 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1537 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 1538 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 1539 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 1540 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
| 1541 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 1542 | 145 |
| 1543 | }; |
| 1544 | |
| 1545 | #if YYDEBUG |
| 1546 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1547 | YYRHS. */ |
| 1548 | static const unsigned short yyprhs[] = |
| 1549 | { |
| 1550 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1551 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1552 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 1553 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 1554 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 1555 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 1556 | 119, 121, 123, 125, 127, 129, 130, 133, 134, 136, |
| 1557 | 138, 140, 141, 144, 146, 148, 150, 152, 154, 156, |
| 1558 | 158, 160, 161, 163, 165, 167, 168, 170, 172, 173, |
| 1559 | 175, 177, 179, 181, 182, 184, 186, 187, 189, 191, |
| 1560 | 193, 195, 197, 200, 202, 204, 206, 208, 210, 212, |
| 1561 | 214, 216, 218, 219, 222, 224, 226, 228, 230, 231, |
| 1562 | 234, 235, 238, 239, 243, 246, 247, 249, 250, 254, |
| 1563 | 256, 259, 261, 263, 265, 267, 269, 271, 273, 275, |
| 1564 | 277, 280, 282, 285, 291, 297, 303, 309, 313, 316, |
| 1565 | 322, 327, 330, 332, 334, 336, 340, 342, 346, 348, |
| 1566 | 349, 351, 355, 360, 364, 368, 373, 378, 382, 389, |
| 1567 | 395, 398, 401, 404, 407, 410, 413, 416, 419, 422, |
| 1568 | 425, 428, 431, 438, 444, 453, 460, 467, 475, 483, |
| 1569 | 490, 499, 508, 512, 514, 516, 518, 520, 521, 524, |
| 1570 | 531, 533, 534, 536, 539, 540, 544, 545, 549, 553, |
| 1571 | 557, 561, 562, 570, 571, 580, 581, 590, 596, 599, |
| 1572 | 603, 605, 609, 613, 617, 621, 623, 624, 630, 634, |
| 1573 | 636, 640, 642, 643, 653, 655, 657, 662, 664, 666, |
| 1574 | 669, 673, 674, 676, 678, 680, 682, 684, 686, 688, |
| 1575 | 690, 692, 696, 698, 704, 706, 708, 710, 712, 714, |
| 1576 | 716, 719, 722, 725, 729, 732, 733, 735, 738, 741, |
| 1577 | 745, 755, 765, 774, 789, 791, 793, 800, 806, 809, |
| 1578 | 816, 824, 828, 834, 835, 836, 840, 843, 845, 851, |
| 1579 | 857, 864, 871, 876, 883, 888, 893, 900, 907, 910, |
| 1580 | 919, 921, 923, 924, 928, 935, 939, 946, 949, 955, |
| 1581 | 963 |
| 1582 | }; |
| 1583 | |
| 1584 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1585 | static const short yyrhs[] = |
| 1586 | { |
| 1587 | 204, 0, -1, 73, -1, 74, -1, 75, -1, 76, |
| 1588 | -1, 77, -1, 78, -1, 79, -1, 80, -1, 81, |
| 1589 | -1, 85, -1, 86, -1, 87, -1, 82, -1, 83, |
| 1590 | -1, 84, -1, 116, -1, 117, -1, 118, -1, 119, |
| 1591 | -1, 120, -1, 121, -1, 122, -1, 123, -1, 124, |
| 1592 | -1, 125, -1, 126, -1, 127, -1, 90, -1, 91, |
| 1593 | -1, 92, -1, 93, -1, 94, -1, 95, -1, 96, |
| 1594 | -1, 97, -1, 98, -1, 99, -1, 100, -1, 101, |
| 1595 | -1, 102, -1, 103, -1, 104, -1, 105, -1, 106, |
| 1596 | -1, 107, -1, 108, -1, 109, -1, 96, -1, 97, |
| 1597 | -1, 98, -1, 99, -1, 26, -1, 27, -1, 11, |
| 1598 | -1, 12, -1, 13, -1, 16, -1, 15, -1, 14, |
| 1599 | -1, 19, -1, 22, -1, 24, -1, 168, -1, -1, |
| 1600 | 168, 146, -1, -1, 20, -1, 23, -1, 173, -1, |
| 1601 | -1, 171, 146, -1, 42, -1, 44, -1, 43, -1, |
| 1602 | 45, -1, 47, -1, 46, -1, 48, -1, 50, -1, |
| 1603 | -1, 143, -1, 144, -1, 145, -1, -1, 46, -1, |
| 1604 | 48, -1, -1, 42, -1, 43, -1, 44, -1, 47, |
| 1605 | -1, -1, 44, -1, 42, -1, -1, 61, -1, 62, |
| 1606 | -1, 63, -1, 64, -1, 65, -1, 60, 4, -1, |
| 1607 | 135, -1, 117, -1, 134, -1, 118, -1, 137, -1, |
| 1608 | 138, -1, 140, -1, 141, -1, 142, -1, -1, 182, |
| 1609 | 181, -1, 136, -1, 139, -1, 135, -1, 134, -1, |
| 1610 | -1, 184, 183, -1, -1, 53, 4, -1, -1, 147, |
| 1611 | 53, 4, -1, 34, 22, -1, -1, 187, -1, -1, |
| 1612 | 147, 190, 189, -1, 187, -1, 53, 4, -1, 11, |
| 1613 | -1, 12, -1, 13, -1, 16, -1, 15, -1, 14, |
| 1614 | -1, 17, -1, 49, -1, 191, -1, 192, 148, -1, |
| 1615 | 226, -1, 149, 4, -1, 192, 150, 196, 151, 184, |
| 1616 | -1, 10, 150, 196, 151, 184, -1, 152, 4, 153, |
| 1617 | 192, 154, -1, 155, 4, 153, 192, 156, -1, 157, |
| 1618 | 197, 158, -1, 157, 158, -1, 155, 157, 197, 158, |
| 1619 | 156, -1, 155, 157, 158, 156, -1, 192, 182, -1, |
| 1620 | 192, -1, 10, -1, 193, -1, 195, 147, 193, -1, |
| 1621 | 195, -1, 195, 147, 39, -1, 39, -1, -1, 192, |
| 1622 | -1, 197, 147, 192, -1, 192, 152, 200, 154, -1, |
| 1623 | 192, 152, 154, -1, 192, 159, 22, -1, 192, 155, |
| 1624 | 200, 156, -1, 192, 157, 200, 158, -1, 192, 157, |
| 1625 | 158, -1, 192, 155, 157, 200, 158, 156, -1, 192, |
| 1626 | 155, 157, 158, 156, -1, 192, 40, -1, 192, 41, |
| 1627 | -1, 192, 226, -1, 192, 199, -1, 192, 25, -1, |
| 1628 | 166, 3, -1, 166, 5, -1, 166, 4, -1, 166, |
| 1629 | 6, -1, 11, 26, -1, 11, 27, -1, 167, 9, |
| 1630 | -1, 163, 150, 198, 38, 192, 151, -1, 115, 150, |
| 1631 | 198, 237, 151, -1, 129, 150, 198, 147, 198, 147, |
| 1632 | 198, 151, -1, 161, 150, 198, 147, 198, 151, -1, |
| 1633 | 162, 150, 198, 147, 198, 151, -1, 88, 164, 150, |
| 1634 | 198, 147, 198, 151, -1, 89, 165, 150, 198, 147, |
| 1635 | 198, 151, -1, 131, 150, 198, 147, 198, 151, -1, |
| 1636 | 132, 150, 198, 147, 198, 147, 198, 151, -1, 133, |
| 1637 | 150, 198, 147, 198, 147, 198, 151, -1, 200, 147, |
| 1638 | 198, -1, 198, -1, 32, -1, 33, -1, 37, -1, |
| 1639 | -1, 194, 226, -1, 121, 150, 203, 38, 192, 151, |
| 1640 | -1, 205, -1, -1, 206, -1, 205, 206, -1, -1, |
| 1641 | 31, 207, 222, -1, -1, 30, 208, 223, -1, 58, |
| 1642 | 57, 212, -1, 170, 18, 192, -1, 170, 18, 10, |
| 1643 | -1, -1, 172, 176, 202, 201, 198, 209, 189, -1, |
| 1644 | -1, 172, 174, 176, 202, 201, 198, 210, 189, -1, |
| 1645 | -1, 172, 175, 176, 202, 201, 192, 211, 189, -1, |
| 1646 | 172, 176, 35, 179, 203, -1, 51, 213, -1, 54, |
| 1647 | 146, 214, -1, 22, -1, 52, 146, 22, -1, 66, |
| 1648 | 146, 22, -1, 152, 215, 154, -1, 215, 147, 22, |
| 1649 | -1, 22, -1, -1, 216, 147, 192, 182, 169, -1, |
| 1650 | 192, 182, 169, -1, 216, -1, 216, 147, 39, -1, |
| 1651 | 39, -1, -1, 180, 194, 171, 150, 217, 151, 184, |
| 1652 | 188, 185, -1, 28, -1, 157, -1, 178, 176, 218, |
| 1653 | 219, -1, 29, -1, 158, -1, 229, 221, -1, 177, |
| 1654 | 176, 218, -1, -1, 59, -1, 3, -1, 4, -1, |
| 1655 | 9, -1, 26, -1, 27, -1, 40, -1, 41, -1, |
| 1656 | 25, -1, 155, 200, 156, -1, 199, -1, 57, 224, |
| 1657 | 22, 147, 22, -1, 7, -1, 8, -1, 168, -1, |
| 1658 | 171, -1, 226, -1, 225, -1, 192, 227, -1, 229, |
| 1659 | 230, -1, 220, 230, -1, 231, 170, 232, -1, 231, |
| 1660 | 234, -1, -1, 21, -1, 67, 228, -1, 67, 10, |
| 1661 | -1, 68, 17, 227, -1, 68, 11, 227, 147, 17, |
| 1662 | 227, 147, 17, 227, -1, 69, 166, 227, 147, 17, |
| 1663 | 227, 152, 233, 154, -1, 69, 166, 227, 147, 17, |
| 1664 | 227, 152, 154, -1, 70, 180, 194, 227, 150, 236, |
| 1665 | 151, 184, 38, 17, 227, 71, 17, 227, -1, 71, |
| 1666 | -1, 72, -1, 233, 166, 225, 147, 17, 227, -1, |
| 1667 | 166, 225, 147, 17, 227, -1, 170, 239, -1, 192, |
| 1668 | 152, 227, 147, 227, 154, -1, 235, 147, 152, 227, |
| 1669 | 147, 227, 154, -1, 192, 227, 182, -1, 236, 147, |
| 1670 | 192, 227, 182, -1, -1, -1, 237, 147, 228, -1, |
| 1671 | 56, 55, -1, 55, -1, 161, 192, 227, 147, 227, |
| 1672 | -1, 162, 192, 227, 147, 227, -1, 88, 164, 192, |
| 1673 | 227, 147, 227, -1, 89, 165, 192, 227, 147, 227, |
| 1674 | -1, 163, 228, 38, 192, -1, 129, 228, 147, 228, |
| 1675 | 147, 228, -1, 130, 228, 147, 192, -1, 131, 228, |
| 1676 | 147, 228, -1, 132, 228, 147, 228, 147, 228, -1, |
| 1677 | 133, 228, 147, 228, 147, 228, -1, 128, 235, -1, |
| 1678 | 238, 180, 194, 227, 150, 236, 151, 184, -1, 241, |
| 1679 | -1, 36, -1, -1, 110, 192, 186, -1, 110, 192, |
| 1680 | 147, 11, 227, 186, -1, 111, 192, 186, -1, 111, |
| 1681 | 192, 147, 11, 227, 186, -1, 112, 228, -1, 240, |
| 1682 | 113, 192, 227, 186, -1, 240, 114, 228, 147, 192, |
| 1683 | 227, 186, -1, 115, 192, 227, 237, -1 |
| 1684 | }; |
| 1685 | |
| 1686 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1687 | static const unsigned short yyrline[] = |
| 1688 | { |
| 1689 | 0, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, |
| 1690 | 1122, 1123, 1123, 1123, 1123, 1123, 1123, 1124, 1124, 1124, |
| 1691 | 1124, 1124, 1124, 1125, 1125, 1125, 1125, 1125, 1125, 1128, |
| 1692 | 1128, 1129, 1129, 1130, 1130, 1131, 1131, 1132, 1132, 1136, |
| 1693 | 1136, 1137, 1137, 1138, 1138, 1139, 1139, 1140, 1140, 1141, |
| 1694 | 1141, 1142, 1142, 1143, 1144, 1149, 1150, 1150, 1150, 1150, |
| 1695 | 1150, 1152, 1152, 1152, 1153, 1153, 1157, 1161, 1166, 1166, |
| 1696 | 1168, 1169, 1174, 1180, 1181, 1182, 1183, 1184, 1188, 1189, |
| 1697 | 1190, 1194, 1195, 1196, 1197, 1201, 1202, 1203, 1207, 1208, |
| 1698 | 1209, 1210, 1211, 1215, 1216, 1217, 1220, 1221, 1222, 1223, |
| 1699 | 1224, 1225, 1226, 1233, 1234, 1235, 1236, 1237, 1238, 1239, |
| 1700 | 1240, 1241, 1244, 1245, 1250, 1251, 1252, 1253, 1256, 1257, |
| 1701 | 1264, 1265, 1271, 1272, 1280, 1288, 1289, 1294, 1295, 1296, |
| 1702 | 1301, 1314, 1314, 1314, 1314, 1314, 1314, 1314, 1317, 1321, |
| 1703 | 1325, 1332, 1337, 1345, 1375, 1406, 1411, 1423, 1433, 1437, |
| 1704 | 1447, 1454, 1461, 1468, 1473, 1478, 1485, 1486, 1493, 1500, |
| 1705 | 1508, 1514, 1526, 1554, 1570, 1597, 1625, 1651, 1671, 1697, |
| 1706 | 1717, 1729, 1736, 1802, 1812, 1822, 1828, 1838, 1844, 1854, |
| 1707 | 1859, 1864, 1872, 1884, 1906, 1914, 1920, 1931, 1936, 1941, |
| 1708 | 1947, 1953, 1962, 1966, 1974, 1974, 1977, 1977, 1980, 1992, |
| 1709 | 2013, 2018, 2026, 2027, 2031, 2031, 2035, 2035, 2038, 2041, |
| 1710 | 2065, 2076, 2076, 2087, 2086, 2096, 2095, 2106, 2125, 2128, |
| 1711 | 2134, 2144, 2148, 2153, 2155, 2160, 2165, 2174, 2184, 2195, |
| 1712 | 2199, 2208, 2217, 2222, 2343, 2343, 2345, 2354, 2354, 2356, |
| 1713 | 2361, 2373, 2377, 2382, 2386, 2390, 2394, 2398, 2402, 2406, |
| 1714 | 2410, 2414, 2439, 2443, 2453, 2457, 2461, 2466, 2473, 2473, |
| 1715 | 2479, 2488, 2492, 2501, 2510, 2519, 2523, 2530, 2534, 2538, |
| 1716 | 2543, 2553, 2572, 2581, 2661, 2665, 2672, 2683, 2696, 2706, |
| 1717 | 2717, 2727, 2736, 2745, 2748, 2749, 2756, 2760, 2765, 2786, |
| 1718 | 2803, 2817, 2831, 2843, 2851, 2858, 2864, 2870, 2876, 2891, |
| 1719 | 2976, 2981, 2985, 2992, 2999, 3007, 3014, 3022, 3030, 3044, |
| 1720 | 3061 |
| 1721 | }; |
| 1722 | #endif |
| 1723 | |
| 1724 | #if YYDEBUG || YYERROR_VERBOSE |
| 1725 | /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1726 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1727 | static const char *const yytname[] = |
| 1728 | { |
| 1729 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL", |
| 1730 | "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE", |
| 1731 | "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE", |
| 1732 | "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT", |
| 1733 | "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK", |
| 1734 | "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL", |
| 1735 | "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO", |
| 1736 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK", |
| 1737 | "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 1738 | "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL", |
| 1739 | "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK", |
| 1740 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 1741 | "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", |
| 1742 | "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", |
| 1743 | "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", |
| 1744 | "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", |
| 1745 | "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", |
| 1746 | "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", |
| 1747 | "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", |
| 1748 | "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", |
| 1749 | "INSERTELEMENT", "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT", "NORETURN", |
| 1750 | "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "DEFAULT", |
| 1751 | "HIDDEN", "PROTECTED", "'='", "','", "'*'", "'\\\\'", "'('", "')'", |
| 1752 | "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", |
| 1753 | "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates", |
| 1754 | "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign", |
| 1755 | "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage", |
| 1756 | "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage", |
| 1757 | "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr", |
| 1758 | "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign", |
| 1759 | "SectionString", "OptSection", "GlobalVarAttributes", |
| 1760 | "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes", |
| 1761 | "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr", |
| 1762 | "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module", |
| 1763 | "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock", |
| 1764 | "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH", |
| 1765 | "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", |
| 1766 | "Function", "FunctionProto", "OptSideEffect", "ConstValueRef", |
| 1767 | "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList", |
| 1768 | "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", |
| 1769 | "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal", |
| 1770 | "OptVolatile", "MemoryInst", 0 |
| 1771 | }; |
| 1772 | #endif |
| 1773 | |
| 1774 | # ifdef YYPRINT |
| 1775 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1776 | token YYLEX-NUM. */ |
| 1777 | static const unsigned short yytoknum[] = |
| 1778 | { |
| 1779 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1780 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1781 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1782 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1783 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1784 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1785 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1786 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1787 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1788 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 1789 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 1790 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 1791 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 1792 | 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, |
| 1793 | 395, 396, 397, 398, 399, 400, 61, 44, 42, 92, |
| 1794 | 40, 41, 91, 120, 93, 60, 62, 123, 125, 99 |
| 1795 | }; |
| 1796 | # endif |
| 1797 | |
| 1798 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1799 | static const unsigned char yyr1[] = |
| 1800 | { |
| 1801 | 0, 160, 161, 161, 161, 161, 161, 161, 161, 161, |
| 1802 | 161, 162, 162, 162, 162, 162, 162, 163, 163, 163, |
| 1803 | 163, 163, 163, 163, 163, 163, 163, 163, 163, 164, |
| 1804 | 164, 164, 164, 164, 164, 164, 164, 164, 164, 165, |
| 1805 | 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, |
| 1806 | 165, 165, 165, 165, 165, 166, 167, 167, 167, 167, |
| 1807 | 167, 168, 168, 168, 169, 169, 170, 170, 171, 171, |
| 1808 | 172, 172, 173, 174, 174, 174, 174, 174, 175, 175, |
| 1809 | 175, 176, 176, 176, 176, 177, 177, 177, 178, 178, |
| 1810 | 178, 178, 178, 179, 179, 179, 180, 180, 180, 180, |
| 1811 | 180, 180, 180, 181, 181, 181, 181, 181, 181, 181, |
| 1812 | 181, 181, 182, 182, 183, 183, 183, 183, 184, 184, |
| 1813 | 185, 185, 186, 186, 187, 188, 188, 189, 189, 190, |
| 1814 | 190, 191, 191, 191, 191, 191, 191, 191, 192, 192, |
| 1815 | 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, |
| 1816 | 192, 193, 194, 194, 195, 195, 196, 196, 196, 196, |
| 1817 | 197, 197, 198, 198, 198, 198, 198, 198, 198, 198, |
| 1818 | 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, |
| 1819 | 198, 198, 199, 199, 199, 199, 199, 199, 199, 199, |
| 1820 | 199, 199, 200, 200, 201, 201, 202, 202, 203, 203, |
| 1821 | 204, 204, 205, 205, 207, 206, 208, 206, 206, 206, |
| 1822 | 206, 209, 206, 210, 206, 211, 206, 206, 206, 206, |
| 1823 | 212, 213, 213, 214, 215, 215, 215, 216, 216, 217, |
| 1824 | 217, 217, 217, 218, 219, 219, 220, 221, 221, 222, |
| 1825 | 223, 224, 224, 225, 225, 225, 225, 225, 225, 225, |
| 1826 | 225, 225, 225, 225, 226, 226, 226, 226, 227, 227, |
| 1827 | 228, 229, 229, 230, 231, 231, 231, 232, 232, 232, |
| 1828 | 232, 232, 232, 232, 232, 232, 233, 233, 234, 235, |
| 1829 | 235, 236, 236, 236, 237, 237, 238, 238, 239, 239, |
| 1830 | 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, |
| 1831 | 239, 240, 240, 241, 241, 241, 241, 241, 241, 241, |
| 1832 | 241 |
| 1833 | }; |
| 1834 | |
| 1835 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1836 | static const unsigned char yyr2[] = |
| 1837 | { |
| 1838 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1839 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1840 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1841 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1842 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1843 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1844 | 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, |
| 1845 | 1, 0, 2, 1, 1, 1, 1, 1, 1, 1, |
| 1846 | 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, |
| 1847 | 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, |
| 1848 | 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, |
| 1849 | 1, 1, 0, 2, 1, 1, 1, 1, 0, 2, |
| 1850 | 0, 2, 0, 3, 2, 0, 1, 0, 3, 1, |
| 1851 | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1852 | 2, 1, 2, 5, 5, 5, 5, 3, 2, 5, |
| 1853 | 4, 2, 1, 1, 1, 3, 1, 3, 1, 0, |
| 1854 | 1, 3, 4, 3, 3, 4, 4, 3, 6, 5, |
| 1855 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1856 | 2, 2, 6, 5, 8, 6, 6, 7, 7, 6, |
| 1857 | 8, 8, 3, 1, 1, 1, 1, 0, 2, 6, |
| 1858 | 1, 0, 1, 2, 0, 3, 0, 3, 3, 3, |
| 1859 | 3, 0, 7, 0, 8, 0, 8, 5, 2, 3, |
| 1860 | 1, 3, 3, 3, 3, 1, 0, 5, 3, 1, |
| 1861 | 3, 1, 0, 9, 1, 1, 4, 1, 1, 2, |
| 1862 | 3, 0, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1863 | 1, 3, 1, 5, 1, 1, 1, 1, 1, 1, |
| 1864 | 2, 2, 2, 3, 2, 0, 1, 2, 2, 3, |
| 1865 | 9, 9, 8, 14, 1, 1, 6, 5, 2, 6, |
| 1866 | 7, 3, 5, 0, 0, 3, 2, 1, 5, 5, |
| 1867 | 6, 6, 4, 6, 4, 4, 6, 6, 2, 8, |
| 1868 | 1, 1, 0, 3, 6, 3, 6, 2, 5, 7, |
| 1869 | 4 |
| 1870 | }; |
| 1871 | |
| 1872 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 1873 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 1874 | means the default is an error. */ |
| 1875 | static const unsigned short yydefact[] = |
| 1876 | { |
| 1877 | 71, 61, 68, 62, 69, 63, 206, 204, 0, 0, |
| 1878 | 0, 0, 0, 0, 81, 70, 0, 71, 202, 85, |
| 1879 | 88, 0, 0, 218, 0, 0, 66, 0, 72, 73, |
| 1880 | 75, 74, 76, 78, 77, 79, 80, 82, 83, 84, |
| 1881 | 81, 81, 197, 1, 203, 86, 87, 81, 207, 89, |
| 1882 | 90, 91, 92, 81, 265, 205, 265, 0, 0, 226, |
| 1883 | 219, 220, 208, 254, 255, 210, 131, 132, 133, 136, |
| 1884 | 135, 134, 137, 138, 0, 0, 0, 0, 256, 257, |
| 1885 | 139, 209, 141, 197, 197, 93, 196, 0, 96, 96, |
| 1886 | 266, 262, 67, 237, 238, 239, 261, 221, 222, 225, |
| 1887 | 0, 159, 142, 0, 0, 0, 0, 148, 160, 0, |
| 1888 | 140, 159, 0, 0, 95, 94, 0, 194, 195, 0, |
| 1889 | 0, 97, 98, 99, 100, 101, 0, 240, 0, 302, |
| 1890 | 264, 0, 223, 158, 112, 154, 156, 0, 0, 0, |
| 1891 | 0, 0, 0, 147, 0, 0, 0, 153, 0, 152, |
| 1892 | 0, 217, 131, 132, 133, 136, 135, 134, 0, 0, |
| 1893 | 0, 211, 102, 0, 234, 235, 236, 301, 287, 0, |
| 1894 | 0, 0, 0, 96, 274, 275, 2, 3, 4, 5, |
| 1895 | 6, 7, 8, 9, 10, 14, 15, 16, 11, 12, |
| 1896 | 13, 0, 0, 0, 0, 0, 0, 17, 18, 19, |
| 1897 | 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, |
| 1898 | 0, 0, 0, 0, 0, 0, 0, 0, 263, 96, |
| 1899 | 278, 0, 300, 224, 151, 0, 118, 0, 0, 150, |
| 1900 | 0, 161, 118, 213, 215, 0, 198, 179, 180, 175, |
| 1901 | 177, 176, 178, 181, 174, 170, 171, 0, 0, 0, |
| 1902 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1903 | 0, 173, 172, 127, 0, 286, 268, 0, 267, 0, |
| 1904 | 0, 55, 0, 0, 29, 30, 31, 32, 33, 34, |
| 1905 | 35, 36, 37, 38, 0, 53, 54, 49, 50, 51, |
| 1906 | 52, 39, 40, 41, 42, 43, 44, 45, 46, 47, |
| 1907 | 48, 0, 122, 122, 307, 0, 0, 298, 0, 0, |
| 1908 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, |
| 1909 | 106, 105, 103, 107, 108, 109, 110, 111, 113, 157, |
| 1910 | 155, 144, 145, 146, 149, 143, 127, 127, 0, 0, |
| 1911 | 0, 0, 0, 0, 0, 0, 163, 193, 0, 0, |
| 1912 | 0, 167, 0, 164, 0, 0, 0, 0, 212, 232, |
| 1913 | 243, 244, 245, 250, 246, 247, 248, 249, 241, 0, |
| 1914 | 252, 259, 258, 260, 0, 269, 0, 0, 0, 0, |
| 1915 | 0, 303, 0, 305, 284, 0, 0, 0, 0, 0, |
| 1916 | 0, 0, 0, 0, 0, 0, 0, 0, 117, 116, |
| 1917 | 114, 115, 119, 214, 216, 0, 0, 0, 284, 0, |
| 1918 | 0, 0, 0, 0, 162, 148, 160, 0, 165, 166, |
| 1919 | 0, 0, 0, 0, 0, 129, 127, 231, 112, 229, |
| 1920 | 0, 242, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1921 | 0, 0, 310, 0, 0, 0, 294, 295, 0, 0, |
| 1922 | 0, 0, 292, 0, 122, 0, 0, 0, 0, 0, |
| 1923 | 0, 0, 0, 0, 192, 169, 0, 0, 0, 0, |
| 1924 | 124, 130, 128, 65, 0, 118, 0, 251, 0, 0, |
| 1925 | 283, 0, 0, 122, 123, 122, 0, 0, 0, 0, |
| 1926 | 0, 0, 288, 289, 283, 0, 308, 0, 199, 0, |
| 1927 | 0, 183, 0, 0, 0, 0, 168, 0, 0, 0, |
| 1928 | 64, 228, 230, 112, 125, 0, 0, 0, 0, 0, |
| 1929 | 290, 291, 304, 306, 285, 0, 0, 293, 296, 297, |
| 1930 | 0, 122, 0, 0, 0, 189, 0, 0, 185, 186, |
| 1931 | 182, 65, 126, 120, 253, 0, 0, 112, 0, 118, |
| 1932 | 279, 0, 118, 309, 187, 188, 0, 0, 0, 227, |
| 1933 | 0, 233, 0, 272, 0, 0, 281, 0, 0, 280, |
| 1934 | 299, 184, 190, 191, 121, 270, 0, 271, 0, 112, |
| 1935 | 0, 0, 0, 282, 0, 0, 0, 0, 277, 0, |
| 1936 | 0, 276, 0, 273 |
| 1937 | }; |
| 1938 | |
| 1939 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 1940 | static const short yydefgoto[] = |
| 1941 | { |
| 1942 | -1, 258, 259, 260, 284, 301, 158, 159, 78, 511, |
| 1943 | 12, 79, 14, 15, 40, 41, 42, 47, 53, 116, |
| 1944 | 126, 328, 224, 402, 331, 561, 381, 425, 543, 358, |
| 1945 | 426, 80, 160, 135, 150, 136, 137, 109, 347, 370, |
| 1946 | 348, 119, 87, 151, 16, 17, 18, 20, 19, 263, |
| 1947 | 336, 337, 62, 23, 60, 100, 429, 430, 127, 166, |
| 1948 | 54, 95, 55, 48, 432, 371, 82, 373, 268, 56, |
| 1949 | 91, 92, 218, 565, 130, 307, 519, 442, 219, 220, |
| 1950 | 221, 222 |
| 1951 | }; |
| 1952 | |
| 1953 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 1954 | STATE-NUM. */ |
| 1955 | #define YYPACT_NINF -529 |
| 1956 | static const short yypact[] = |
| 1957 | { |
| 1958 | 40, -529, -529, -529, -529, -529, -529, -529, -17, -107, |
| 1959 | 12, -64, 78, -40, 183, -529, 150, 370, -529, 147, |
| 1960 | 115, -5, 26, -529, 14, 132, -529, 1319, -529, -529, |
| 1961 | -529, -529, -529, -529, -529, -529, -529, -529, -529, -529, |
| 1962 | -90, -90, 173, -529, -529, -529, -529, -90, -529, -529, |
| 1963 | -529, -529, -529, -90, 154, -529, -7, 179, 197, 214, |
| 1964 | -529, -529, -529, -529, -529, 96, -529, -529, -529, -529, |
| 1965 | -529, -529, -529, -529, 253, 258, 3, 791, -529, -529, |
| 1966 | -529, 145, -529, 228, 228, 287, -529, 191, 189, 189, |
| 1967 | -529, -529, 109, -529, -529, -529, -529, -529, -529, -529, |
| 1968 | -66, 1052, -529, 125, 135, 835, 96, -529, 145, -110, |
| 1969 | -529, 1052, 191, 191, -529, -529, 1092, -529, -529, 1359, |
| 1970 | 285, -529, -529, -529, -529, -529, 1377, -529, -12, 1525, |
| 1971 | -529, 272, -529, -529, 145, -529, 153, 152, 1430, 1430, |
| 1972 | 168, -106, 1430, -529, 157, 1359, 1430, 96, 159, 145, |
| 1973 | 102, -529, 39, 321, 323, 325, 326, 327, 266, 328, |
| 1974 | 750, -529, -529, 141, -529, -529, -529, -529, -529, 288, |
| 1975 | 1470, 94, 329, 189, -529, -529, -529, -529, -529, -529, |
| 1976 | -529, -529, -529, -529, -529, -529, -529, -529, -529, -529, |
| 1977 | -529, 222, 625, 1430, 1430, 1430, 1430, -529, -529, -529, |
| 1978 | -529, -529, -529, -529, -529, -529, -529, -529, -529, 1430, |
| 1979 | 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, -529, 189, |
| 1980 | -529, 128, -529, -529, 126, 1110, -529, -53, -72, -529, |
| 1981 | 188, 145, -529, -529, 145, 1092, -529, -529, -529, -529, |
| 1982 | -529, -529, -529, -529, -529, -529, -529, 222, 625, 195, |
| 1983 | 196, 200, 201, 202, 1204, 1528, 1012, 331, 204, 206, |
| 1984 | 208, -529, -529, 212, 210, -529, 96, 486, -529, 623, |
| 1985 | 623, -529, 623, 1377, -529, -529, -529, -529, -529, -529, |
| 1986 | -529, -529, -529, -529, 1430, -529, -529, -529, -529, -529, |
| 1987 | -529, -529, -529, -529, -529, -529, -529, -529, -529, -529, |
| 1988 | -529, 1430, -1, 32, -529, 486, 52, 219, 220, 224, |
| 1989 | 227, 230, 233, 486, 486, 343, 1377, 1430, 1430, -529, |
| 1990 | -529, -529, -529, -529, -529, -529, -529, -529, -529, -529, |
| 1991 | -529, 77, -529, -529, -529, 77, 212, 212, 344, 234, |
| 1992 | 235, 1359, 1359, 1359, 1359, 1359, -529, -529, -61, 1031, |
| 1993 | -100, -529, -101, -529, 1359, 1359, 1359, -19, -529, 1261, |
| 1994 | -529, -529, -529, -529, -529, -529, -529, -529, 310, 1359, |
| 1995 | -529, -529, -529, -529, 236, -529, 240, 623, 486, 486, |
| 1996 | 20, -529, 21, -529, -529, 623, 239, 1430, 1430, 1430, |
| 1997 | 1430, 1430, 249, 250, 1430, 623, 486, 251, -529, -529, |
| 1998 | -529, -529, -529, -529, -529, 1430, 1359, 1359, -529, 252, |
| 1999 | 259, 260, 264, 1359, -529, 256, 750, -75, -529, -529, |
| 2000 | 267, 268, 375, 396, 415, -529, 212, -529, 145, 273, |
| 2001 | 274, -529, 401, -79, 409, 413, 281, 286, 289, 623, |
| 2002 | 428, 623, 290, 291, 623, 292, 145, -529, 293, 299, |
| 2003 | 623, 623, 145, 284, 300, 1430, 84, 303, 304, -44, |
| 2004 | 1359, 1359, 1359, 1359, -529, -529, 279, 1359, 1359, 1430, |
| 2005 | -529, -529, -529, 80, 1279, -529, 306, -529, 623, 623, |
| 2006 | 1430, 623, 623, 300, -529, 300, 1430, 623, 308, 1430, |
| 2007 | 1430, 1430, -529, -529, 1430, 403, -529, 486, -529, 1359, |
| 2008 | 1359, -529, 311, 315, 312, 314, -529, 316, 318, 129, |
| 2009 | -529, -529, -529, 145, 4, 435, 324, 320, 486, -33, |
| 2010 | -529, -529, -529, -529, -529, 330, 623, -529, -529, -529, |
| 2011 | -32, 300, 319, 332, 1359, -529, 1359, 1359, -529, -529, |
| 2012 | -529, 80, -529, 421, -529, 445, -2, -529, 1430, -529, |
| 2013 | -529, 333, -529, -529, -529, -529, 334, 335, 340, -529, |
| 2014 | 471, -529, 623, -529, 885, 2, 126, 486, 42, -529, |
| 2015 | 77, -529, -529, -529, -529, -529, 345, -529, 885, -529, |
| 2016 | 460, 479, 350, 126, 623, 623, 483, 430, -529, 623, |
| 2017 | 485, -529, 623, -529 |
| 2018 | }; |
| 2019 | |
| 2020 | /* YYPGOTO[NTERM-NUM]. */ |
| 2021 | static const short yypgoto[] = |
| 2022 | { |
| 2023 | -529, 374, 378, 385, 257, 269, -170, -529, 0, -25, |
| 2024 | 423, 8, -529, -529, -529, -529, 95, -529, -529, -529, |
| 2025 | -152, -529, -424, -529, -227, -529, -291, 5, -529, -318, |
| 2026 | -529, -529, -26, 295, -120, -529, 407, 416, -58, -157, |
| 2027 | -232, 161, 198, 294, -529, -529, 506, -529, -529, -529, |
| 2028 | -529, -529, -529, -529, -529, -529, -529, -529, 436, -529, |
| 2029 | -529, -529, -529, -529, -529, -528, -140, 103, -184, -529, |
| 2030 | 468, -529, -529, -529, -529, -529, 34, 122, -529, -529, |
| 2031 | -529, -529 |
| 2032 | }; |
| 2033 | |
| 2034 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2035 | positive, shift that token. If negative, reduce the rule which |
| 2036 | number is the opposite. If zero, do what YYDEFACT says. |
| 2037 | If YYTABLE_NINF, syntax error. */ |
| 2038 | #define YYTABLE_NINF -202 |
| 2039 | static const short yytable[] = |
| 2040 | { |
| 2041 | 11, 81, 272, 261, 473, 335, 163, 104, 13, 271, |
| 2042 | 236, 304, 383, 271, 90, 423, 164, 11, 403, 404, |
| 2043 | 262, 273, 93, 350, 352, 13, 308, 309, 310, 311, |
| 2044 | 312, 439, 441, 315, 424, 21, 576, 142, 423, 24, |
| 2045 | -201, 142, -55, -55, -55, -55, 413, 413, 143, 22, |
| 2046 | 582, 108, 230, 37, 38, 39, 418, 419, -67, 1, |
| 2047 | 2, 161, 3, 4, 5, 237, 238, 316, 413, 25, |
| 2048 | 6, 7, 413, 440, 440, 134, 110, 477, 111, 108, |
| 2049 | 580, 131, 26, 466, 333, 134, 413, 233, 132, 541, |
| 2050 | 149, 8, 11, 414, 9, 110, 27, 111, 10, 1, |
| 2051 | 149, 332, 3, 486, 5, 269, 28, 501, 472, 63, |
| 2052 | 64, 270, 227, 228, 548, 548, 231, 417, 549, 552, |
| 2053 | 234, 1, 2, 566, 3, 4, 5, 372, 1, 372, |
| 2054 | 372, 3, 372, 5, 397, 83, 84, 433, 398, 399, |
| 2055 | 400, 57, 88, 401, 267, 165, 380, 110, 89, 111, |
| 2056 | 43, 94, 563, 377, 61, 583, 577, 49, 50, 51, |
| 2057 | 105, 2, 52, 496, 4, 372, 59, 302, 303, 267, |
| 2058 | 305, 264, 58, 372, 372, 90, 398, 399, 400, 382, |
| 2059 | 110, 401, 111, 306, 267, 267, 267, 267, 267, 313, |
| 2060 | 314, 267, 522, 45, 523, 46, 395, 319, 320, 134, |
| 2061 | 110, 97, 111, 445, 385, 447, 448, 449, 85, 149, |
| 2062 | 86, 398, 399, 400, 321, 322, 401, 323, 324, 98, |
| 2063 | 325, 326, 327, 117, 118, 29, 30, 31, 32, 33, |
| 2064 | 34, 35, 110, 36, 111, 498, 99, 372, 372, 372, |
| 2065 | 553, 317, 318, 319, 320, 372, 101, 149, 514, 120, |
| 2066 | 121, 122, 123, 124, 125, 372, 372, 102, 378, 261, |
| 2067 | 321, 322, 103, 323, 324, 86, 325, 326, 327, 239, |
| 2068 | 240, 241, 242, 145, 146, 379, 262, 110, 138, 111, |
| 2069 | 540, 112, 113, 408, 409, 410, 411, 412, 139, 162, |
| 2070 | 149, 396, 267, 110, 223, 111, 420, 421, 422, 372, |
| 2071 | 225, 372, 524, 226, 372, 527, 528, 529, 232, 235, |
| 2072 | 372, 372, 274, 275, 276, 277, 278, 279, 280, 281, |
| 2073 | 282, 283, 568, 416, 229, 570, 37, 38, 39, 114, |
| 2074 | -56, 115, -57, 428, -60, -59, -58, 243, 372, 372, |
| 2075 | 271, 372, 372, 265, 334, 341, 342, 372, 457, 458, |
| 2076 | 343, 344, 345, 353, 354, 464, 355, 372, 356, 357, |
| 2077 | 359, 267, 446, 267, 267, 267, 386, 387, 452, 431, |
| 2078 | -200, 388, 374, 375, 389, 376, 564, 390, 372, 456, |
| 2079 | 391, 394, 405, 434, 406, 407, 372, 435, -67, 1, |
| 2080 | 2, 444, 3, 4, 5, 578, 450, 451, 455, 460, |
| 2081 | 6, 7, 502, 503, 504, 505, 461, 462, 384, 507, |
| 2082 | 508, 463, 465, 469, 467, 468, 392, 393, 470, 471, |
| 2083 | 474, 8, 372, 476, 9, 475, 478, 372, 10, 497, |
| 2084 | 479, 480, 484, 481, 494, 506, 482, 486, 487, 489, |
| 2085 | 490, 532, 533, 509, 372, 372, 491, 495, 513, 372, |
| 2086 | 499, 500, 372, 515, 518, 526, 440, 544, 534, 536, |
| 2087 | 267, 537, 562, 267, 267, 267, 535, 538, 518, 539, |
| 2088 | 554, 545, 546, 510, 560, 574, 556, 584, 557, 558, |
| 2089 | 436, 437, 438, 555, 550, 571, 572, 569, 443, 360, |
| 2090 | 361, 573, 581, 63, 64, 362, 585, 586, 453, 454, |
| 2091 | 589, 590, 592, 215, 339, 1, 2, 216, 3, 4, |
| 2092 | 5, 363, 364, 365, 217, 129, 559, 340, 144, 542, |
| 2093 | 330, 141, 567, 44, 96, 128, 366, 367, 530, 338, |
| 2094 | 459, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2095 | 0, 510, 483, 368, 485, 0, 0, 488, 0, 0, |
| 2096 | 0, 0, 0, 492, 493, 0, 0, 0, 0, 176, |
| 2097 | 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, |
| 2098 | 187, 188, 189, 190, 247, 248, 0, 0, 0, 0, |
| 2099 | 0, 516, 517, 0, 520, 521, 0, 0, 0, 0, |
| 2100 | 525, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2101 | 531, 249, 197, 198, 199, 200, 201, 202, 203, 204, |
| 2102 | 205, 206, 207, 208, 0, 250, 0, 251, 252, 253, |
| 2103 | 0, 547, 0, 0, 0, 0, 360, 361, 0, 551, |
| 2104 | 63, 64, 362, 0, 110, 0, 111, 0, 0, 0, |
| 2105 | 0, 369, 1, 2, 0, 3, 4, 5, 363, 364, |
| 2106 | 365, 285, 286, 0, 0, 0, 0, 0, 0, 0, |
| 2107 | 0, 0, 0, 366, 367, 575, 0, 0, 0, 0, |
| 2108 | 579, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2109 | 368, 0, 0, 0, 0, 0, 0, 587, 588, 0, |
| 2110 | 0, 0, 591, 0, 0, 593, 176, 177, 178, 179, |
| 2111 | 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, |
| 2112 | 190, 247, 248, 0, 0, 0, 0, 0, 0, 0, |
| 2113 | 0, 287, 288, 289, 290, 291, 292, 293, 294, 295, |
| 2114 | 296, 297, 298, 299, 300, 0, 0, 0, 249, 197, |
| 2115 | 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, |
| 2116 | 208, 0, 250, 0, 251, 252, 253, 63, 64, 0, |
| 2117 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, |
| 2118 | 2, 0, 3, 4, 5, 244, 0, 0, 369, 0, |
| 2119 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2120 | 245, 246, 0, 0, 0, 0, 0, 0, 63, 64, |
| 2121 | 0, 106, 66, 67, 68, 69, 70, 71, 72, 0, |
| 2122 | 1, 2, 0, 3, 4, 5, 0, 0, 0, 0, |
| 2123 | 0, 0, 0, 176, 177, 178, 179, 180, 181, 182, |
| 2124 | 183, 184, 185, 186, 187, 188, 189, 190, 247, 248, |
| 2125 | 73, 0, 63, 64, 0, 106, 66, 67, 68, 69, |
| 2126 | 70, 71, 72, 0, 1, 2, 0, 3, 4, 5, |
| 2127 | 0, 0, 0, 0, 0, 249, 197, 198, 199, 200, |
| 2128 | 201, 202, 203, 204, 205, 206, 207, 208, 0, 250, |
| 2129 | 0, 251, 252, 253, 73, 0, 0, 0, 360, 361, |
| 2130 | 0, 0, 0, 0, 362, 0, 0, 0, 110, 0, |
| 2131 | 111, 0, 254, 0, 0, 255, 0, 256, 0, 257, |
| 2132 | 363, 364, 365, 0, 0, 0, 0, 0, 0, 0, |
| 2133 | 0, 0, 0, 0, 0, 366, 367, 0, 0, 0, |
| 2134 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2135 | 74, 0, 368, 75, 0, 0, 76, 0, 77, 107, |
| 2136 | 0, 0, 0, 0, 0, 0, 0, 0, 176, 177, |
| 2137 | 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, |
| 2138 | 188, 189, 190, 247, 248, 0, 0, 0, 0, 0, |
| 2139 | 0, 0, 0, 0, 74, 0, 0, 75, 0, 0, |
| 2140 | 76, 0, 77, 140, 0, 0, 0, 0, 0, 0, |
| 2141 | 249, 197, 198, 199, 200, 201, 202, 203, 204, 205, |
| 2142 | 206, 207, 208, 0, 250, 0, 251, 252, 253, 63, |
| 2143 | 64, 0, 106, 152, 153, 154, 155, 156, 157, 72, |
| 2144 | 0, 1, 2, 0, 3, 4, 5, 0, 63, 64, |
| 2145 | 369, 106, 152, 153, 154, 155, 156, 157, 72, 0, |
| 2146 | 1, 2, 0, 3, 4, 5, 0, 0, 0, 63, |
| 2147 | 64, 73, 106, 66, 67, 68, 69, 70, 71, 72, |
| 2148 | 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, |
| 2149 | 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2150 | 0, 133, 0, 0, 0, 0, 0, 0, 0, 63, |
| 2151 | 64, 73, 147, 66, 67, 68, 69, 70, 71, 72, |
| 2152 | 0, 1, 2, 0, 3, 4, 5, 63, 64, 0, |
| 2153 | 106, 66, 67, 68, 69, 70, 71, 72, 0, 1, |
| 2154 | 2, 0, 3, 4, 5, 0, 0, 0, 0, 0, |
| 2155 | 0, 73, 0, 0, 0, 0, 0, 0, 0, 329, |
| 2156 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, |
| 2157 | 0, 74, 0, 0, 75, 0, 0, 76, 0, 77, |
| 2158 | 351, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2159 | 74, 0, 0, 75, 0, 0, 76, 0, 77, 415, |
| 2160 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2161 | 0, 74, 0, 0, 75, 0, 0, 76, 0, 77, |
| 2162 | 0, 63, 64, 148, 106, 152, 153, 154, 155, 156, |
| 2163 | 157, 72, 0, 1, 2, 0, 3, 4, 5, 0, |
| 2164 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2165 | 0, 74, 0, 0, 75, 0, 0, 76, 0, 77, |
| 2166 | 0, 0, 0, 73, 0, 0, 0, 0, 0, 74, |
| 2167 | 0, 0, 75, 0, 0, 76, 0, 77, 63, 64, |
| 2168 | 0, 106, 66, 67, 68, 69, 70, 71, 72, 0, |
| 2169 | 1, 2, 0, 3, 4, 5, 63, 64, 0, 106, |
| 2170 | 66, 67, 68, 69, 70, 71, 72, 0, 1, 2, |
| 2171 | 427, 3, 4, 5, 0, 0, 0, 0, 0, 0, |
| 2172 | 73, 0, 0, 0, 0, 0, 0, 0, 512, 0, |
| 2173 | 0, 0, 0, 0, 0, 0, 63, 64, 73, 65, |
| 2174 | 66, 67, 68, 69, 70, 71, 72, 0, 1, 2, |
| 2175 | 0, 3, 4, 5, 0, 0, 0, 0, 0, 0, |
| 2176 | 0, 0, 0, 74, 0, 0, 75, 0, 346, 76, |
| 2177 | 0, 77, 0, 0, 0, 0, 63, 64, 73, 106, |
| 2178 | 152, 153, 154, 155, 156, 157, 72, 0, 1, 2, |
| 2179 | 0, 3, 4, 5, 63, 64, 0, 147, 66, 67, |
| 2180 | 68, 69, 70, 71, 72, 0, 1, 2, 0, 3, |
| 2181 | 4, 5, 0, 0, 0, 0, 0, 0, 73, 0, |
| 2182 | 74, 0, 0, 75, 0, 0, 76, 0, 77, 0, |
| 2183 | 0, 0, 0, 0, 0, 0, 73, 0, 74, 0, |
| 2184 | 0, 75, 0, 0, 76, 0, 77, 63, 64, 0, |
| 2185 | 106, 66, 67, 68, 69, 70, 71, 72, 0, 1, |
| 2186 | 2, 0, 3, 4, 5, 0, 0, 0, 0, 0, |
| 2187 | 0, 0, 0, 0, 0, 0, 0, 0, 74, 0, |
| 2188 | 0, 75, 0, 0, 76, 0, 77, 63, 64, 73, |
| 2189 | 266, 66, 67, 68, 69, 70, 71, 72, 0, 1, |
| 2190 | 2, 0, 3, 4, 5, 0, 0, 0, 0, 0, |
| 2191 | 0, 0, 0, 0, 0, 0, 0, 0, 74, 0, |
| 2192 | 0, 75, 0, 0, 76, 0, 77, 0, 0, 73, |
| 2193 | 0, 0, 0, 0, 0, 0, 74, 0, 0, 75, |
| 2194 | 0, 0, 76, 0, 77, 63, 64, 0, 106, 152, |
| 2195 | 153, 154, 155, 156, 157, 72, 0, 1, 2, 0, |
| 2196 | 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, |
| 2197 | 0, 167, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2198 | 0, 0, 0, 0, 0, 0, 0, 73, 0, 74, |
| 2199 | 168, 169, 75, 0, 0, 76, 0, 77, 0, 0, |
| 2200 | 0, 0, 170, 171, 172, 173, 174, 175, 176, 177, |
| 2201 | 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, |
| 2202 | 188, 189, 190, 191, 192, 0, 0, 0, 0, 74, |
| 2203 | 0, 0, 75, 0, 0, 76, 0, 77, 0, 0, |
| 2204 | 0, 0, 0, 0, 0, 193, 194, 195, 0, 0, |
| 2205 | 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, |
| 2206 | 206, 207, 208, 209, 210, 211, 212, 213, 214, 0, |
| 2207 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2208 | 0, 0, 0, 0, 0, 0, 0, 74, 0, 0, |
| 2209 | 75, 0, 0, 76, 0, 349 |
| 2210 | }; |
| 2211 | |
| 2212 | static const short yycheck[] = |
| 2213 | { |
| 2214 | 0, 27, 172, 160, 428, 232, 126, 4, 0, 11, |
| 2215 | 150, 195, 303, 11, 21, 34, 28, 17, 336, 337, |
| 2216 | 160, 173, 29, 255, 256, 17, 210, 211, 212, 213, |
| 2217 | 214, 11, 11, 217, 53, 52, 564, 147, 34, 146, |
| 2218 | 0, 147, 3, 4, 5, 6, 147, 147, 158, 66, |
| 2219 | 578, 77, 158, 143, 144, 145, 156, 158, 18, 19, |
| 2220 | 20, 119, 22, 23, 24, 26, 27, 219, 147, 57, |
| 2221 | 30, 31, 147, 53, 53, 101, 148, 156, 150, 105, |
| 2222 | 38, 147, 146, 158, 156, 111, 147, 145, 154, 513, |
| 2223 | 116, 51, 92, 154, 54, 148, 18, 150, 58, 19, |
| 2224 | 126, 154, 22, 147, 24, 11, 146, 151, 426, 7, |
| 2225 | 8, 17, 138, 139, 147, 147, 142, 349, 151, 151, |
| 2226 | 146, 19, 20, 547, 22, 23, 24, 267, 19, 269, |
| 2227 | 270, 22, 272, 24, 318, 40, 41, 369, 134, 135, |
| 2228 | 136, 146, 47, 139, 170, 157, 147, 148, 53, 150, |
| 2229 | 0, 158, 154, 273, 22, 579, 154, 42, 43, 44, |
| 2230 | 157, 20, 47, 454, 23, 305, 152, 193, 194, 195, |
| 2231 | 196, 163, 146, 313, 314, 21, 134, 135, 136, 147, |
| 2232 | 148, 139, 150, 209, 210, 211, 212, 213, 214, 215, |
| 2233 | 216, 217, 483, 46, 485, 48, 316, 117, 118, 225, |
| 2234 | 148, 22, 150, 387, 152, 389, 390, 391, 35, 235, |
| 2235 | 37, 134, 135, 136, 134, 135, 139, 137, 138, 22, |
| 2236 | 140, 141, 142, 32, 33, 42, 43, 44, 45, 46, |
| 2237 | 47, 48, 148, 50, 150, 151, 22, 377, 378, 379, |
| 2238 | 531, 113, 114, 117, 118, 385, 150, 273, 475, 60, |
| 2239 | 61, 62, 63, 64, 65, 395, 396, 4, 284, 416, |
| 2240 | 134, 135, 4, 137, 138, 37, 140, 141, 142, 3, |
| 2241 | 4, 5, 6, 112, 113, 301, 416, 148, 153, 150, |
| 2242 | 151, 83, 84, 341, 342, 343, 344, 345, 153, 4, |
| 2243 | 316, 317, 318, 148, 22, 150, 354, 355, 356, 439, |
| 2244 | 147, 441, 486, 151, 444, 489, 490, 491, 151, 150, |
| 2245 | 450, 451, 90, 91, 92, 93, 94, 95, 96, 97, |
| 2246 | 98, 99, 549, 349, 156, 552, 143, 144, 145, 42, |
| 2247 | 9, 44, 9, 359, 9, 9, 9, 9, 478, 479, |
| 2248 | 11, 481, 482, 55, 156, 150, 150, 487, 406, 407, |
| 2249 | 150, 150, 150, 22, 150, 413, 150, 497, 150, 147, |
| 2250 | 150, 387, 388, 389, 390, 391, 147, 147, 394, 59, |
| 2251 | 0, 147, 269, 270, 147, 272, 546, 147, 518, 405, |
| 2252 | 147, 38, 38, 147, 150, 150, 526, 147, 18, 19, |
| 2253 | 20, 152, 22, 23, 24, 565, 147, 147, 147, 147, |
| 2254 | 30, 31, 460, 461, 462, 463, 147, 147, 305, 467, |
| 2255 | 468, 147, 156, 38, 147, 147, 313, 314, 22, 4, |
| 2256 | 147, 51, 562, 22, 54, 151, 17, 567, 58, 455, |
| 2257 | 17, 150, 4, 147, 150, 156, 147, 147, 147, 147, |
| 2258 | 147, 499, 500, 469, 584, 585, 147, 147, 474, 589, |
| 2259 | 147, 147, 592, 147, 480, 147, 53, 22, 147, 147, |
| 2260 | 486, 147, 17, 489, 490, 491, 151, 151, 494, 151, |
| 2261 | 151, 147, 152, 473, 53, 4, 534, 17, 536, 537, |
| 2262 | 377, 378, 379, 151, 154, 151, 151, 154, 385, 3, |
| 2263 | 4, 151, 147, 7, 8, 9, 17, 147, 395, 396, |
| 2264 | 17, 71, 17, 129, 247, 19, 20, 129, 22, 23, |
| 2265 | 24, 25, 26, 27, 129, 92, 541, 248, 111, 514, |
| 2266 | 225, 105, 548, 17, 56, 89, 40, 41, 494, 235, |
| 2267 | 408, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2268 | -1, 541, 439, 57, 441, -1, -1, 444, -1, -1, |
| 2269 | -1, -1, -1, 450, 451, -1, -1, -1, -1, 73, |
| 2270 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 2271 | 84, 85, 86, 87, 88, 89, -1, -1, -1, -1, |
| 2272 | -1, 478, 479, -1, 481, 482, -1, -1, -1, -1, |
| 2273 | 487, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2274 | 497, 115, 116, 117, 118, 119, 120, 121, 122, 123, |
| 2275 | 124, 125, 126, 127, -1, 129, -1, 131, 132, 133, |
| 2276 | -1, 518, -1, -1, -1, -1, 3, 4, -1, 526, |
| 2277 | 7, 8, 9, -1, 148, -1, 150, -1, -1, -1, |
| 2278 | -1, 155, 19, 20, -1, 22, 23, 24, 25, 26, |
| 2279 | 27, 26, 27, -1, -1, -1, -1, -1, -1, -1, |
| 2280 | -1, -1, -1, 40, 41, 562, -1, -1, -1, -1, |
| 2281 | 567, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2282 | 57, -1, -1, -1, -1, -1, -1, 584, 585, -1, |
| 2283 | -1, -1, 589, -1, -1, 592, 73, 74, 75, 76, |
| 2284 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 2285 | 87, 88, 89, -1, -1, -1, -1, -1, -1, -1, |
| 2286 | -1, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2287 | 105, 106, 107, 108, 109, -1, -1, -1, 115, 116, |
| 2288 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 2289 | 127, -1, 129, -1, 131, 132, 133, 7, 8, -1, |
| 2290 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, |
| 2291 | 20, -1, 22, 23, 24, 25, -1, -1, 155, -1, |
| 2292 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2293 | 40, 41, -1, -1, -1, -1, -1, -1, 7, 8, |
| 2294 | -1, 10, 11, 12, 13, 14, 15, 16, 17, -1, |
| 2295 | 19, 20, -1, 22, 23, 24, -1, -1, -1, -1, |
| 2296 | -1, -1, -1, 73, 74, 75, 76, 77, 78, 79, |
| 2297 | 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, |
| 2298 | 49, -1, 7, 8, -1, 10, 11, 12, 13, 14, |
| 2299 | 15, 16, 17, -1, 19, 20, -1, 22, 23, 24, |
| 2300 | -1, -1, -1, -1, -1, 115, 116, 117, 118, 119, |
| 2301 | 120, 121, 122, 123, 124, 125, 126, 127, -1, 129, |
| 2302 | -1, 131, 132, 133, 49, -1, -1, -1, 3, 4, |
| 2303 | -1, -1, -1, -1, 9, -1, -1, -1, 148, -1, |
| 2304 | 150, -1, 152, -1, -1, 155, -1, 157, -1, 159, |
| 2305 | 25, 26, 27, -1, -1, -1, -1, -1, -1, -1, |
| 2306 | -1, -1, -1, -1, -1, 40, 41, -1, -1, -1, |
| 2307 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2308 | 149, -1, 57, 152, -1, -1, 155, -1, 157, 158, |
| 2309 | -1, -1, -1, -1, -1, -1, -1, -1, 73, 74, |
| 2310 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2311 | 85, 86, 87, 88, 89, -1, -1, -1, -1, -1, |
| 2312 | -1, -1, -1, -1, 149, -1, -1, 152, -1, -1, |
| 2313 | 155, -1, 157, 158, -1, -1, -1, -1, -1, -1, |
| 2314 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2315 | 125, 126, 127, -1, 129, -1, 131, 132, 133, 7, |
| 2316 | 8, -1, 10, 11, 12, 13, 14, 15, 16, 17, |
| 2317 | -1, 19, 20, -1, 22, 23, 24, -1, 7, 8, |
| 2318 | 155, 10, 11, 12, 13, 14, 15, 16, 17, -1, |
| 2319 | 19, 20, -1, 22, 23, 24, -1, -1, -1, 7, |
| 2320 | 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, |
| 2321 | -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, |
| 2322 | 49, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2323 | -1, 39, -1, -1, -1, -1, -1, -1, -1, 7, |
| 2324 | 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, |
| 2325 | -1, 19, 20, -1, 22, 23, 24, 7, 8, -1, |
| 2326 | 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, |
| 2327 | 20, -1, 22, 23, 24, -1, -1, -1, -1, -1, |
| 2328 | -1, 49, -1, -1, -1, -1, -1, -1, -1, 39, |
| 2329 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 49, |
| 2330 | -1, 149, -1, -1, 152, -1, -1, 155, -1, 157, |
| 2331 | 158, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2332 | 149, -1, -1, 152, -1, -1, 155, -1, 157, 158, |
| 2333 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2334 | -1, 149, -1, -1, 152, -1, -1, 155, -1, 157, |
| 2335 | -1, 7, 8, 121, 10, 11, 12, 13, 14, 15, |
| 2336 | 16, 17, -1, 19, 20, -1, 22, 23, 24, -1, |
| 2337 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2338 | -1, 149, -1, -1, 152, -1, -1, 155, -1, 157, |
| 2339 | -1, -1, -1, 49, -1, -1, -1, -1, -1, 149, |
| 2340 | -1, -1, 152, -1, -1, 155, -1, 157, 7, 8, |
| 2341 | -1, 10, 11, 12, 13, 14, 15, 16, 17, -1, |
| 2342 | 19, 20, -1, 22, 23, 24, 7, 8, -1, 10, |
| 2343 | 11, 12, 13, 14, 15, 16, 17, -1, 19, 20, |
| 2344 | 39, 22, 23, 24, -1, -1, -1, -1, -1, -1, |
| 2345 | 49, -1, -1, -1, -1, -1, -1, -1, 39, -1, |
| 2346 | -1, -1, -1, -1, -1, -1, 7, 8, 49, 10, |
| 2347 | 11, 12, 13, 14, 15, 16, 17, -1, 19, 20, |
| 2348 | -1, 22, 23, 24, -1, -1, -1, -1, -1, -1, |
| 2349 | -1, -1, -1, 149, -1, -1, 152, -1, 154, 155, |
| 2350 | -1, 157, -1, -1, -1, -1, 7, 8, 49, 10, |
| 2351 | 11, 12, 13, 14, 15, 16, 17, -1, 19, 20, |
| 2352 | -1, 22, 23, 24, 7, 8, -1, 10, 11, 12, |
| 2353 | 13, 14, 15, 16, 17, -1, 19, 20, -1, 22, |
| 2354 | 23, 24, -1, -1, -1, -1, -1, -1, 49, -1, |
| 2355 | 149, -1, -1, 152, -1, -1, 155, -1, 157, -1, |
| 2356 | -1, -1, -1, -1, -1, -1, 49, -1, 149, -1, |
| 2357 | -1, 152, -1, -1, 155, -1, 157, 7, 8, -1, |
| 2358 | 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, |
| 2359 | 20, -1, 22, 23, 24, -1, -1, -1, -1, -1, |
| 2360 | -1, -1, -1, -1, -1, -1, -1, -1, 149, -1, |
| 2361 | -1, 152, -1, -1, 155, -1, 157, 7, 8, 49, |
| 2362 | 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, |
| 2363 | 20, -1, 22, 23, 24, -1, -1, -1, -1, -1, |
| 2364 | -1, -1, -1, -1, -1, -1, -1, -1, 149, -1, |
| 2365 | -1, 152, -1, -1, 155, -1, 157, -1, -1, 49, |
| 2366 | -1, -1, -1, -1, -1, -1, 149, -1, -1, 152, |
| 2367 | -1, -1, 155, -1, 157, 7, 8, -1, 10, 11, |
| 2368 | 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, |
| 2369 | 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, |
| 2370 | -1, 36, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2371 | -1, -1, -1, -1, -1, -1, -1, 49, -1, 149, |
| 2372 | 55, 56, 152, -1, -1, 155, -1, 157, -1, -1, |
| 2373 | -1, -1, 67, 68, 69, 70, 71, 72, 73, 74, |
| 2374 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2375 | 85, 86, 87, 88, 89, -1, -1, -1, -1, 149, |
| 2376 | -1, -1, 152, -1, -1, 155, -1, 157, -1, -1, |
| 2377 | -1, -1, -1, -1, -1, 110, 111, 112, -1, -1, |
| 2378 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2379 | 125, 126, 127, 128, 129, 130, 131, 132, 133, -1, |
| 2380 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2381 | -1, -1, -1, -1, -1, -1, -1, 149, -1, -1, |
| 2382 | 152, -1, -1, 155, -1, 157 |
| 2383 | }; |
| 2384 | |
| 2385 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2386 | symbol of state STATE-NUM. */ |
| 2387 | static const unsigned char yystos[] = |
| 2388 | { |
| 2389 | 0, 19, 20, 22, 23, 24, 30, 31, 51, 54, |
| 2390 | 58, 168, 170, 171, 172, 173, 204, 205, 206, 208, |
| 2391 | 207, 52, 66, 213, 146, 57, 146, 18, 146, 42, |
| 2392 | 43, 44, 45, 46, 47, 48, 50, 143, 144, 145, |
| 2393 | 174, 175, 176, 0, 206, 46, 48, 177, 223, 42, |
| 2394 | 43, 44, 47, 178, 220, 222, 229, 146, 146, 152, |
| 2395 | 214, 22, 212, 7, 8, 10, 11, 12, 13, 14, |
| 2396 | 15, 16, 17, 49, 149, 152, 155, 157, 168, 171, |
| 2397 | 191, 192, 226, 176, 176, 35, 37, 202, 176, 176, |
| 2398 | 21, 230, 231, 29, 158, 221, 230, 22, 22, 22, |
| 2399 | 215, 150, 4, 4, 4, 157, 10, 158, 192, 197, |
| 2400 | 148, 150, 202, 202, 42, 44, 179, 32, 33, 201, |
| 2401 | 60, 61, 62, 63, 64, 65, 180, 218, 218, 170, |
| 2402 | 234, 147, 154, 39, 192, 193, 195, 196, 153, 153, |
| 2403 | 158, 197, 147, 158, 196, 201, 201, 10, 121, 192, |
| 2404 | 194, 203, 11, 12, 13, 14, 15, 16, 166, 167, |
| 2405 | 192, 198, 4, 194, 28, 157, 219, 36, 55, 56, |
| 2406 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 2407 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 2408 | 87, 88, 89, 110, 111, 112, 115, 116, 117, 118, |
| 2409 | 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, |
| 2410 | 129, 130, 131, 132, 133, 161, 162, 163, 232, 238, |
| 2411 | 239, 240, 241, 22, 182, 147, 151, 192, 192, 156, |
| 2412 | 158, 192, 151, 198, 192, 150, 226, 26, 27, 3, |
| 2413 | 4, 5, 6, 9, 25, 40, 41, 88, 89, 115, |
| 2414 | 129, 131, 132, 133, 152, 155, 157, 159, 161, 162, |
| 2415 | 163, 199, 226, 209, 171, 55, 10, 192, 228, 11, |
| 2416 | 17, 11, 166, 180, 90, 91, 92, 93, 94, 95, |
| 2417 | 96, 97, 98, 99, 164, 26, 27, 96, 97, 98, |
| 2418 | 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, |
| 2419 | 109, 165, 192, 192, 228, 192, 192, 235, 228, 228, |
| 2420 | 228, 228, 228, 192, 192, 228, 180, 113, 114, 117, |
| 2421 | 118, 134, 135, 137, 138, 140, 141, 142, 181, 39, |
| 2422 | 193, 184, 154, 156, 156, 184, 210, 211, 203, 164, |
| 2423 | 165, 150, 150, 150, 150, 150, 154, 198, 200, 157, |
| 2424 | 200, 158, 200, 22, 150, 150, 150, 147, 189, 150, |
| 2425 | 3, 4, 9, 25, 26, 27, 40, 41, 57, 155, |
| 2426 | 199, 225, 226, 227, 227, 227, 227, 194, 192, 192, |
| 2427 | 147, 186, 147, 186, 227, 152, 147, 147, 147, 147, |
| 2428 | 147, 147, 227, 227, 38, 194, 192, 228, 134, 135, |
| 2429 | 136, 139, 183, 189, 189, 38, 150, 150, 198, 198, |
| 2430 | 198, 198, 198, 147, 154, 158, 192, 200, 156, 158, |
| 2431 | 198, 198, 198, 34, 53, 187, 190, 39, 192, 216, |
| 2432 | 217, 59, 224, 200, 147, 147, 227, 227, 227, 11, |
| 2433 | 53, 11, 237, 227, 152, 228, 192, 228, 228, 228, |
| 2434 | 147, 147, 192, 227, 227, 147, 192, 198, 198, 237, |
| 2435 | 147, 147, 147, 147, 198, 156, 158, 147, 147, 38, |
| 2436 | 22, 4, 189, 182, 147, 151, 22, 156, 17, 17, |
| 2437 | 150, 147, 147, 227, 4, 227, 147, 147, 227, 147, |
| 2438 | 147, 147, 227, 227, 150, 147, 186, 192, 151, 147, |
| 2439 | 147, 151, 198, 198, 198, 198, 156, 198, 198, 192, |
| 2440 | 168, 169, 39, 192, 184, 147, 227, 227, 192, 236, |
| 2441 | 227, 227, 186, 186, 228, 227, 147, 228, 228, 228, |
| 2442 | 236, 227, 198, 198, 147, 151, 147, 147, 151, 151, |
| 2443 | 151, 182, 187, 188, 22, 147, 152, 227, 147, 151, |
| 2444 | 154, 227, 151, 186, 151, 151, 198, 198, 198, 169, |
| 2445 | 53, 185, 17, 154, 166, 233, 182, 192, 184, 154, |
| 2446 | 184, 151, 151, 151, 4, 227, 225, 154, 166, 227, |
| 2447 | 38, 147, 225, 182, 17, 17, 147, 227, 227, 17, |
| 2448 | 71, 227, 17, 227 |
| 2449 | }; |
| 2450 | |
| 2451 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 2452 | # define YYSIZE_T __SIZE_TYPE__ |
| 2453 | #endif |
| 2454 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 2455 | # define YYSIZE_T size_t |
| 2456 | #endif |
| 2457 | #if ! defined (YYSIZE_T) |
| 2458 | # if defined (__STDC__) || defined (__cplusplus) |
| 2459 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 2460 | # define YYSIZE_T size_t |
| 2461 | # endif |
| 2462 | #endif |
| 2463 | #if ! defined (YYSIZE_T) |
| 2464 | # define YYSIZE_T unsigned int |
| 2465 | #endif |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 2466 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2467 | #define yyerrok (yyerrstatus = 0) |
| 2468 | #define yyclearin (yychar = YYEMPTY) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2469 | #define YYEMPTY (-2) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2470 | #define YYEOF 0 |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2471 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2472 | #define YYACCEPT goto yyacceptlab |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2473 | #define YYABORT goto yyabortlab |
| 2474 | #define YYERROR goto yyerrorlab |
| 2475 | |
| 2476 | |
| 2477 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2478 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2479 | Once GCC version 2 has supplanted version 1, this can go. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2480 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2481 | #define YYFAIL goto yyerrlab |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2482 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2483 | #define YYRECOVERING() (!!yyerrstatus) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2484 | |
| 2485 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2486 | do \ |
| 2487 | if (yychar == YYEMPTY && yylen == 1) \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2488 | { \ |
| 2489 | yychar = (Token); \ |
| 2490 | yylval = (Value); \ |
| 2491 | yytoken = YYTRANSLATE (yychar); \ |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2492 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2493 | goto yybackup; \ |
| 2494 | } \ |
| 2495 | else \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2496 | { \ |
| 2497 | yyerror ("syntax error: cannot back up");\ |
| 2498 | YYERROR; \ |
| 2499 | } \ |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2500 | while (0) |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2501 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2502 | #define YYTERROR 1 |
| 2503 | #define YYERRCODE 256 |
| 2504 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2505 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions |
| 2506 | are run). */ |
| 2507 | |
| 2508 | #ifndef YYLLOC_DEFAULT |
| 2509 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2510 | ((Current).first_line = (Rhs)[1].first_line, \ |
| 2511 | (Current).first_column = (Rhs)[1].first_column, \ |
| 2512 | (Current).last_line = (Rhs)[N].last_line, \ |
| 2513 | (Current).last_column = (Rhs)[N].last_column) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2514 | #endif |
| 2515 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2516 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2517 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2518 | #ifdef YYLEX_PARAM |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2519 | # define YYLEX yylex (YYLEX_PARAM) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2520 | #else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2521 | # define YYLEX yylex () |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2522 | #endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2523 | |
| 2524 | /* Enable debugging if requested. */ |
| 2525 | #if YYDEBUG |
| 2526 | |
| 2527 | # ifndef YYFPRINTF |
| 2528 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2529 | # define YYFPRINTF fprintf |
| 2530 | # endif |
| 2531 | |
| 2532 | # define YYDPRINTF(Args) \ |
| 2533 | do { \ |
| 2534 | if (yydebug) \ |
| 2535 | YYFPRINTF Args; \ |
| 2536 | } while (0) |
| 2537 | |
| 2538 | # define YYDSYMPRINT(Args) \ |
| 2539 | do { \ |
| 2540 | if (yydebug) \ |
| 2541 | yysymprint Args; \ |
| 2542 | } while (0) |
| 2543 | |
| 2544 | # define YYDSYMPRINTF(Title, Token, Value, Location) \ |
| 2545 | do { \ |
| 2546 | if (yydebug) \ |
| 2547 | { \ |
| 2548 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2549 | yysymprint (stderr, \ |
| 2550 | Token, Value); \ |
| 2551 | YYFPRINTF (stderr, "\n"); \ |
| 2552 | } \ |
| 2553 | } while (0) |
| 2554 | |
| 2555 | /*------------------------------------------------------------------. |
| 2556 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2557 | | TOP (included). | |
| 2558 | `------------------------------------------------------------------*/ |
| 2559 | |
| 2560 | #if defined (__STDC__) || defined (__cplusplus) |
| 2561 | static void |
| 2562 | yy_stack_print (short *bottom, short *top) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2563 | #else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2564 | static void |
| 2565 | yy_stack_print (bottom, top) |
| 2566 | short *bottom; |
| 2567 | short *top; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2568 | #endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2569 | { |
| 2570 | YYFPRINTF (stderr, "Stack now"); |
| 2571 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 2572 | YYFPRINTF (stderr, " %d", *bottom); |
| 2573 | YYFPRINTF (stderr, "\n"); |
| 2574 | } |
| 2575 | |
| 2576 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2577 | do { \ |
| 2578 | if (yydebug) \ |
| 2579 | yy_stack_print ((Bottom), (Top)); \ |
| 2580 | } while (0) |
| 2581 | |
| 2582 | |
| 2583 | /*------------------------------------------------. |
| 2584 | | Report that the YYRULE is going to be reduced. | |
| 2585 | `------------------------------------------------*/ |
| 2586 | |
| 2587 | #if defined (__STDC__) || defined (__cplusplus) |
| 2588 | static void |
| 2589 | yy_reduce_print (int yyrule) |
| 2590 | #else |
| 2591 | static void |
| 2592 | yy_reduce_print (yyrule) |
| 2593 | int yyrule; |
Dale Johannesen | 320fc8a | 2007-08-03 01:03:46 +0000 | [diff] [blame] | 2594 | #endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2595 | { |
| 2596 | int yyi; |
| 2597 | unsigned int yylno = yyrline[yyrule]; |
| 2598 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", |
| 2599 | yyrule - 1, yylno); |
| 2600 | /* Print the symbols being reduced, and their result. */ |
| 2601 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 2602 | YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); |
| 2603 | YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); |
| 2604 | } |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2605 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2606 | # define YY_REDUCE_PRINT(Rule) \ |
| 2607 | do { \ |
| 2608 | if (yydebug) \ |
| 2609 | yy_reduce_print (Rule); \ |
| 2610 | } while (0) |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2611 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2612 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2613 | multiple parsers can coexist. */ |
| 2614 | int yydebug; |
| 2615 | #else /* !YYDEBUG */ |
| 2616 | # define YYDPRINTF(Args) |
| 2617 | # define YYDSYMPRINT(Args) |
| 2618 | # define YYDSYMPRINTF(Title, Token, Value, Location) |
| 2619 | # define YY_STACK_PRINT(Bottom, Top) |
| 2620 | # define YY_REDUCE_PRINT(Rule) |
| 2621 | #endif /* !YYDEBUG */ |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2622 | |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2623 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2624 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2625 | #ifndef YYINITDEPTH |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2626 | # define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2627 | #endif |
| 2628 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2629 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2630 | if the built-in stack extension method is used). |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2631 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2632 | Do not make this value too large; the results are undefined if |
| 2633 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) |
| 2634 | evaluated with infinite-precision integer arithmetic. */ |
| 2635 | |
| 2636 | #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 |
| 2637 | # undef YYMAXDEPTH |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2638 | #endif |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 2639 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2640 | #ifndef YYMAXDEPTH |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2641 | # define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2642 | #endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2643 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2644 | |
| 2645 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2646 | #if YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2647 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2648 | # ifndef yystrlen |
| 2649 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 2650 | # define yystrlen strlen |
| 2651 | # else |
| 2652 | /* Return the length of YYSTR. */ |
| 2653 | static YYSIZE_T |
| 2654 | # if defined (__STDC__) || defined (__cplusplus) |
| 2655 | yystrlen (const char *yystr) |
| 2656 | # else |
| 2657 | yystrlen (yystr) |
| 2658 | const char *yystr; |
| 2659 | # endif |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2660 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2661 | register const char *yys = yystr; |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2662 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2663 | while (*yys++ != '\0') |
| 2664 | continue; |
| 2665 | |
| 2666 | return yys - yystr - 1; |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2667 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2668 | # endif |
| 2669 | # endif |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2670 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2671 | # ifndef yystpcpy |
| 2672 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 2673 | # define yystpcpy stpcpy |
| 2674 | # else |
| 2675 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2676 | YYDEST. */ |
| 2677 | static char * |
| 2678 | # if defined (__STDC__) || defined (__cplusplus) |
| 2679 | yystpcpy (char *yydest, const char *yysrc) |
| 2680 | # else |
| 2681 | yystpcpy (yydest, yysrc) |
| 2682 | char *yydest; |
| 2683 | const char *yysrc; |
| 2684 | # endif |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2685 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2686 | register char *yyd = yydest; |
| 2687 | register const char *yys = yysrc; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2688 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2689 | while ((*yyd++ = *yys++) != '\0') |
| 2690 | continue; |
| 2691 | |
| 2692 | return yyd - 1; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2693 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2694 | # endif |
| 2695 | # endif |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2696 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2697 | #endif /* !YYERROR_VERBOSE */ |
| 2698 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2699 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2700 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2701 | #if YYDEBUG |
| 2702 | /*--------------------------------. |
| 2703 | | Print this symbol on YYOUTPUT. | |
| 2704 | `--------------------------------*/ |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2705 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2706 | #if defined (__STDC__) || defined (__cplusplus) |
| 2707 | static void |
| 2708 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2709 | #else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2710 | static void |
| 2711 | yysymprint (yyoutput, yytype, yyvaluep) |
| 2712 | FILE *yyoutput; |
| 2713 | int yytype; |
| 2714 | YYSTYPE *yyvaluep; |
Dale Johannesen | 320fc8a | 2007-08-03 01:03:46 +0000 | [diff] [blame] | 2715 | #endif |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2716 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2717 | /* Pacify ``unused variable'' warnings. */ |
| 2718 | (void) yyvaluep; |
| 2719 | |
| 2720 | if (yytype < YYNTOKENS) |
| 2721 | { |
| 2722 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2723 | # ifdef YYPRINT |
| 2724 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2725 | # endif |
| 2726 | } |
| 2727 | else |
| 2728 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 2729 | |
| 2730 | switch (yytype) |
| 2731 | { |
| 2732 | default: |
| 2733 | break; |
| 2734 | } |
| 2735 | YYFPRINTF (yyoutput, ")"); |
| 2736 | } |
| 2737 | |
| 2738 | #endif /* ! YYDEBUG */ |
| 2739 | /*-----------------------------------------------. |
| 2740 | | Release the memory associated to this symbol. | |
| 2741 | `-----------------------------------------------*/ |
| 2742 | |
| 2743 | #if defined (__STDC__) || defined (__cplusplus) |
| 2744 | static void |
| 2745 | yydestruct (int yytype, YYSTYPE *yyvaluep) |
| 2746 | #else |
| 2747 | static void |
| 2748 | yydestruct (yytype, yyvaluep) |
| 2749 | int yytype; |
| 2750 | YYSTYPE *yyvaluep; |
| 2751 | #endif |
| 2752 | { |
| 2753 | /* Pacify ``unused variable'' warnings. */ |
| 2754 | (void) yyvaluep; |
| 2755 | |
| 2756 | switch (yytype) |
| 2757 | { |
| 2758 | |
| 2759 | default: |
| 2760 | break; |
| 2761 | } |
| 2762 | } |
| 2763 | |
| 2764 | |
| 2765 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 2766 | |
| 2767 | #ifdef YYPARSE_PARAM |
| 2768 | # if defined (__STDC__) || defined (__cplusplus) |
| 2769 | int yyparse (void *YYPARSE_PARAM); |
| 2770 | # else |
| 2771 | int yyparse (); |
| 2772 | # endif |
| 2773 | #else /* ! YYPARSE_PARAM */ |
| 2774 | #if defined (__STDC__) || defined (__cplusplus) |
| 2775 | int yyparse (void); |
| 2776 | #else |
| 2777 | int yyparse (); |
| 2778 | #endif |
| 2779 | #endif /* ! YYPARSE_PARAM */ |
| 2780 | |
| 2781 | |
| 2782 | |
| 2783 | /* The lookahead symbol. */ |
| 2784 | int yychar; |
| 2785 | |
| 2786 | /* The semantic value of the lookahead symbol. */ |
| 2787 | YYSTYPE yylval; |
| 2788 | |
| 2789 | /* Number of syntax errors so far. */ |
| 2790 | int yynerrs; |
| 2791 | |
| 2792 | |
| 2793 | |
| 2794 | /*----------. |
| 2795 | | yyparse. | |
| 2796 | `----------*/ |
| 2797 | |
| 2798 | #ifdef YYPARSE_PARAM |
| 2799 | # if defined (__STDC__) || defined (__cplusplus) |
| 2800 | int yyparse (void *YYPARSE_PARAM) |
| 2801 | # else |
| 2802 | int yyparse (YYPARSE_PARAM) |
| 2803 | void *YYPARSE_PARAM; |
| 2804 | # endif |
| 2805 | #else /* ! YYPARSE_PARAM */ |
| 2806 | #if defined (__STDC__) || defined (__cplusplus) |
| 2807 | int |
| 2808 | yyparse (void) |
| 2809 | #else |
| 2810 | int |
| 2811 | yyparse () |
| 2812 | |
| 2813 | #endif |
| 2814 | #endif |
| 2815 | { |
| 2816 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2817 | register int yystate; |
| 2818 | register int yyn; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2819 | int yyresult; |
| 2820 | /* Number of tokens to shift before error messages enabled. */ |
| 2821 | int yyerrstatus; |
| 2822 | /* Lookahead token as an internal (translated) token number. */ |
| 2823 | int yytoken = 0; |
| 2824 | |
| 2825 | /* Three stacks and their tools: |
| 2826 | `yyss': related to states, |
| 2827 | `yyvs': related to semantic values, |
| 2828 | `yyls': related to locations. |
| 2829 | |
| 2830 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 2831 | to reallocate them elsewhere. */ |
| 2832 | |
| 2833 | /* The state stack. */ |
| 2834 | short yyssa[YYINITDEPTH]; |
| 2835 | short *yyss = yyssa; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2836 | register short *yyssp; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2837 | |
| 2838 | /* The semantic value stack. */ |
| 2839 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 2840 | YYSTYPE *yyvs = yyvsa; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2841 | register YYSTYPE *yyvsp; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2842 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2843 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2844 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2845 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2846 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2847 | YYSIZE_T yystacksize = YYINITDEPTH; |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2848 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2849 | /* The variables used to return semantic value and location from the |
| 2850 | action routines. */ |
| 2851 | YYSTYPE yyval; |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2852 | |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2853 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2854 | /* When reducing, the number of symbols on the RHS of the reduced |
| 2855 | rule. */ |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2856 | int yylen; |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2857 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2858 | YYDPRINTF ((stderr, "Starting parse\n")); |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2859 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2860 | yystate = 0; |
| 2861 | yyerrstatus = 0; |
| 2862 | yynerrs = 0; |
| 2863 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2864 | |
| 2865 | /* Initialize stack pointers. |
| 2866 | Waste one element of value and location stack |
| 2867 | so that they stay on the same level as the state stack. |
| 2868 | The wasted elements are never initialized. */ |
| 2869 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2870 | yyssp = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2871 | yyvsp = yyvs; |
| 2872 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2873 | goto yysetstate; |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2874 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2875 | /*------------------------------------------------------------. |
| 2876 | | yynewstate -- Push a new state, which is found in yystate. | |
| 2877 | `------------------------------------------------------------*/ |
| 2878 | yynewstate: |
| 2879 | /* In all cases, when you get here, the value and location stacks |
| 2880 | have just been pushed. so pushing a state here evens the stacks. |
| 2881 | */ |
| 2882 | yyssp++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2883 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2884 | yysetstate: |
| 2885 | *yyssp = yystate; |
| 2886 | |
| 2887 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2888 | { |
| 2889 | /* Get the current used size of the three stacks, in elements. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2890 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2891 | |
| 2892 | #ifdef yyoverflow |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2893 | { |
| 2894 | /* Give user a chance to reallocate the stack. Use copies of |
| 2895 | these so that the &'s don't force the real ones into |
| 2896 | memory. */ |
| 2897 | YYSTYPE *yyvs1 = yyvs; |
| 2898 | short *yyss1 = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2899 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2900 | |
| 2901 | /* Each stack pointer address is followed by the size of the |
| 2902 | data in use in that stack, in bytes. This used to be a |
| 2903 | conditional around just the two extra args, but that might |
| 2904 | be undefined if yyoverflow is a macro. */ |
| 2905 | yyoverflow ("parser stack overflow", |
| 2906 | &yyss1, yysize * sizeof (*yyssp), |
| 2907 | &yyvs1, yysize * sizeof (*yyvsp), |
| 2908 | |
| 2909 | &yystacksize); |
| 2910 | |
| 2911 | yyss = yyss1; |
| 2912 | yyvs = yyvs1; |
| 2913 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2914 | #else /* no yyoverflow */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2915 | # ifndef YYSTACK_RELOCATE |
| 2916 | goto yyoverflowlab; |
| 2917 | # else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2918 | /* Extend the stack our own way. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2919 | if (YYMAXDEPTH <= yystacksize) |
| 2920 | goto yyoverflowlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2921 | yystacksize *= 2; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2922 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2923 | yystacksize = YYMAXDEPTH; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2924 | |
| 2925 | { |
| 2926 | short *yyss1 = yyss; |
| 2927 | union yyalloc *yyptr = |
| 2928 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 2929 | if (! yyptr) |
| 2930 | goto yyoverflowlab; |
| 2931 | YYSTACK_RELOCATE (yyss); |
| 2932 | YYSTACK_RELOCATE (yyvs); |
| 2933 | |
| 2934 | # undef YYSTACK_RELOCATE |
| 2935 | if (yyss1 != yyssa) |
| 2936 | YYSTACK_FREE (yyss1); |
| 2937 | } |
| 2938 | # endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2939 | #endif /* no yyoverflow */ |
| 2940 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2941 | yyssp = yyss + yysize - 1; |
| 2942 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2943 | |
| 2944 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2945 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 2946 | (unsigned long int) yystacksize)); |
| 2947 | |
| 2948 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2949 | YYABORT; |
| 2950 | } |
| 2951 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2952 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2953 | |
| 2954 | goto yybackup; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2955 | |
| 2956 | /*-----------. |
| 2957 | | yybackup. | |
| 2958 | `-----------*/ |
| 2959 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2960 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2961 | /* Do appropriate processing given the current state. */ |
| 2962 | /* Read a lookahead token if we need one and don't already have one. */ |
| 2963 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2964 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2965 | /* First try to decide what to do without reference to lookahead token. */ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2966 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2967 | yyn = yypact[yystate]; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2968 | if (yyn == YYPACT_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2969 | goto yydefault; |
| 2970 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2971 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2972 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2973 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2974 | if (yychar == YYEMPTY) |
| 2975 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2976 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2977 | yychar = YYLEX; |
| 2978 | } |
| 2979 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2980 | if (yychar <= YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2981 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2982 | yychar = yytoken = YYEOF; |
| 2983 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2984 | } |
| 2985 | else |
| 2986 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2987 | yytoken = YYTRANSLATE (yychar); |
| 2988 | YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2989 | } |
| 2990 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2991 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 2992 | detect an error, take that action. */ |
| 2993 | yyn += yytoken; |
| 2994 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2995 | goto yydefault; |
| 2996 | yyn = yytable[yyn]; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2997 | if (yyn <= 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2998 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2999 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3000 | goto yyerrlab; |
| 3001 | yyn = -yyn; |
| 3002 | goto yyreduce; |
| 3003 | } |
| 3004 | |
| 3005 | if (yyn == YYFINAL) |
| 3006 | YYACCEPT; |
| 3007 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3008 | /* Shift the lookahead token. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3009 | YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3010 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3011 | /* Discard the token being shifted unless it is eof. */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3012 | if (yychar != YYEOF) |
| 3013 | yychar = YYEMPTY; |
| 3014 | |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 3015 | *++yyvsp = yylval; |
| 3016 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3017 | |
| 3018 | /* Count tokens shifted since error; after three, turn off error |
| 3019 | status. */ |
| 3020 | if (yyerrstatus) |
| 3021 | yyerrstatus--; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3022 | |
| 3023 | yystate = yyn; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3024 | goto yynewstate; |
| 3025 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3026 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3027 | /*-----------------------------------------------------------. |
| 3028 | | yydefault -- do the default action for the current state. | |
| 3029 | `-----------------------------------------------------------*/ |
| 3030 | yydefault: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3031 | yyn = yydefact[yystate]; |
| 3032 | if (yyn == 0) |
| 3033 | goto yyerrlab; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3034 | goto yyreduce; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3035 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3036 | |
| 3037 | /*-----------------------------. |
| 3038 | | yyreduce -- Do a reduction. | |
| 3039 | `-----------------------------*/ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3040 | yyreduce: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3041 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3042 | yylen = yyr2[yyn]; |
| 3043 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3044 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3045 | `$$ = $1'. |
| 3046 | |
| 3047 | Otherwise, the following line sets YYVAL to garbage. |
| 3048 | This behavior is undocumented and Bison |
| 3049 | users should not rely upon it. Assigning to YYVAL |
| 3050 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3051 | GCC warning that YYVAL may be used uninitialized. */ |
| 3052 | yyval = yyvsp[1-yylen]; |
| 3053 | |
| 3054 | |
| 3055 | YY_REDUCE_PRINT (yyn); |
| 3056 | switch (yyn) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3057 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3058 | case 29: |
| 3059 | #line 1128 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3060 | { yyval.IPredicate = ICmpInst::ICMP_EQ; ;} |
| 3061 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3062 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3063 | case 30: |
| 3064 | #line 1128 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3065 | { yyval.IPredicate = ICmpInst::ICMP_NE; ;} |
| 3066 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3067 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3068 | case 31: |
| 3069 | #line 1129 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3070 | { yyval.IPredicate = ICmpInst::ICMP_SLT; ;} |
| 3071 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3072 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3073 | case 32: |
| 3074 | #line 1129 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3075 | { yyval.IPredicate = ICmpInst::ICMP_SGT; ;} |
| 3076 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3077 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3078 | case 33: |
| 3079 | #line 1130 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3080 | { yyval.IPredicate = ICmpInst::ICMP_SLE; ;} |
| 3081 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3082 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3083 | case 34: |
| 3084 | #line 1130 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3085 | { yyval.IPredicate = ICmpInst::ICMP_SGE; ;} |
| 3086 | break; |
| 3087 | |
| 3088 | case 35: |
| 3089 | #line 1131 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3090 | { yyval.IPredicate = ICmpInst::ICMP_ULT; ;} |
| 3091 | break; |
| 3092 | |
| 3093 | case 36: |
| 3094 | #line 1131 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3095 | { yyval.IPredicate = ICmpInst::ICMP_UGT; ;} |
| 3096 | break; |
| 3097 | |
| 3098 | case 37: |
| 3099 | #line 1132 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3100 | { yyval.IPredicate = ICmpInst::ICMP_ULE; ;} |
| 3101 | break; |
| 3102 | |
| 3103 | case 38: |
| 3104 | #line 1132 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3105 | { yyval.IPredicate = ICmpInst::ICMP_UGE; ;} |
| 3106 | break; |
| 3107 | |
| 3108 | case 39: |
| 3109 | #line 1136 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3110 | { yyval.FPredicate = FCmpInst::FCMP_OEQ; ;} |
| 3111 | break; |
| 3112 | |
| 3113 | case 40: |
| 3114 | #line 1136 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3115 | { yyval.FPredicate = FCmpInst::FCMP_ONE; ;} |
| 3116 | break; |
| 3117 | |
| 3118 | case 41: |
| 3119 | #line 1137 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3120 | { yyval.FPredicate = FCmpInst::FCMP_OLT; ;} |
| 3121 | break; |
| 3122 | |
| 3123 | case 42: |
| 3124 | #line 1137 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3125 | { yyval.FPredicate = FCmpInst::FCMP_OGT; ;} |
| 3126 | break; |
| 3127 | |
| 3128 | case 43: |
| 3129 | #line 1138 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3130 | { yyval.FPredicate = FCmpInst::FCMP_OLE; ;} |
| 3131 | break; |
| 3132 | |
| 3133 | case 44: |
| 3134 | #line 1138 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3135 | { yyval.FPredicate = FCmpInst::FCMP_OGE; ;} |
| 3136 | break; |
| 3137 | |
| 3138 | case 45: |
| 3139 | #line 1139 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3140 | { yyval.FPredicate = FCmpInst::FCMP_ORD; ;} |
| 3141 | break; |
| 3142 | |
| 3143 | case 46: |
| 3144 | #line 1139 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3145 | { yyval.FPredicate = FCmpInst::FCMP_UNO; ;} |
| 3146 | break; |
| 3147 | |
| 3148 | case 47: |
| 3149 | #line 1140 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3150 | { yyval.FPredicate = FCmpInst::FCMP_UEQ; ;} |
| 3151 | break; |
| 3152 | |
| 3153 | case 48: |
| 3154 | #line 1140 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3155 | { yyval.FPredicate = FCmpInst::FCMP_UNE; ;} |
| 3156 | break; |
| 3157 | |
| 3158 | case 49: |
| 3159 | #line 1141 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3160 | { yyval.FPredicate = FCmpInst::FCMP_ULT; ;} |
| 3161 | break; |
| 3162 | |
| 3163 | case 50: |
| 3164 | #line 1141 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3165 | { yyval.FPredicate = FCmpInst::FCMP_UGT; ;} |
| 3166 | break; |
| 3167 | |
| 3168 | case 51: |
| 3169 | #line 1142 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3170 | { yyval.FPredicate = FCmpInst::FCMP_ULE; ;} |
| 3171 | break; |
| 3172 | |
| 3173 | case 52: |
| 3174 | #line 1142 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3175 | { yyval.FPredicate = FCmpInst::FCMP_UGE; ;} |
| 3176 | break; |
| 3177 | |
| 3178 | case 53: |
| 3179 | #line 1143 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3180 | { yyval.FPredicate = FCmpInst::FCMP_TRUE; ;} |
| 3181 | break; |
| 3182 | |
| 3183 | case 54: |
| 3184 | #line 1144 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3185 | { yyval.FPredicate = FCmpInst::FCMP_FALSE; ;} |
| 3186 | break; |
| 3187 | |
| 3188 | case 65: |
| 3189 | #line 1153 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3190 | { yyval.StrVal = 0; ;} |
| 3191 | break; |
| 3192 | |
| 3193 | case 66: |
| 3194 | #line 1157 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3195 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3196 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3197 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3198 | ;} |
| 3199 | break; |
| 3200 | |
| 3201 | case 67: |
| 3202 | #line 1161 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3203 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3204 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3205 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3206 | ;} |
| 3207 | break; |
| 3208 | |
| 3209 | case 71: |
| 3210 | #line 1169 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3211 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3212 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3213 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3214 | ;} |
| 3215 | break; |
| 3216 | |
| 3217 | case 72: |
| 3218 | #line 1174 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3219 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3220 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3221 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3222 | ;} |
| 3223 | break; |
| 3224 | |
| 3225 | case 73: |
| 3226 | #line 1180 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3227 | { yyval.Linkage = GlobalValue::InternalLinkage; ;} |
| 3228 | break; |
| 3229 | |
| 3230 | case 74: |
| 3231 | #line 1181 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3232 | { yyval.Linkage = GlobalValue::WeakLinkage; ;} |
| 3233 | break; |
| 3234 | |
| 3235 | case 75: |
| 3236 | #line 1182 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3237 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;} |
| 3238 | break; |
| 3239 | |
| 3240 | case 76: |
| 3241 | #line 1183 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3242 | { yyval.Linkage = GlobalValue::AppendingLinkage; ;} |
| 3243 | break; |
| 3244 | |
| 3245 | case 77: |
| 3246 | #line 1184 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3247 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ;} |
| 3248 | break; |
| 3249 | |
| 3250 | case 78: |
| 3251 | #line 1188 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3252 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ;} |
| 3253 | break; |
| 3254 | |
| 3255 | case 79: |
| 3256 | #line 1189 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3257 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;} |
| 3258 | break; |
| 3259 | |
| 3260 | case 80: |
| 3261 | #line 1190 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3262 | { yyval.Linkage = GlobalValue::ExternalLinkage; ;} |
| 3263 | break; |
| 3264 | |
| 3265 | case 81: |
| 3266 | #line 1194 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3267 | { yyval.Visibility = GlobalValue::DefaultVisibility; ;} |
| 3268 | break; |
| 3269 | |
| 3270 | case 82: |
| 3271 | #line 1195 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3272 | { yyval.Visibility = GlobalValue::DefaultVisibility; ;} |
| 3273 | break; |
| 3274 | |
| 3275 | case 83: |
| 3276 | #line 1196 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3277 | { yyval.Visibility = GlobalValue::HiddenVisibility; ;} |
| 3278 | break; |
| 3279 | |
| 3280 | case 84: |
| 3281 | #line 1197 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3282 | { yyval.Visibility = GlobalValue::ProtectedVisibility; ;} |
| 3283 | break; |
| 3284 | |
| 3285 | case 85: |
| 3286 | #line 1201 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3287 | { yyval.Linkage = GlobalValue::ExternalLinkage; ;} |
| 3288 | break; |
| 3289 | |
| 3290 | case 86: |
| 3291 | #line 1202 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3292 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ;} |
| 3293 | break; |
| 3294 | |
| 3295 | case 87: |
| 3296 | #line 1203 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3297 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;} |
| 3298 | break; |
| 3299 | |
| 3300 | case 88: |
| 3301 | #line 1207 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3302 | { yyval.Linkage = GlobalValue::ExternalLinkage; ;} |
| 3303 | break; |
| 3304 | |
| 3305 | case 89: |
| 3306 | #line 1208 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3307 | { yyval.Linkage = GlobalValue::InternalLinkage; ;} |
| 3308 | break; |
| 3309 | |
| 3310 | case 90: |
| 3311 | #line 1209 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3312 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;} |
| 3313 | break; |
| 3314 | |
| 3315 | case 91: |
| 3316 | #line 1210 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3317 | { yyval.Linkage = GlobalValue::WeakLinkage; ;} |
| 3318 | break; |
| 3319 | |
| 3320 | case 92: |
| 3321 | #line 1211 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3322 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ;} |
| 3323 | break; |
| 3324 | |
| 3325 | case 93: |
| 3326 | #line 1215 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3327 | { yyval.Linkage = GlobalValue::ExternalLinkage; ;} |
| 3328 | break; |
| 3329 | |
| 3330 | case 94: |
| 3331 | #line 1216 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3332 | { yyval.Linkage = GlobalValue::WeakLinkage; ;} |
| 3333 | break; |
| 3334 | |
| 3335 | case 95: |
| 3336 | #line 1217 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3337 | { yyval.Linkage = GlobalValue::InternalLinkage; ;} |
| 3338 | break; |
| 3339 | |
| 3340 | case 96: |
| 3341 | #line 1220 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3342 | { yyval.UIntVal = CallingConv::C; ;} |
| 3343 | break; |
| 3344 | |
| 3345 | case 97: |
| 3346 | #line 1221 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3347 | { yyval.UIntVal = CallingConv::C; ;} |
| 3348 | break; |
| 3349 | |
| 3350 | case 98: |
| 3351 | #line 1222 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3352 | { yyval.UIntVal = CallingConv::Fast; ;} |
| 3353 | break; |
| 3354 | |
| 3355 | case 99: |
| 3356 | #line 1223 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3357 | { yyval.UIntVal = CallingConv::Cold; ;} |
| 3358 | break; |
| 3359 | |
| 3360 | case 100: |
| 3361 | #line 1224 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3362 | { yyval.UIntVal = CallingConv::X86_StdCall; ;} |
| 3363 | break; |
| 3364 | |
| 3365 | case 101: |
| 3366 | #line 1225 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3367 | { yyval.UIntVal = CallingConv::X86_FastCall; ;} |
| 3368 | break; |
| 3369 | |
| 3370 | case 102: |
| 3371 | #line 1226 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3372 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3373 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3374 | GEN_ERROR("Calling conv too large"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3375 | yyval.UIntVal = yyvsp[0].UInt64Val; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3376 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3377 | ;} |
| 3378 | break; |
| 3379 | |
| 3380 | case 103: |
| 3381 | #line 1233 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3382 | { yyval.ParamAttrs = ParamAttr::ZExt; ;} |
| 3383 | break; |
| 3384 | |
| 3385 | case 104: |
| 3386 | #line 1234 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3387 | { yyval.ParamAttrs = ParamAttr::ZExt; ;} |
| 3388 | break; |
| 3389 | |
| 3390 | case 105: |
| 3391 | #line 1235 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3392 | { yyval.ParamAttrs = ParamAttr::SExt; ;} |
| 3393 | break; |
| 3394 | |
| 3395 | case 106: |
| 3396 | #line 1236 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3397 | { yyval.ParamAttrs = ParamAttr::SExt; ;} |
| 3398 | break; |
| 3399 | |
| 3400 | case 107: |
| 3401 | #line 1237 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3402 | { yyval.ParamAttrs = ParamAttr::InReg; ;} |
| 3403 | break; |
| 3404 | |
| 3405 | case 108: |
| 3406 | #line 1238 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3407 | { yyval.ParamAttrs = ParamAttr::StructRet; ;} |
| 3408 | break; |
| 3409 | |
| 3410 | case 109: |
| 3411 | #line 1239 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3412 | { yyval.ParamAttrs = ParamAttr::NoAlias; ;} |
| 3413 | break; |
| 3414 | |
| 3415 | case 110: |
| 3416 | #line 1240 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3417 | { yyval.ParamAttrs = ParamAttr::ByVal; ;} |
| 3418 | break; |
| 3419 | |
| 3420 | case 111: |
| 3421 | #line 1241 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3422 | { yyval.ParamAttrs = ParamAttr::Nest; ;} |
| 3423 | break; |
| 3424 | |
| 3425 | case 112: |
| 3426 | #line 1244 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3427 | { yyval.ParamAttrs = ParamAttr::None; ;} |
| 3428 | break; |
| 3429 | |
| 3430 | case 113: |
| 3431 | #line 1245 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3432 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3433 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3434 | ;} |
| 3435 | break; |
| 3436 | |
| 3437 | case 114: |
| 3438 | #line 1250 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3439 | { yyval.ParamAttrs = ParamAttr::NoReturn; ;} |
| 3440 | break; |
| 3441 | |
| 3442 | case 115: |
| 3443 | #line 1251 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3444 | { yyval.ParamAttrs = ParamAttr::NoUnwind; ;} |
| 3445 | break; |
| 3446 | |
| 3447 | case 116: |
| 3448 | #line 1252 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3449 | { yyval.ParamAttrs = ParamAttr::ZExt; ;} |
| 3450 | break; |
| 3451 | |
| 3452 | case 117: |
| 3453 | #line 1253 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3454 | { yyval.ParamAttrs = ParamAttr::SExt; ;} |
| 3455 | break; |
| 3456 | |
| 3457 | case 118: |
| 3458 | #line 1256 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3459 | { yyval.ParamAttrs = ParamAttr::None; ;} |
| 3460 | break; |
| 3461 | |
| 3462 | case 119: |
| 3463 | #line 1257 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3464 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3465 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3466 | ;} |
| 3467 | break; |
| 3468 | |
| 3469 | case 120: |
| 3470 | #line 1264 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3471 | { yyval.UIntVal = 0; ;} |
| 3472 | break; |
| 3473 | |
| 3474 | case 121: |
| 3475 | #line 1265 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3476 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3477 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 3478 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3479 | GEN_ERROR("Alignment must be a power of two"); |
| 3480 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3481 | ;} |
| 3482 | break; |
| 3483 | |
| 3484 | case 122: |
| 3485 | #line 1271 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3486 | { yyval.UIntVal = 0; ;} |
| 3487 | break; |
| 3488 | |
| 3489 | case 123: |
| 3490 | #line 1272 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3491 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3492 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 3493 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3494 | GEN_ERROR("Alignment must be a power of two"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3495 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3496 | ;} |
| 3497 | break; |
| 3498 | |
| 3499 | case 124: |
| 3500 | #line 1280 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3501 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3502 | for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i) |
| 3503 | if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\') |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3504 | GEN_ERROR("Invalid character in section name"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3505 | yyval.StrVal = yyvsp[0].StrVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3506 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3507 | ;} |
| 3508 | break; |
| 3509 | |
| 3510 | case 125: |
| 3511 | #line 1288 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3512 | { yyval.StrVal = 0; ;} |
| 3513 | break; |
| 3514 | |
| 3515 | case 126: |
| 3516 | #line 1289 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3517 | { yyval.StrVal = yyvsp[0].StrVal; ;} |
| 3518 | break; |
| 3519 | |
| 3520 | case 127: |
| 3521 | #line 1294 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3522 | {;} |
| 3523 | break; |
| 3524 | |
| 3525 | case 128: |
| 3526 | #line 1295 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3527 | {;} |
| 3528 | break; |
| 3529 | |
| 3530 | case 129: |
| 3531 | #line 1296 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3532 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3533 | CurGV->setSection(*yyvsp[0].StrVal); |
| 3534 | delete yyvsp[0].StrVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3535 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3536 | ;} |
| 3537 | break; |
| 3538 | |
| 3539 | case 130: |
| 3540 | #line 1301 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3541 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3542 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3543 | GEN_ERROR("Alignment must be a power of two"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3544 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3545 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3546 | ;} |
| 3547 | break; |
| 3548 | |
| 3549 | case 138: |
| 3550 | #line 1317 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3551 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3552 | yyval.TypeVal = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3553 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3554 | ;} |
| 3555 | break; |
| 3556 | |
| 3557 | case 139: |
| 3558 | #line 1321 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3559 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3560 | yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3561 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3562 | ;} |
| 3563 | break; |
| 3564 | |
| 3565 | case 140: |
| 3566 | #line 1325 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3567 | { // Pointer type? |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3568 | if (*yyvsp[-1].TypeVal == Type::LabelTy) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3569 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3570 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); |
| 3571 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3572 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3573 | ;} |
| 3574 | break; |
| 3575 | |
| 3576 | case 141: |
| 3577 | #line 1332 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3578 | { // Named types are also simple types... |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3579 | const Type* tmp = getTypeVal(yyvsp[0].ValIDVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3580 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3581 | yyval.TypeVal = new PATypeHolder(tmp); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3582 | ;} |
| 3583 | break; |
| 3584 | |
| 3585 | case 142: |
| 3586 | #line 1337 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3587 | { // Type UpReference |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3588 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3589 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3590 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 3591 | yyval.TypeVal = new PATypeHolder(OT); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3592 | UR_OUT("New Upreference!\n"); |
| 3593 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3594 | ;} |
| 3595 | break; |
| 3596 | |
| 3597 | case 143: |
| 3598 | #line 1345 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3599 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3600 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3601 | ParamAttrsVector Attrs; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3602 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 3603 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3604 | Attrs.push_back(X); |
| 3605 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3606 | unsigned index = 1; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3607 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3608 | for (; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 3609 | const Type *Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 3610 | Params.push_back(Ty); |
| 3611 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3612 | if (I->Attrs != ParamAttr::None) { |
| 3613 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 3614 | Attrs.push_back(X); |
| 3615 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3616 | } |
| 3617 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3618 | if (isVarArg) Params.pop_back(); |
| 3619 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3620 | ParamAttrsList *ActualAttrs = 0; |
| 3621 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3622 | ActualAttrs = ParamAttrsList::get(Attrs); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3623 | FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs); |
| 3624 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 3625 | delete yyvsp[-4].TypeVal; // Delete the return type handle |
| 3626 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3627 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3628 | ;} |
| 3629 | break; |
| 3630 | |
| 3631 | case 144: |
| 3632 | #line 1375 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3633 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3634 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3635 | ParamAttrsVector Attrs; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3636 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 3637 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3638 | Attrs.push_back(X); |
| 3639 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3640 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3641 | unsigned index = 1; |
| 3642 | for ( ; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 3643 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 3644 | Params.push_back(Ty); |
| 3645 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3646 | if (I->Attrs != ParamAttr::None) { |
| 3647 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 3648 | Attrs.push_back(X); |
| 3649 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3650 | } |
| 3651 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3652 | if (isVarArg) Params.pop_back(); |
| 3653 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3654 | ParamAttrsList *ActualAttrs = 0; |
| 3655 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3656 | ActualAttrs = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3657 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3658 | FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs); |
| 3659 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 3660 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3661 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3662 | ;} |
| 3663 | break; |
| 3664 | |
| 3665 | case 145: |
| 3666 | #line 1406 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3667 | { // Sized array type? |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3668 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 3669 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3670 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3671 | ;} |
| 3672 | break; |
| 3673 | |
| 3674 | case 146: |
| 3675 | #line 1411 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3676 | { // Vector type? |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3677 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); |
| 3678 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3679 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 3680 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
| 3681 | GEN_ERROR("Element type of a VectorType must be primitive"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3682 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3683 | GEN_ERROR("Vector length should be a power of 2"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3684 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 3685 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3686 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3687 | ;} |
| 3688 | break; |
| 3689 | |
| 3690 | case 147: |
| 3691 | #line 1423 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3692 | { // Structure type? |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3693 | std::vector<const Type*> Elements; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3694 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 3695 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3696 | Elements.push_back(*I); |
| 3697 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3698 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3699 | delete yyvsp[-1].TypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3700 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3701 | ;} |
| 3702 | break; |
| 3703 | |
| 3704 | case 148: |
| 3705 | #line 1433 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3706 | { // Empty structure type? |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3707 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3708 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3709 | ;} |
| 3710 | break; |
| 3711 | |
| 3712 | case 149: |
| 3713 | #line 1437 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3714 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3715 | std::vector<const Type*> Elements; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3716 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(), |
| 3717 | E = yyvsp[-2].TypeList->end(); I != E; ++I) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3718 | Elements.push_back(*I); |
| 3719 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3720 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 3721 | delete yyvsp[-2].TypeList; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3722 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3723 | ;} |
| 3724 | break; |
| 3725 | |
| 3726 | case 150: |
| 3727 | #line 1447 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3728 | { // Empty structure type? |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3729 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3730 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3731 | ;} |
| 3732 | break; |
| 3733 | |
| 3734 | case 151: |
| 3735 | #line 1454 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3736 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3737 | yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal; |
| 3738 | yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3739 | ;} |
| 3740 | break; |
| 3741 | |
| 3742 | case 152: |
| 3743 | #line 1461 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3744 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3745 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3746 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 3747 | if (!(*yyvsp[0].TypeVal)->isFirstClassType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3748 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3749 | yyval.TypeVal = yyvsp[0].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3750 | ;} |
| 3751 | break; |
| 3752 | |
| 3753 | case 153: |
| 3754 | #line 1468 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3755 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3756 | yyval.TypeVal = new PATypeHolder(Type::VoidTy); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3757 | ;} |
| 3758 | break; |
| 3759 | |
| 3760 | case 154: |
| 3761 | #line 1473 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3762 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3763 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
| 3764 | yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3765 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3766 | ;} |
| 3767 | break; |
| 3768 | |
| 3769 | case 155: |
| 3770 | #line 1478 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3771 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3772 | (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3773 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3774 | ;} |
| 3775 | break; |
| 3776 | |
| 3777 | case 157: |
| 3778 | #line 1486 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3779 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3780 | yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3781 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3782 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3783 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3784 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3785 | ;} |
| 3786 | break; |
| 3787 | |
| 3788 | case 158: |
| 3789 | #line 1493 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3790 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3791 | yyval.TypeWithAttrsList = new TypeWithAttrsList; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3792 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
| 3793 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3794 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3795 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3796 | ;} |
| 3797 | break; |
| 3798 | |
| 3799 | case 159: |
| 3800 | #line 1500 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3801 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3802 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3803 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3804 | ;} |
| 3805 | break; |
| 3806 | |
| 3807 | case 160: |
| 3808 | #line 1508 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3809 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3810 | yyval.TypeList = new std::list<PATypeHolder>(); |
| 3811 | yyval.TypeList->push_back(*yyvsp[0].TypeVal); |
| 3812 | delete yyvsp[0].TypeVal; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3813 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3814 | ;} |
| 3815 | break; |
| 3816 | |
| 3817 | case 161: |
| 3818 | #line 1514 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3819 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3820 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); |
| 3821 | delete yyvsp[0].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3822 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3823 | ;} |
| 3824 | break; |
| 3825 | |
| 3826 | case 162: |
| 3827 | #line 1526 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3828 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3829 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3830 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3831 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3832 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3833 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3834 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3835 | const Type *ETy = ATy->getElementType(); |
| 3836 | int NumElements = ATy->getNumElements(); |
| 3837 | |
| 3838 | // Verify that we have the correct size... |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3839 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3840 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3841 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3842 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3843 | |
| 3844 | // Verify all elements are correct type! |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3845 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3846 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3847 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3848 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3849 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3850 | } |
| 3851 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3852 | yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); |
| 3853 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3854 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3855 | ;} |
| 3856 | break; |
| 3857 | |
| 3858 | case 163: |
| 3859 | #line 1554 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3860 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3861 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3862 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3863 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3864 | if (ATy == 0) |
| 3865 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3866 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3867 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3868 | int NumElements = ATy->getNumElements(); |
| 3869 | if (NumElements != -1 && NumElements != 0) |
| 3870 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3871 | " arguments, but has size of " + itostr(NumElements) +""); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3872 | yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3873 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3874 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3875 | ;} |
| 3876 | break; |
| 3877 | |
| 3878 | case 164: |
| 3879 | #line 1570 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3880 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3881 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3882 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3883 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3884 | if (ATy == 0) |
| 3885 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3886 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3887 | |
| 3888 | int NumElements = ATy->getNumElements(); |
| 3889 | const Type *ETy = ATy->getElementType(); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3890 | if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3891 | GEN_ERROR("Can't build string constant of size " + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3892 | itostr((int)(yyvsp[0].StrVal->length())) + |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3893 | " when array has size " + itostr(NumElements) + ""); |
| 3894 | std::vector<Constant*> Vals; |
| 3895 | if (ETy == Type::Int8Ty) { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3896 | for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i) |
| 3897 | Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i])); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3898 | } else { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3899 | delete yyvsp[0].StrVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3900 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
| 3901 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3902 | delete yyvsp[0].StrVal; |
| 3903 | yyval.ConstVal = ConstantArray::get(ATy, Vals); |
| 3904 | delete yyvsp[-2].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3905 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3906 | ;} |
| 3907 | break; |
| 3908 | |
| 3909 | case 165: |
| 3910 | #line 1597 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3911 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3912 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3913 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3914 | const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3915 | if (PTy == 0) |
| 3916 | GEN_ERROR("Cannot make packed constant with type: '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3917 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3918 | const Type *ETy = PTy->getElementType(); |
| 3919 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3920 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3921 | // Verify that we have the correct size... |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3922 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3923 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3924 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3925 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3926 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3927 | // Verify all elements are correct type! |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3928 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3929 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3930 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3931 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3932 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3933 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3934 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3935 | yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector); |
| 3936 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3937 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3938 | ;} |
| 3939 | break; |
| 3940 | |
| 3941 | case 166: |
| 3942 | #line 1625 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3943 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3944 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3945 | if (STy == 0) |
| 3946 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3947 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3948 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3949 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3950 | GEN_ERROR("Illegal number of initializers for structure type"); |
| 3951 | |
| 3952 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3953 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) |
| 3954 | if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3955 | GEN_ERROR("Expected type '" + |
| 3956 | STy->getElementType(i)->getDescription() + |
| 3957 | "' for element #" + utostr(i) + |
| 3958 | " of structure initializer"); |
| 3959 | |
| 3960 | // Check to ensure that Type is not packed |
| 3961 | if (STy->isPacked()) |
| 3962 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 3963 | STy->getDescription() + "'"); |
| 3964 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3965 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); |
| 3966 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3967 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3968 | ;} |
| 3969 | break; |
| 3970 | |
| 3971 | case 167: |
| 3972 | #line 1651 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3973 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3974 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3975 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3976 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3977 | if (STy == 0) |
| 3978 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3979 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3980 | |
| 3981 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3982 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3983 | |
| 3984 | // Check to ensure that Type is not packed |
| 3985 | if (STy->isPacked()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3986 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 3987 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3988 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3989 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3990 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3991 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3992 | ;} |
| 3993 | break; |
| 3994 | |
| 3995 | case 168: |
| 3996 | #line 1671 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 3997 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 3998 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3999 | if (STy == 0) |
| 4000 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4001 | (*yyvsp[-5].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4002 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4003 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4004 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4005 | |
| 4006 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4007 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) |
| 4008 | if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4009 | GEN_ERROR("Expected type '" + |
| 4010 | STy->getElementType(i)->getDescription() + |
| 4011 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4012 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4013 | |
| 4014 | // Check to ensure that Type is packed |
| 4015 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4016 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 4017 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4018 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4019 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector); |
| 4020 | delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4021 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4022 | ;} |
| 4023 | break; |
| 4024 | |
| 4025 | case 169: |
| 4026 | #line 1697 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4027 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4028 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4029 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4030 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4031 | if (STy == 0) |
| 4032 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4033 | (*yyvsp[-4].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4034 | |
| 4035 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4036 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4037 | |
| 4038 | // Check to ensure that Type is packed |
| 4039 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4040 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 4041 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4042 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4043 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4044 | delete yyvsp[-4].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4045 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4046 | ;} |
| 4047 | break; |
| 4048 | |
| 4049 | case 170: |
| 4050 | #line 1717 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4051 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4052 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4053 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4054 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4055 | if (PTy == 0) |
| 4056 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4057 | (*yyvsp[-1].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4058 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4059 | yyval.ConstVal = ConstantPointerNull::get(PTy); |
| 4060 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4061 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4062 | ;} |
| 4063 | break; |
| 4064 | |
| 4065 | case 171: |
| 4066 | #line 1729 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4067 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4068 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4069 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4070 | yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); |
| 4071 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4072 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4073 | ;} |
| 4074 | break; |
| 4075 | |
| 4076 | case 172: |
| 4077 | #line 1736 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4078 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4079 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4080 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4081 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4082 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4083 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4084 | |
| 4085 | // ConstExprs can exist in the body of a function, thus creating |
| 4086 | // GlobalValues whenever they refer to a variable. Because we are in |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4087 | // the context of a function, getExistingVal will search the functions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4088 | // symbol table instead of the module symbol table for the global symbol, |
| 4089 | // which throws things all off. To get around this, we just tell |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4090 | // getExistingVal that we are at global scope here. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4091 | // |
| 4092 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 4093 | CurFun.CurrentFunction = 0; |
| 4094 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4095 | Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4096 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4097 | |
| 4098 | CurFun.CurrentFunction = SavedCurFn; |
| 4099 | |
| 4100 | // If this is an initializer for a constant pointer, which is referencing a |
| 4101 | // (currently) undefined variable, create a stub now that shall be replaced |
| 4102 | // in the future with the right type of variable. |
| 4103 | // |
| 4104 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 4105 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4106 | const PointerType *PT = cast<PointerType>(Ty); |
| 4107 | |
| 4108 | // First check to see if the forward references value is already created! |
| 4109 | PerModuleInfo::GlobalRefsType::iterator I = |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4110 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4111 | |
| 4112 | if (I != CurModule.GlobalRefs.end()) { |
| 4113 | V = I->second; // Placeholder already exists, use it... |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4114 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4115 | } else { |
| 4116 | std::string Name; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4117 | if (yyvsp[0].ValIDVal.Type == ValID::GlobalName) |
| 4118 | Name = yyvsp[0].ValIDVal.getName(); |
| 4119 | else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4120 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4121 | |
| 4122 | // Create the forward referenced global. |
| 4123 | GlobalValue *GV; |
| 4124 | if (const FunctionType *FTy = |
| 4125 | dyn_cast<FunctionType>(PT->getElementType())) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4126 | GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4127 | CurModule.CurrentModule); |
| 4128 | } else { |
| 4129 | GV = new GlobalVariable(PT->getElementType(), false, |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4130 | GlobalValue::ExternalWeakLinkage, 0, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4131 | Name, CurModule.CurrentModule); |
| 4132 | } |
| 4133 | |
| 4134 | // Keep track of the fact that we have a forward ref to recycle it |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4135 | 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] | 4136 | V = GV; |
| 4137 | } |
| 4138 | } |
| 4139 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4140 | yyval.ConstVal = cast<GlobalValue>(V); |
| 4141 | delete yyvsp[-1].TypeVal; // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4142 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4143 | ;} |
| 4144 | break; |
| 4145 | |
| 4146 | case 173: |
| 4147 | #line 1802 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4148 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4149 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4150 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4151 | if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4152 | GEN_ERROR("Mismatched types for constant expression: " + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4153 | (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription()); |
| 4154 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 4155 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4156 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4157 | ;} |
| 4158 | break; |
| 4159 | |
| 4160 | case 174: |
| 4161 | #line 1812 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4162 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4163 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4164 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4165 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4166 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 4167 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4168 | yyval.ConstVal = Constant::getNullValue(Ty); |
| 4169 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4170 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4171 | ;} |
| 4172 | break; |
| 4173 | |
| 4174 | case 175: |
| 4175 | #line 1822 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4176 | { // integral constants |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4177 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4178 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4179 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 4180 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4181 | ;} |
| 4182 | break; |
| 4183 | |
| 4184 | case 176: |
| 4185 | #line 1828 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4186 | { // arbitrary precision integer constants |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4187 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 4188 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4189 | GEN_ERROR("Constant value does not fit in type"); |
| 4190 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4191 | yyvsp[0].APIntVal->sextOrTrunc(BitWidth); |
| 4192 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 4193 | delete yyvsp[0].APIntVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4194 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4195 | ;} |
| 4196 | break; |
| 4197 | |
| 4198 | case 177: |
| 4199 | #line 1838 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4200 | { // integral constants |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4201 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4202 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4203 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4204 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4205 | ;} |
| 4206 | break; |
| 4207 | |
| 4208 | case 178: |
| 4209 | #line 1844 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4210 | { // arbitrary precision integer constants |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4211 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 4212 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4213 | GEN_ERROR("Constant value does not fit in type"); |
| 4214 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4215 | yyvsp[0].APIntVal->zextOrTrunc(BitWidth); |
| 4216 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 4217 | delete yyvsp[0].APIntVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4218 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4219 | ;} |
| 4220 | break; |
| 4221 | |
| 4222 | case 179: |
| 4223 | #line 1854 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4224 | { // Boolean constants |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4225 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 4226 | yyval.ConstVal = ConstantInt::getTrue(); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 4227 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4228 | ;} |
| 4229 | break; |
| 4230 | |
| 4231 | case 180: |
| 4232 | #line 1859 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4233 | { // Boolean constants |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4234 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 4235 | yyval.ConstVal = ConstantInt::getFalse(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4236 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4237 | ;} |
| 4238 | break; |
| 4239 | |
| 4240 | case 181: |
| 4241 | #line 1864 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4242 | { // Float & Double constants |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4243 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4244 | GEN_ERROR("Floating point constant invalid for type"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4245 | yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4246 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4247 | ;} |
| 4248 | break; |
| 4249 | |
| 4250 | case 182: |
| 4251 | #line 1872 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4252 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4253 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4254 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4255 | Constant *Val = yyvsp[-3].ConstVal; |
| 4256 | const Type *DestTy = yyvsp[-1].TypeVal->get(); |
| 4257 | if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4258 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4259 | Val->getType()->getDescription() + "' to '" + |
| 4260 | DestTy->getDescription() + "'"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4261 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); |
| 4262 | delete yyvsp[-1].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4263 | ;} |
| 4264 | break; |
| 4265 | |
| 4266 | case 183: |
| 4267 | #line 1884 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4268 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4269 | if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4270 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4271 | |
| 4272 | const Type *IdxTy = |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4273 | GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end(), |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 4274 | true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4275 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4276 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4277 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 4278 | SmallVector<Constant*, 8> IdxVec; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4279 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) |
| 4280 | if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4281 | IdxVec.push_back(C); |
| 4282 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4283 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4284 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4285 | delete yyvsp[-1].ValueList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4286 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4287 | yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4288 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4289 | ;} |
| 4290 | break; |
| 4291 | |
| 4292 | case 184: |
| 4293 | #line 1906 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4294 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4295 | if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4296 | GEN_ERROR("Select condition must be of boolean type"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4297 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4298 | GEN_ERROR("Select operand types must match"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4299 | yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4300 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4301 | ;} |
| 4302 | break; |
| 4303 | |
| 4304 | case 185: |
| 4305 | #line 1914 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4306 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4307 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4308 | GEN_ERROR("Binary operator types must match"); |
| 4309 | CHECK_FOR_ERROR; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4310 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4311 | ;} |
| 4312 | break; |
| 4313 | |
| 4314 | case 186: |
| 4315 | #line 1920 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4316 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4317 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4318 | GEN_ERROR("Logical operator types must match"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4319 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) { |
| 4320 | if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) || |
| 4321 | !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4322 | GEN_ERROR("Logical operator requires integral operands"); |
| 4323 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4324 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4325 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4326 | ;} |
| 4327 | break; |
| 4328 | |
| 4329 | case 187: |
| 4330 | #line 1931 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4331 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4332 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4333 | GEN_ERROR("icmp operand types must match"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4334 | yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4335 | ;} |
| 4336 | break; |
| 4337 | |
| 4338 | case 188: |
| 4339 | #line 1936 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4340 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4341 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4342 | GEN_ERROR("fcmp operand types must match"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4343 | yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4344 | ;} |
| 4345 | break; |
| 4346 | |
| 4347 | case 189: |
| 4348 | #line 1941 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4349 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4350 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4351 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4352 | yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4353 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4354 | ;} |
| 4355 | break; |
| 4356 | |
| 4357 | case 190: |
| 4358 | #line 1947 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4359 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4360 | if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4361 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4362 | 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] | 4363 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4364 | ;} |
| 4365 | break; |
| 4366 | |
| 4367 | case 191: |
| 4368 | #line 1953 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4369 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4370 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4371 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4372 | 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] | 4373 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4374 | ;} |
| 4375 | break; |
| 4376 | |
| 4377 | case 192: |
| 4378 | #line 1962 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4379 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4380 | (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4381 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4382 | ;} |
| 4383 | break; |
| 4384 | |
| 4385 | case 193: |
| 4386 | #line 1966 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4387 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4388 | yyval.ConstVector = new std::vector<Constant*>(); |
| 4389 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4390 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4391 | ;} |
| 4392 | break; |
| 4393 | |
| 4394 | case 194: |
| 4395 | #line 1974 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4396 | { yyval.BoolVal = false; ;} |
| 4397 | break; |
| 4398 | |
| 4399 | case 195: |
| 4400 | #line 1974 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4401 | { yyval.BoolVal = true; ;} |
| 4402 | break; |
| 4403 | |
| 4404 | case 196: |
| 4405 | #line 1977 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4406 | { yyval.BoolVal = true; ;} |
| 4407 | break; |
| 4408 | |
| 4409 | case 197: |
| 4410 | #line 1977 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4411 | { yyval.BoolVal = false; ;} |
| 4412 | break; |
| 4413 | |
| 4414 | case 198: |
| 4415 | #line 1980 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4416 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4417 | const Type* VTy = yyvsp[-1].TypeVal->get(); |
| 4418 | Value *V = getVal(VTy, yyvsp[0].ValIDVal); |
| 4419 | CHECK_FOR_ERROR |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4420 | GlobalValue* Aliasee = dyn_cast<GlobalValue>(V); |
| 4421 | if (!Aliasee) |
| 4422 | GEN_ERROR("Aliases can be created only to global values"); |
| 4423 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4424 | yyval.ConstVal = Aliasee; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4425 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4426 | delete yyvsp[-1].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4427 | ;} |
| 4428 | break; |
| 4429 | |
| 4430 | case 199: |
| 4431 | #line 1992 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4432 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4433 | Constant *Val = yyvsp[-3].ConstVal; |
| 4434 | const Type *DestTy = yyvsp[-1].TypeVal->get(); |
| 4435 | if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4436 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4437 | Val->getType()->getDescription() + "' to '" + |
| 4438 | DestTy->getDescription() + "'"); |
| 4439 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4440 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4441 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4442 | delete yyvsp[-1].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4443 | ;} |
| 4444 | break; |
| 4445 | |
| 4446 | case 200: |
| 4447 | #line 2013 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4448 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4449 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 1013b4d | 2007-07-31 14:41:17 +0000 | [diff] [blame] | 4450 | CurModule.ModuleDone(); |
| 4451 | CHECK_FOR_ERROR; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4452 | ;} |
| 4453 | break; |
| 4454 | |
| 4455 | case 201: |
| 4456 | #line 2018 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4457 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4458 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4459 | CurModule.ModuleDone(); |
| 4460 | CHECK_FOR_ERROR; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4461 | ;} |
| 4462 | break; |
| 4463 | |
| 4464 | case 204: |
| 4465 | #line 2031 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4466 | { CurFun.isDeclare = false; ;} |
| 4467 | break; |
| 4468 | |
| 4469 | case 205: |
| 4470 | #line 2031 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4471 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4472 | CurFun.FunctionDone(); |
| 4473 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4474 | ;} |
| 4475 | break; |
| 4476 | |
| 4477 | case 206: |
| 4478 | #line 2035 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4479 | { CurFun.isDeclare = true; ;} |
| 4480 | break; |
| 4481 | |
| 4482 | case 207: |
| 4483 | #line 2035 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4484 | { |
Reid Spencer | 1013b4d | 2007-07-31 14:41:17 +0000 | [diff] [blame] | 4485 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4486 | ;} |
| 4487 | break; |
| 4488 | |
| 4489 | case 208: |
| 4490 | #line 2038 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4491 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4492 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4493 | ;} |
| 4494 | break; |
| 4495 | |
| 4496 | case 209: |
| 4497 | #line 2041 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4498 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4499 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4500 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4501 | // Eagerly resolve types. This is not an optimization, this is a |
| 4502 | // requirement that is due to the fact that we could have this: |
| 4503 | // |
| 4504 | // %list = type { %list * } |
| 4505 | // %list = type { %list * } ; repeated type decl |
| 4506 | // |
| 4507 | // If types are not resolved eagerly, then the two types will not be |
| 4508 | // determined to be the same type! |
| 4509 | // |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4510 | ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4511 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4512 | if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4513 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4514 | // If this is a named type that is not a redefinition, add it to the slot |
| 4515 | // table. |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4516 | CurModule.Types.push_back(*yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4517 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4518 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4519 | delete yyvsp[0].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4520 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4521 | ;} |
| 4522 | break; |
| 4523 | |
| 4524 | case 210: |
| 4525 | #line 2065 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4526 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4527 | ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType); |
Reid Spencer | b8f8505 | 2007-07-31 03:50:36 +0000 | [diff] [blame] | 4528 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4529 | if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4530 | CHECK_FOR_ERROR |
| 4531 | // If this is a named type that is not a redefinition, add it to the slot |
| 4532 | // table. |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4533 | CurModule.Types.push_back(yyvsp[0].PrimType); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4534 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4535 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4536 | ;} |
| 4537 | break; |
| 4538 | |
| 4539 | case 211: |
| 4540 | #line 2076 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4541 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4542 | /* "Externally Visible" Linkage */ |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4543 | if (yyvsp[0].ConstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4544 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4545 | CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage, |
| 4546 | yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4547 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4548 | ;} |
| 4549 | break; |
| 4550 | |
| 4551 | case 212: |
| 4552 | #line 2083 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4553 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4554 | CurGV = 0; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4555 | ;} |
| 4556 | break; |
| 4557 | |
| 4558 | case 213: |
| 4559 | #line 2087 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4560 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4561 | if (yyvsp[0].ConstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4562 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4563 | CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4564 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4565 | ;} |
| 4566 | break; |
| 4567 | |
| 4568 | case 214: |
| 4569 | #line 2092 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4570 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4571 | CurGV = 0; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4572 | ;} |
| 4573 | break; |
| 4574 | |
| 4575 | case 215: |
| 4576 | #line 2096 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4577 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4578 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4579 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4580 | CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0, yyvsp[-2].BoolVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4581 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4582 | delete yyvsp[0].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4583 | ;} |
| 4584 | break; |
| 4585 | |
| 4586 | case 216: |
| 4587 | #line 2102 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4588 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4589 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4590 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4591 | ;} |
| 4592 | break; |
| 4593 | |
| 4594 | case 217: |
| 4595 | #line 2106 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4596 | { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 4597 | std::string Name; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4598 | if (yyvsp[-4].StrVal) { |
| 4599 | Name = *yyvsp[-4].StrVal; |
| 4600 | delete yyvsp[-4].StrVal; |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 4601 | } |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4602 | if (Name.empty()) |
| 4603 | GEN_ERROR("Alias name cannot be empty"); |
| 4604 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4605 | Constant* Aliasee = yyvsp[0].ConstVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4606 | if (Aliasee == 0) |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 4607 | GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4608 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4609 | GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee, |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4610 | CurModule.CurrentModule); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4611 | GA->setVisibility(yyvsp[-3].Visibility); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4612 | InsertValue(GA, CurModule.Values); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4613 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4614 | ;} |
| 4615 | break; |
| 4616 | |
| 4617 | case 218: |
| 4618 | #line 2125 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4619 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4620 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4621 | ;} |
| 4622 | break; |
| 4623 | |
| 4624 | case 219: |
| 4625 | #line 2128 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4626 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4627 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4628 | ;} |
| 4629 | break; |
| 4630 | |
| 4631 | case 220: |
| 4632 | #line 2134 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4633 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4634 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4635 | if (AsmSoFar.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4636 | CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4637 | else |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4638 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal); |
| 4639 | delete yyvsp[0].StrVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4640 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4641 | ;} |
| 4642 | break; |
| 4643 | |
| 4644 | case 221: |
| 4645 | #line 2144 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4646 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4647 | CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal); |
| 4648 | delete yyvsp[0].StrVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4649 | ;} |
| 4650 | break; |
| 4651 | |
| 4652 | case 222: |
| 4653 | #line 2148 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4654 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4655 | CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal); |
| 4656 | delete yyvsp[0].StrVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4657 | ;} |
| 4658 | break; |
| 4659 | |
| 4660 | case 224: |
| 4661 | #line 2155 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4662 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4663 | CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal); |
| 4664 | delete yyvsp[0].StrVal; |
Reid Spencer | 1013b4d | 2007-07-31 14:41:17 +0000 | [diff] [blame] | 4665 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4666 | ;} |
| 4667 | break; |
| 4668 | |
| 4669 | case 225: |
| 4670 | #line 2160 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4671 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4672 | CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal); |
| 4673 | delete yyvsp[0].StrVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4674 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4675 | ;} |
| 4676 | break; |
| 4677 | |
| 4678 | case 226: |
| 4679 | #line 2165 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4680 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4681 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4682 | ;} |
| 4683 | break; |
| 4684 | |
| 4685 | case 227: |
| 4686 | #line 2174 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4687 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4688 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4689 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4690 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4691 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4692 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 4693 | yyval.ArgList = yyvsp[-4].ArgList; |
| 4694 | yyvsp[-4].ArgList->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4695 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4696 | ;} |
| 4697 | break; |
| 4698 | |
| 4699 | case 228: |
| 4700 | #line 2184 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4701 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4702 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4703 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4704 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4705 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4706 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 4707 | yyval.ArgList = new ArgListType; |
| 4708 | yyval.ArgList->push_back(E); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4709 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4710 | ;} |
| 4711 | break; |
| 4712 | |
| 4713 | case 229: |
| 4714 | #line 2195 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4715 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4716 | yyval.ArgList = yyvsp[0].ArgList; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4717 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4718 | ;} |
| 4719 | break; |
| 4720 | |
| 4721 | case 230: |
| 4722 | #line 2199 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4723 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4724 | yyval.ArgList = yyvsp[-2].ArgList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4725 | struct ArgListEntry E; |
| 4726 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 4727 | E.Name = 0; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 4728 | E.Attrs = ParamAttr::None; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4729 | yyval.ArgList->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4730 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4731 | ;} |
| 4732 | break; |
| 4733 | |
| 4734 | case 231: |
| 4735 | #line 2208 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4736 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4737 | yyval.ArgList = new ArgListType; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4738 | struct ArgListEntry E; |
| 4739 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 4740 | E.Name = 0; |
| 4741 | E.Attrs = ParamAttr::None; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4742 | yyval.ArgList->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4743 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4744 | ;} |
| 4745 | break; |
| 4746 | |
| 4747 | case 232: |
| 4748 | #line 2217 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4749 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4750 | yyval.ArgList = 0; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4751 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4752 | ;} |
| 4753 | break; |
| 4754 | |
| 4755 | case 233: |
| 4756 | #line 2223 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4757 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4758 | std::string FunctionName(*yyvsp[-6].StrVal); |
| 4759 | delete yyvsp[-6].StrVal; // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4760 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4761 | // Check the function result for abstractness if this is a define. We should |
| 4762 | // have no abstract types at this point |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4763 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal)) |
| 4764 | GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4765 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4766 | std::vector<const Type*> ParamTypeList; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4767 | ParamAttrsVector Attrs; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4768 | if (yyvsp[-2].ParamAttrs != ParamAttr::None) { |
| 4769 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4770 | Attrs.push_back(PAWI); |
| 4771 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4772 | if (yyvsp[-4].ArgList) { // If there are arguments... |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4773 | unsigned index = 1; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4774 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4775 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4776 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 4777 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4778 | ParamTypeList.push_back(Ty); |
| 4779 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4780 | if (I->Attrs != ParamAttr::None) { |
| 4781 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4782 | Attrs.push_back(PAWI); |
| 4783 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4784 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4785 | } |
| 4786 | |
| 4787 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 4788 | if (isVarArg) ParamTypeList.pop_back(); |
| 4789 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4790 | ParamAttrsList *PAL = 0; |
| 4791 | if (!Attrs.empty()) |
| 4792 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4793 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4794 | FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4795 | const PointerType *PFT = PointerType::get(FT); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4796 | delete yyvsp[-7].TypeVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4797 | |
| 4798 | ValID ID; |
| 4799 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4800 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4801 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4802 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4803 | } |
| 4804 | |
| 4805 | Function *Fn = 0; |
| 4806 | // See if this function was forward referenced. If so, recycle the object. |
| 4807 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4808 | // Move the function to the end of the list, from whereever it was |
| 4809 | // previously inserted. |
| 4810 | Fn = cast<Function>(FWRef); |
| 4811 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 4812 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 4813 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4814 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4815 | if (Fn->getFunctionType() != FT) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4816 | // The existing function doesn't have the same type. This is an overload |
| 4817 | // error. |
| 4818 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
| 4819 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4820 | // Neither the existing or the current function is a declaration and they |
| 4821 | // have the same name and same type. Clearly this is a redefinition. |
| 4822 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4823 | } if (Fn->isDeclaration()) { |
| 4824 | // 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] | 4825 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4826 | AI != AE; ++AI) |
| 4827 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4828 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4829 | } else { // Not already defined? |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4830 | Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4831 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4832 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4833 | InsertValue(Fn, CurModule.Values); |
| 4834 | } |
| 4835 | |
| 4836 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4837 | |
| 4838 | if (CurFun.isDeclare) { |
| 4839 | // If we have declaration, always overwrite linkage. This will allow us to |
| 4840 | // correctly handle cases, when pointer to function is passed as argument to |
| 4841 | // another function. |
| 4842 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4843 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4844 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4845 | Fn->setCallingConv(yyvsp[-8].UIntVal); |
| 4846 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 4847 | if (yyvsp[-1].StrVal) { |
| 4848 | Fn->setSection(*yyvsp[-1].StrVal); |
| 4849 | delete yyvsp[-1].StrVal; |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4850 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4851 | |
| 4852 | // Add all of the arguments we parsed to the function... |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4853 | if (yyvsp[-4].ArgList) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4854 | if (isVarArg) { // Nuke the last entry |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4855 | 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] | 4856 | "Not a varargs marker!"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4857 | delete yyvsp[-4].ArgList->back().Ty; |
| 4858 | yyvsp[-4].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4859 | } |
| 4860 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4861 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4862 | unsigned Idx = 1; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4863 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); |
| 4864 | I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4865 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 4866 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4867 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4868 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4869 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4870 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4871 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4872 | delete yyvsp[-4].ArgList; // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4873 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4874 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4875 | ;} |
| 4876 | break; |
| 4877 | |
| 4878 | case 236: |
| 4879 | #line 2345 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4880 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4881 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4882 | |
| 4883 | // Make sure that we keep track of the linkage type even if there was a |
| 4884 | // previous "declare". |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4885 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
| 4886 | yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4887 | ;} |
| 4888 | break; |
| 4889 | |
| 4890 | case 239: |
| 4891 | #line 2356 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4892 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4893 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4894 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4895 | ;} |
| 4896 | break; |
| 4897 | |
| 4898 | case 240: |
| 4899 | #line 2361 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4900 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4901 | CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage); |
| 4902 | CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility); |
| 4903 | yyval.FunctionVal = CurFun.CurrentFunction; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4904 | CurFun.FunctionDone(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4905 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4906 | ;} |
| 4907 | break; |
| 4908 | |
| 4909 | case 241: |
| 4910 | #line 2373 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4911 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4912 | yyval.BoolVal = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4913 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4914 | ;} |
| 4915 | break; |
| 4916 | |
| 4917 | case 242: |
| 4918 | #line 2377 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4919 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4920 | yyval.BoolVal = true; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4921 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4922 | ;} |
| 4923 | break; |
| 4924 | |
| 4925 | case 243: |
| 4926 | #line 2382 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4927 | { // A reference to a direct constant |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4928 | yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4929 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4930 | ;} |
| 4931 | break; |
| 4932 | |
| 4933 | case 244: |
| 4934 | #line 2386 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4935 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4936 | yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4937 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4938 | ;} |
| 4939 | break; |
| 4940 | |
| 4941 | case 245: |
| 4942 | #line 2390 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4943 | { // Perhaps it's an FP constant? |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4944 | yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4945 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4946 | ;} |
| 4947 | break; |
| 4948 | |
| 4949 | case 246: |
| 4950 | #line 2394 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4951 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4952 | yyval.ValIDVal = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4953 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4954 | ;} |
| 4955 | break; |
| 4956 | |
| 4957 | case 247: |
| 4958 | #line 2398 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4959 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4960 | yyval.ValIDVal = ValID::create(ConstantInt::getFalse()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4961 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4962 | ;} |
| 4963 | break; |
| 4964 | |
| 4965 | case 248: |
| 4966 | #line 2402 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4967 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4968 | yyval.ValIDVal = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4969 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4970 | ;} |
| 4971 | break; |
| 4972 | |
| 4973 | case 249: |
| 4974 | #line 2406 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4975 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4976 | yyval.ValIDVal = ValID::createUndef(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4977 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4978 | ;} |
| 4979 | break; |
| 4980 | |
| 4981 | case 250: |
| 4982 | #line 2410 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4983 | { // A vector zero constant. |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4984 | yyval.ValIDVal = ValID::createZeroInit(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4985 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4986 | ;} |
| 4987 | break; |
| 4988 | |
| 4989 | case 251: |
| 4990 | #line 2414 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 4991 | { // Nonempty unsized packed vector |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4992 | const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); |
| 4993 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4994 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4995 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4996 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4997 | HandleUpRefs( |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4998 | VectorType::get( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4999 | ETy, |
| 5000 | NumElements) |
| 5001 | ) |
| 5002 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5003 | |
| 5004 | // Verify all elements are correct type! |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5005 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 5006 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5007 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5008 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5009 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5010 | } |
| 5011 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5012 | yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector)); |
| 5013 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5014 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5015 | ;} |
| 5016 | break; |
| 5017 | |
| 5018 | case 252: |
| 5019 | #line 2439 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5020 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5021 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5022 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5023 | ;} |
| 5024 | break; |
| 5025 | |
| 5026 | case 253: |
| 5027 | #line 2443 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5028 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5029 | yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal); |
| 5030 | delete yyvsp[-2].StrVal; |
| 5031 | delete yyvsp[0].StrVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5032 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5033 | ;} |
| 5034 | break; |
| 5035 | |
| 5036 | case 254: |
| 5037 | #line 2453 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5038 | { // Is it an integer reference...? |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5039 | yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5040 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5041 | ;} |
| 5042 | break; |
| 5043 | |
| 5044 | case 255: |
| 5045 | #line 2457 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5046 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5047 | yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5048 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5049 | ;} |
| 5050 | break; |
| 5051 | |
| 5052 | case 256: |
| 5053 | #line 2461 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5054 | { // Is it a named reference...? |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5055 | yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal); |
| 5056 | delete yyvsp[0].StrVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5057 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5058 | ;} |
| 5059 | break; |
| 5060 | |
| 5061 | case 257: |
| 5062 | #line 2466 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5063 | { // Is it a named reference...? |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5064 | yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal); |
| 5065 | delete yyvsp[0].StrVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5066 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5067 | ;} |
| 5068 | break; |
| 5069 | |
| 5070 | case 260: |
| 5071 | #line 2479 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5072 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5073 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5074 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 5075 | yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
| 5076 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5077 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5078 | ;} |
| 5079 | break; |
| 5080 | |
| 5081 | case 261: |
| 5082 | #line 2488 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5083 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5084 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5085 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5086 | ;} |
| 5087 | break; |
| 5088 | |
| 5089 | case 262: |
| 5090 | #line 2492 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5091 | { // Do not allow functions with 0 basic blocks |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5092 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5093 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5094 | ;} |
| 5095 | break; |
| 5096 | |
| 5097 | case 263: |
| 5098 | #line 2501 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5099 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5100 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5101 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5102 | InsertValue(yyvsp[0].TermInstVal); |
| 5103 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 5104 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5105 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5106 | ;} |
| 5107 | break; |
| 5108 | |
| 5109 | case 264: |
| 5110 | #line 2510 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5111 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5112 | if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5113 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 5114 | if (CI2->getParent() == 0) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5115 | yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2); |
| 5116 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); |
| 5117 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 5118 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5119 | ;} |
| 5120 | break; |
| 5121 | |
| 5122 | case 265: |
| 5123 | #line 2519 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5124 | { // Empty space between instruction lists |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5125 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum)); |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 5126 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5127 | ;} |
| 5128 | break; |
| 5129 | |
| 5130 | case 266: |
| 5131 | #line 2523 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5132 | { // Labelled (named) basic block |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5133 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal)); |
| 5134 | delete yyvsp[0].StrVal; |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 5135 | CHECK_FOR_ERROR |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 5136 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5137 | ;} |
| 5138 | break; |
| 5139 | |
| 5140 | case 267: |
| 5141 | #line 2530 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5142 | { // Return with a result... |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5143 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); |
| 5144 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5145 | ;} |
| 5146 | break; |
| 5147 | |
| 5148 | case 268: |
| 5149 | #line 2534 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5150 | { // Return with no result... |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5151 | yyval.TermInstVal = new ReturnInst(); |
| 5152 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5153 | ;} |
| 5154 | break; |
| 5155 | |
| 5156 | case 269: |
| 5157 | #line 2538 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5158 | { // Unconditional Branch... |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5159 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 5160 | CHECK_FOR_ERROR |
| 5161 | yyval.TermInstVal = new BranchInst(tmpBB); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5162 | ;} |
| 5163 | break; |
| 5164 | |
| 5165 | case 270: |
| 5166 | #line 2543 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5167 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5168 | assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 5169 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 5170 | CHECK_FOR_ERROR |
| 5171 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 5172 | CHECK_FOR_ERROR |
| 5173 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 5174 | CHECK_FOR_ERROR |
| 5175 | yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5176 | ;} |
| 5177 | break; |
| 5178 | |
| 5179 | case 271: |
| 5180 | #line 2553 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5181 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5182 | Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal); |
| 5183 | CHECK_FOR_ERROR |
| 5184 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 5185 | CHECK_FOR_ERROR |
| 5186 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 5187 | yyval.TermInstVal = S; |
Reid Spencer | b8f8505 | 2007-07-31 03:50:36 +0000 | [diff] [blame] | 5188 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5189 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 5190 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5191 | for (; I != E; ++I) { |
| 5192 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 5193 | S->addCase(CI, I->second); |
| 5194 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5195 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5196 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5197 | delete yyvsp[-1].JumpTable; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5198 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5199 | ;} |
| 5200 | break; |
| 5201 | |
| 5202 | case 272: |
| 5203 | #line 2572 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5204 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5205 | Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5206 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5207 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5208 | CHECK_FOR_ERROR |
| 5209 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5210 | yyval.TermInstVal = S; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5211 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5212 | ;} |
| 5213 | break; |
| 5214 | |
| 5215 | case 273: |
| 5216 | #line 2582 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5217 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5218 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5219 | // Handle the short syntax |
| 5220 | const PointerType *PFTy = 0; |
| 5221 | const FunctionType *Ty = 0; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5222 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5223 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5224 | // Pull out the types of all of the arguments... |
| 5225 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5226 | ParamAttrsVector Attrs; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5227 | if (yyvsp[-6].ParamAttrs != ParamAttr::None) { |
| 5228 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5229 | Attrs.push_back(PAWI); |
| 5230 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5231 | ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5232 | unsigned index = 1; |
| 5233 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5234 | const Type *Ty = I->Val->getType(); |
| 5235 | if (Ty == Type::VoidTy) |
| 5236 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5237 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5238 | if (I->Attrs != ParamAttr::None) { |
| 5239 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 5240 | Attrs.push_back(PAWI); |
| 5241 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5242 | } |
| 5243 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5244 | ParamAttrsList *PAL = 0; |
| 5245 | if (!Attrs.empty()) |
| 5246 | PAL = ParamAttrsList::get(Attrs); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5247 | Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5248 | PFTy = PointerType::get(Ty); |
| 5249 | } |
| 5250 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5251 | delete yyvsp[-11].TypeVal; |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 5252 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5253 | 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] | 5254 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5255 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5256 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5257 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5258 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5259 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5260 | // Check the arguments |
| 5261 | ValueList Args; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5262 | if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5263 | // Make sure no arguments is a good thing! |
| 5264 | if (Ty->getNumParams() != 0) |
| 5265 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5266 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5267 | } else { // Has arguments? |
| 5268 | // Loop through FunctionType's arguments and ensure they are specified |
| 5269 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5270 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5271 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5272 | ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5273 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5274 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5275 | if (ArgI->Val->getType() != *I) |
| 5276 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5277 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5278 | Args.push_back(ArgI->Val); |
| 5279 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5280 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5281 | if (Ty->isVarArg()) { |
| 5282 | if (I == E) |
| 5283 | for (; ArgI != ArgE; ++ArgI) |
| 5284 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5285 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5286 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5287 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5288 | |
| 5289 | // Create the InvokeInst |
Chris Lattner | d80fb8b | 2007-08-29 16:15:23 +0000 | [diff] [blame] | 5290 | InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end()); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5291 | II->setCallingConv(yyvsp[-12].UIntVal); |
| 5292 | yyval.TermInstVal = II; |
| 5293 | delete yyvsp[-8].ValueRefList; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5294 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5295 | ;} |
| 5296 | break; |
| 5297 | |
| 5298 | case 274: |
| 5299 | #line 2661 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5300 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5301 | yyval.TermInstVal = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5302 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5303 | ;} |
| 5304 | break; |
| 5305 | |
| 5306 | case 275: |
| 5307 | #line 2665 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5308 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5309 | yyval.TermInstVal = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5310 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5311 | ;} |
| 5312 | break; |
| 5313 | |
| 5314 | case 276: |
| 5315 | #line 2672 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5316 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5317 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 5318 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5319 | CHECK_FOR_ERROR |
| 5320 | if (V == 0) |
| 5321 | GEN_ERROR("May only switch on a constant pool value"); |
| 5322 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5323 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5324 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5325 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5326 | ;} |
| 5327 | break; |
| 5328 | |
| 5329 | case 277: |
| 5330 | #line 2683 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5331 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5332 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 5333 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5334 | CHECK_FOR_ERROR |
| 5335 | |
| 5336 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5337 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5338 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5339 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5340 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5341 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5342 | ;} |
| 5343 | break; |
| 5344 | |
| 5345 | case 278: |
| 5346 | #line 2696 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5347 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5348 | // Is this definition named?? if so, assign the name... |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5349 | setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5350 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5351 | InsertValue(yyvsp[0].InstVal); |
| 5352 | yyval.InstVal = yyvsp[0].InstVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5353 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5354 | ;} |
| 5355 | break; |
| 5356 | |
| 5357 | case 279: |
| 5358 | #line 2706 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5359 | { // Used for PHI nodes |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5360 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5361 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription()); |
| 5362 | yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 5363 | Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5364 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5365 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5366 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5367 | yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5368 | delete yyvsp[-5].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5369 | ;} |
| 5370 | break; |
| 5371 | |
| 5372 | case 280: |
| 5373 | #line 2717 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5374 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5375 | yyval.PHIList = yyvsp[-6].PHIList; |
| 5376 | Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5377 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5378 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5379 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5380 | yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5381 | ;} |
| 5382 | break; |
| 5383 | |
| 5384 | case 281: |
| 5385 | #line 2727 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5386 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5387 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5388 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5389 | // Used for call and invoke instructions |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5390 | yyval.ValueRefList = new ValueRefList(); |
| 5391 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 5392 | yyval.ValueRefList->push_back(E); |
| 5393 | delete yyvsp[-2].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5394 | ;} |
| 5395 | break; |
| 5396 | |
| 5397 | case 282: |
| 5398 | #line 2736 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5399 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5400 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5401 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 5402 | yyval.ValueRefList = yyvsp[-4].ValueRefList; |
| 5403 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 5404 | yyval.ValueRefList->push_back(E); |
| 5405 | delete yyvsp[-2].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5406 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5407 | ;} |
| 5408 | break; |
| 5409 | |
| 5410 | case 283: |
| 5411 | #line 2745 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5412 | { yyval.ValueRefList = new ValueRefList(); ;} |
| 5413 | break; |
| 5414 | |
| 5415 | case 284: |
| 5416 | #line 2748 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5417 | { yyval.ValueList = new std::vector<Value*>(); ;} |
| 5418 | break; |
| 5419 | |
| 5420 | case 285: |
| 5421 | #line 2749 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5422 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5423 | yyval.ValueList = yyvsp[-2].ValueList; |
| 5424 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5425 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5426 | ;} |
| 5427 | break; |
| 5428 | |
| 5429 | case 286: |
| 5430 | #line 2756 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5431 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5432 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5433 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5434 | ;} |
| 5435 | break; |
| 5436 | |
| 5437 | case 287: |
| 5438 | #line 2760 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5439 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5440 | yyval.BoolVal = false; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5441 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5442 | ;} |
| 5443 | break; |
| 5444 | |
| 5445 | case 288: |
| 5446 | #line 2765 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5447 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5448 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5449 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 5450 | if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && |
| 5451 | !isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5452 | GEN_ERROR( |
| 5453 | "Arithmetic operator requires integer, FP, or packed operands"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5454 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) && |
| 5455 | (yyvsp[-4].BinaryOpVal == Instruction::URem || |
| 5456 | yyvsp[-4].BinaryOpVal == Instruction::SRem || |
| 5457 | yyvsp[-4].BinaryOpVal == Instruction::FRem)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5458 | GEN_ERROR("Remainder not supported on vector types"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5459 | Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5460 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5461 | Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5462 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5463 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2); |
| 5464 | if (yyval.InstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5465 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5466 | delete yyvsp[-3].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5467 | ;} |
| 5468 | break; |
| 5469 | |
| 5470 | case 289: |
| 5471 | #line 2786 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5472 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5473 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5474 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 5475 | if (!(*yyvsp[-3].TypeVal)->isInteger()) { |
| 5476 | if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) || |
| 5477 | !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5478 | GEN_ERROR("Logical operator requires integral operands"); |
| 5479 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5480 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5481 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5482 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5483 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5484 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); |
| 5485 | if (yyval.InstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5486 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5487 | delete yyvsp[-3].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5488 | ;} |
| 5489 | break; |
| 5490 | |
| 5491 | case 290: |
| 5492 | #line 2803 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5493 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5494 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5495 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 5496 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5497 | GEN_ERROR("Vector types not supported by icmp instruction"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5498 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5499 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5500 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5501 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5502 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2); |
| 5503 | if (yyval.InstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5504 | GEN_ERROR("icmp operator returned null"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5505 | delete yyvsp[-3].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5506 | ;} |
| 5507 | break; |
| 5508 | |
| 5509 | case 291: |
| 5510 | #line 2817 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5511 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5512 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5513 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 5514 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5515 | GEN_ERROR("Vector types not supported by fcmp instruction"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5516 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5517 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5518 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5519 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5520 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2); |
| 5521 | if (yyval.InstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5522 | GEN_ERROR("fcmp operator returned null"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5523 | delete yyvsp[-3].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5524 | ;} |
| 5525 | break; |
| 5526 | |
| 5527 | case 292: |
| 5528 | #line 2831 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5529 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5530 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5531 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 5532 | Value* Val = yyvsp[-2].ValueVal; |
| 5533 | const Type* DestTy = yyvsp[0].TypeVal->get(); |
| 5534 | if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5535 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 5536 | Val->getType()->getDescription() + "' to '" + |
| 5537 | DestTy->getDescription() + "'"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5538 | yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy); |
| 5539 | delete yyvsp[0].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5540 | ;} |
| 5541 | break; |
| 5542 | |
| 5543 | case 293: |
| 5544 | #line 2843 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5545 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5546 | if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5547 | GEN_ERROR("select condition must be boolean"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5548 | if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5549 | GEN_ERROR("select value types should match"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5550 | 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] | 5551 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5552 | ;} |
| 5553 | break; |
| 5554 | |
| 5555 | case 294: |
| 5556 | #line 2851 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5557 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5558 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5559 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 5560 | yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 5561 | delete yyvsp[0].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5562 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5563 | ;} |
| 5564 | break; |
| 5565 | |
| 5566 | case 295: |
| 5567 | #line 2858 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5568 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5569 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5570 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5571 | yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5572 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5573 | ;} |
| 5574 | break; |
| 5575 | |
| 5576 | case 296: |
| 5577 | #line 2864 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5578 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5579 | if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5580 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5581 | yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5582 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5583 | ;} |
| 5584 | break; |
| 5585 | |
| 5586 | case 297: |
| 5587 | #line 2870 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5588 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5589 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5590 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5591 | yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5592 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5593 | ;} |
| 5594 | break; |
| 5595 | |
| 5596 | case 298: |
| 5597 | #line 2876 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5598 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5599 | const Type *Ty = yyvsp[0].PHIList->front().first->getType(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5600 | if (!Ty->isFirstClassType()) |
| 5601 | GEN_ERROR("PHI node operands must be of first class type"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5602 | yyval.InstVal = new PHINode(Ty); |
| 5603 | ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); |
| 5604 | while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { |
| 5605 | if (yyvsp[0].PHIList->front().first->getType() != Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5606 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5607 | cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); |
| 5608 | yyvsp[0].PHIList->pop_front(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5609 | } |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5610 | delete yyvsp[0].PHIList; // Free the list... |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5611 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5612 | ;} |
| 5613 | break; |
| 5614 | |
| 5615 | case 299: |
| 5616 | #line 2892 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5617 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5618 | |
| 5619 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5620 | const PointerType *PFTy = 0; |
| 5621 | const FunctionType *Ty = 0; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5622 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5623 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5624 | // Pull out the types of all of the arguments... |
| 5625 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5626 | ParamAttrsVector Attrs; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5627 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 5628 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5629 | Attrs.push_back(PAWI); |
| 5630 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5631 | unsigned index = 1; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5632 | ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5633 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5634 | const Type *Ty = I->Val->getType(); |
| 5635 | if (Ty == Type::VoidTy) |
| 5636 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5637 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5638 | if (I->Attrs != ParamAttr::None) { |
| 5639 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 5640 | Attrs.push_back(PAWI); |
| 5641 | } |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5642 | } |
| 5643 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5644 | ParamAttrsList *PAL = 0; |
| 5645 | if (!Attrs.empty()) |
| 5646 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5647 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5648 | Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5649 | PFTy = PointerType::get(Ty); |
| 5650 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5651 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5652 | 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] | 5653 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5654 | |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 5655 | // Check for call to invalid intrinsic to avoid crashing later. |
| 5656 | if (Function *theF = dyn_cast<Function>(V)) { |
Reid Spencer | ed48de2 | 2007-04-16 22:02:23 +0000 | [diff] [blame] | 5657 | if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) && |
Reid Spencer | 36fdde1 | 2007-04-16 20:35:38 +0000 | [diff] [blame] | 5658 | (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) && |
| 5659 | !theF->getIntrinsicID(true)) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 5660 | GEN_ERROR("Call to invalid LLVM intrinsic function '" + |
| 5661 | theF->getName() + "'"); |
| 5662 | } |
| 5663 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5664 | // Check the arguments |
| 5665 | ValueList Args; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5666 | if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5667 | // Make sure no arguments is a good thing! |
| 5668 | if (Ty->getNumParams() != 0) |
| 5669 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5670 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5671 | } else { // Has arguments? |
| 5672 | // Loop through FunctionType's arguments and ensure they are specified |
| 5673 | // correctly! |
| 5674 | // |
| 5675 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5676 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5677 | ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5678 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5679 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5680 | if (ArgI->Val->getType() != *I) |
| 5681 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5682 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5683 | Args.push_back(ArgI->Val); |
| 5684 | } |
| 5685 | if (Ty->isVarArg()) { |
| 5686 | if (I == E) |
| 5687 | for (; ArgI != ArgE; ++ArgI) |
| 5688 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5689 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5690 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5691 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5692 | // Create the call node |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 5693 | CallInst *CI = new CallInst(V, Args.begin(), Args.end()); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5694 | CI->setTailCall(yyvsp[-7].BoolVal); |
| 5695 | CI->setCallingConv(yyvsp[-6].UIntVal); |
| 5696 | yyval.InstVal = CI; |
| 5697 | delete yyvsp[-2].ValueRefList; |
| 5698 | delete yyvsp[-5].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5699 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5700 | ;} |
| 5701 | break; |
| 5702 | |
| 5703 | case 300: |
| 5704 | #line 2976 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5705 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5706 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5707 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5708 | ;} |
| 5709 | break; |
| 5710 | |
| 5711 | case 301: |
| 5712 | #line 2981 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5713 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5714 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5715 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5716 | ;} |
| 5717 | break; |
| 5718 | |
| 5719 | case 302: |
| 5720 | #line 2985 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5721 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5722 | yyval.BoolVal = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5723 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5724 | ;} |
| 5725 | break; |
| 5726 | |
| 5727 | case 303: |
| 5728 | #line 2992 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5729 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5730 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5731 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 5732 | yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 5733 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5734 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5735 | ;} |
| 5736 | break; |
| 5737 | |
| 5738 | case 304: |
| 5739 | #line 2999 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5740 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5741 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5742 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 5743 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5744 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5745 | yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 5746 | delete yyvsp[-4].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5747 | ;} |
| 5748 | break; |
| 5749 | |
| 5750 | case 305: |
| 5751 | #line 3007 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5752 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5753 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5754 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 5755 | yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 5756 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5757 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5758 | ;} |
| 5759 | break; |
| 5760 | |
| 5761 | case 306: |
| 5762 | #line 3014 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5763 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5764 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5765 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 5766 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5767 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5768 | yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 5769 | delete yyvsp[-4].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5770 | ;} |
| 5771 | break; |
| 5772 | |
| 5773 | case 307: |
| 5774 | #line 3022 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5775 | { |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5776 | if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5777 | GEN_ERROR("Trying to free nonpointer type " + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5778 | yyvsp[0].ValueVal->getType()->getDescription() + ""); |
| 5779 | yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5780 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5781 | ;} |
| 5782 | break; |
| 5783 | |
| 5784 | case 308: |
| 5785 | #line 3030 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5786 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5787 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5788 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 5789 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5790 | GEN_ERROR("Can't load from nonpointer type: " + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5791 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 5792 | if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5793 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5794 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 5795 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5796 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5797 | yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal); |
| 5798 | delete yyvsp[-2].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5799 | ;} |
| 5800 | break; |
| 5801 | |
| 5802 | case 309: |
| 5803 | #line 3044 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5804 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5805 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5806 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 5807 | const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5808 | if (!PT) |
| 5809 | GEN_ERROR("Can't store to a nonpointer type: " + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5810 | (*yyvsp[-2].TypeVal)->getDescription()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5811 | const Type *ElTy = PT->getElementType(); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5812 | if (ElTy != yyvsp[-4].ValueVal->getType()) |
| 5813 | GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() + |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5814 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 5815 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5816 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5817 | CHECK_FOR_ERROR |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5818 | yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal); |
| 5819 | delete yyvsp[-2].TypeVal; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5820 | ;} |
| 5821 | break; |
| 5822 | |
| 5823 | case 310: |
| 5824 | #line 3061 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
| 5825 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5826 | if (!UpRefs.empty()) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5827 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 5828 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5829 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5830 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5831 | if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end(), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5832 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5833 | (*yyvsp[-2].TypeVal)->getDescription()+ "'"); |
| 5834 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5835 | CHECK_FOR_ERROR |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5836 | yyval.InstVal = new GetElementPtrInst(tmpVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5837 | delete yyvsp[-2].TypeVal; |
| 5838 | delete yyvsp[0].ValueList; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5839 | ;} |
| 5840 | break; |
| 5841 | |
| 5842 | |
| 5843 | } |
| 5844 | |
| 5845 | /* Line 993 of yacc.c. */ |
| 5846 | #line 5847 "llvmAsmParser.tab.c" |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5847 | |
| 5848 | yyvsp -= yylen; |
| 5849 | yyssp -= yylen; |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 5850 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5851 | |
| 5852 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5853 | |
| 5854 | *++yyvsp = yyval; |
| 5855 | |
| 5856 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5857 | /* Now `shift' the result of the reduction. Determine what state |
| 5858 | that goes to, based on the state we popped back to and the rule |
| 5859 | number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5860 | |
| 5861 | yyn = yyr1[yyn]; |
| 5862 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5863 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 5864 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5865 | yystate = yytable[yystate]; |
| 5866 | else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5867 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5868 | |
| 5869 | goto yynewstate; |
| 5870 | |
| 5871 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5872 | /*------------------------------------. |
| 5873 | | yyerrlab -- here on detecting error | |
| 5874 | `------------------------------------*/ |
| 5875 | yyerrlab: |
| 5876 | /* If not already recovering from an error, report this error. */ |
| 5877 | if (!yyerrstatus) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5878 | { |
| 5879 | ++yynerrs; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5880 | #if YYERROR_VERBOSE |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5881 | yyn = yypact[yystate]; |
| 5882 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5883 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5884 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5885 | YYSIZE_T yysize = 0; |
| 5886 | int yytype = YYTRANSLATE (yychar); |
| 5887 | const char* yyprefix; |
| 5888 | char *yymsg; |
| 5889 | int yyx; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5890 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5891 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 5892 | YYCHECK. */ |
| 5893 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 5894 | |
| 5895 | /* Stay within bounds of both yycheck and yytname. */ |
| 5896 | int yychecklim = YYLAST - yyn; |
| 5897 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 5898 | int yycount = 0; |
| 5899 | |
| 5900 | yyprefix = ", expecting "; |
| 5901 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 5902 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 5903 | { |
| 5904 | yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); |
| 5905 | yycount += 1; |
| 5906 | if (yycount == 5) |
| 5907 | { |
| 5908 | yysize = 0; |
| 5909 | break; |
| 5910 | } |
| 5911 | } |
| 5912 | yysize += (sizeof ("syntax error, unexpected ") |
| 5913 | + yystrlen (yytname[yytype])); |
| 5914 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 5915 | if (yymsg != 0) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5916 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5917 | char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); |
| 5918 | yyp = yystpcpy (yyp, yytname[yytype]); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5919 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5920 | if (yycount < 5) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5921 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5922 | yyprefix = ", expecting "; |
| 5923 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 5924 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5925 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5926 | yyp = yystpcpy (yyp, yyprefix); |
| 5927 | yyp = yystpcpy (yyp, yytname[yyx]); |
| 5928 | yyprefix = " or "; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5929 | } |
| 5930 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5931 | yyerror (yymsg); |
| 5932 | YYSTACK_FREE (yymsg); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5933 | } |
| 5934 | else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5935 | yyerror ("syntax error; also virtual memory exhausted"); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 5936 | } |
| 5937 | else |
| 5938 | #endif /* YYERROR_VERBOSE */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5939 | yyerror ("syntax error"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5940 | } |
| 5941 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5942 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5943 | |
| 5944 | if (yyerrstatus == 3) |
| 5945 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5946 | /* If just tried and failed to reuse lookahead token after an |
| 5947 | error, discard it. */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5948 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5949 | if (yychar <= YYEOF) |
| 5950 | { |
| 5951 | /* If at end of input, pop the error token, |
| 5952 | then the rest of the stack, then return failure. */ |
| 5953 | if (yychar == YYEOF) |
| 5954 | for (;;) |
| 5955 | { |
| 5956 | YYPOPSTACK; |
| 5957 | if (yyssp == yyss) |
| 5958 | YYABORT; |
| 5959 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); |
| 5960 | yydestruct (yystos[*yyssp], yyvsp); |
| 5961 | } |
| 5962 | } |
| 5963 | else |
| 5964 | { |
| 5965 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); |
| 5966 | yydestruct (yytoken, &yylval); |
| 5967 | yychar = YYEMPTY; |
| 5968 | |
| 5969 | } |
| 5970 | } |
| 5971 | |
| 5972 | /* Else will try to reuse lookahead token after shifting the error |
| 5973 | token. */ |
| 5974 | goto yyerrlab1; |
| 5975 | |
| 5976 | |
| 5977 | /*---------------------------------------------------. |
| 5978 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 5979 | `---------------------------------------------------*/ |
| 5980 | yyerrorlab: |
| 5981 | |
| 5982 | #ifdef __GNUC__ |
| 5983 | /* Pacify GCC when the user code never invokes YYERROR and the label |
| 5984 | yyerrorlab therefore never appears in user code. */ |
| 5985 | if (0) |
| 5986 | goto yyerrorlab; |
| 5987 | #endif |
| 5988 | |
| 5989 | yyvsp -= yylen; |
| 5990 | yyssp -= yylen; |
| 5991 | yystate = *yyssp; |
| 5992 | goto yyerrlab1; |
| 5993 | |
| 5994 | |
| 5995 | /*-------------------------------------------------------------. |
| 5996 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 5997 | `-------------------------------------------------------------*/ |
| 5998 | yyerrlab1: |
| 5999 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 6000 | |
| 6001 | for (;;) |
| 6002 | { |
| 6003 | yyn = yypact[yystate]; |
| 6004 | if (yyn != YYPACT_NINF) |
| 6005 | { |
| 6006 | yyn += YYTERROR; |
| 6007 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 6008 | { |
| 6009 | yyn = yytable[yyn]; |
| 6010 | if (0 < yyn) |
| 6011 | break; |
| 6012 | } |
| 6013 | } |
| 6014 | |
| 6015 | /* Pop the current state because it cannot handle the error token. */ |
| 6016 | if (yyssp == yyss) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6017 | YYABORT; |
| 6018 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 6019 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); |
| 6020 | yydestruct (yystos[yystate], yyvsp); |
| 6021 | YYPOPSTACK; |
| 6022 | yystate = *yyssp; |
| 6023 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6024 | } |
| 6025 | |
| 6026 | if (yyn == YYFINAL) |
| 6027 | YYACCEPT; |
| 6028 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 6029 | YYDPRINTF ((stderr, "Shifting error token, ")); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 6030 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6031 | *++yyvsp = yylval; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 6032 | |
Reid Spencer | b8f8505 | 2007-07-31 03:50:36 +0000 | [diff] [blame] | 6033 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6034 | yystate = yyn; |
| 6035 | goto yynewstate; |
| 6036 | |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 6037 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 6038 | /*-------------------------------------. |
| 6039 | | yyacceptlab -- YYACCEPT comes here. | |
| 6040 | `-------------------------------------*/ |
| 6041 | yyacceptlab: |
| 6042 | yyresult = 0; |
| 6043 | goto yyreturn; |
| 6044 | |
| 6045 | /*-----------------------------------. |
| 6046 | | yyabortlab -- YYABORT comes here. | |
| 6047 | `-----------------------------------*/ |
| 6048 | yyabortlab: |
| 6049 | yyresult = 1; |
| 6050 | goto yyreturn; |
| 6051 | |
| 6052 | #ifndef yyoverflow |
| 6053 | /*----------------------------------------------. |
| 6054 | | yyoverflowlab -- parser overflow comes here. | |
| 6055 | `----------------------------------------------*/ |
| 6056 | yyoverflowlab: |
| 6057 | yyerror ("parser stack overflow"); |
| 6058 | yyresult = 2; |
| 6059 | /* Fall through. */ |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 6060 | #endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 6061 | |
| 6062 | yyreturn: |
| 6063 | #ifndef yyoverflow |
| 6064 | if (yyss != yyssa) |
| 6065 | YYSTACK_FREE (yyss); |
| 6066 | #endif |
| 6067 | return yyresult; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6068 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 6069 | |
| 6070 | |
| 6071 | #line 3078 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6072 | |
| 6073 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6074 | // common code from the two 'RunVMAsmParser' functions |
| 6075 | static Module* RunParser(Module * M) { |
| 6076 | |
| 6077 | llvmAsmlineno = 1; // Reset the current line number... |
| 6078 | CurModule.CurrentModule = M; |
| 6079 | #if YYDEBUG |
| 6080 | yydebug = Debug; |
| 6081 | #endif |
| 6082 | |
| 6083 | // Check to make sure the parser succeeded |
| 6084 | if (yyparse()) { |
| 6085 | if (ParserResult) |
| 6086 | delete ParserResult; |
| 6087 | return 0; |
| 6088 | } |
| 6089 | |
Reid Spencer | 0d60b5a | 2007-03-30 01:37:39 +0000 | [diff] [blame] | 6090 | // Emit an error if there are any unresolved types left. |
| 6091 | if (!CurModule.LateResolveTypes.empty()) { |
| 6092 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 6093 | if (DID.Type == ValID::LocalName) { |
| 6094 | GenerateError("Undefined type remains at eof: '"+DID.getName() + "'"); |
| 6095 | } else { |
| 6096 | GenerateError("Undefined type remains at eof: #" + itostr(DID.Num)); |
| 6097 | } |
| 6098 | if (ParserResult) |
| 6099 | delete ParserResult; |
| 6100 | return 0; |
| 6101 | } |
| 6102 | |
| 6103 | // Emit an error if there are any unresolved values left. |
| 6104 | if (!CurModule.LateResolveValues.empty()) { |
| 6105 | Value *V = CurModule.LateResolveValues.back(); |
| 6106 | std::map<Value*, std::pair<ValID, int> >::iterator I = |
| 6107 | CurModule.PlaceHolderInfo.find(V); |
| 6108 | |
| 6109 | if (I != CurModule.PlaceHolderInfo.end()) { |
| 6110 | ValID &DID = I->second.first; |
| 6111 | if (DID.Type == ValID::LocalName) { |
| 6112 | GenerateError("Undefined value remains at eof: "+DID.getName() + "'"); |
| 6113 | } else { |
| 6114 | GenerateError("Undefined value remains at eof: #" + itostr(DID.Num)); |
| 6115 | } |
| 6116 | if (ParserResult) |
| 6117 | delete ParserResult; |
| 6118 | return 0; |
| 6119 | } |
| 6120 | } |
| 6121 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6122 | // Check to make sure that parsing produced a result |
| 6123 | if (!ParserResult) |
| 6124 | return 0; |
| 6125 | |
| 6126 | // Reset ParserResult variable while saving its value for the result. |
| 6127 | Module *Result = ParserResult; |
| 6128 | ParserResult = 0; |
| 6129 | |
| 6130 | return Result; |
| 6131 | } |
| 6132 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6133 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 6134 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 6135 | // TODO: column number in exception |
| 6136 | if (TheParseError) |
| 6137 | TheParseError->setError(CurFilename, message, LineNo); |
| 6138 | TriggerError = 1; |
| 6139 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6140 | |
| 6141 | int yyerror(const char *ErrorMsg) { |
| 6142 | std::string where |
| 6143 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 6144 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 6145 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 6146 | if (yychar != YYEMPTY && yychar != 0) |
| 6147 | errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+ |
| 6148 | "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6149 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6150 | return 0; |
| 6151 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 6152 | |