Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 1 | /* A Bison parser, made by GNU Bison 2.3. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3 | /* Skeleton implementation for Bison's Yacc-like parsers in C |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 |
| 6 | Free Software Foundation, Inc. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 7 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2, or (at your option) |
| 11 | any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 | Boston, MA 02110-1301, USA. */ |
| 22 | |
| 23 | /* As a special exception, you may create a larger work that contains |
| 24 | part or all of the Bison parser skeleton and distribute that work |
| 25 | under terms of your choice, so long as that work isn't itself a |
| 26 | parser generator using the skeleton or a modified version thereof |
| 27 | as a parser skeleton. Alternatively, if you modify or redistribute |
| 28 | the parser skeleton itself, you may (at your option) remove this |
| 29 | special exception, which will cause the skeleton and the resulting |
| 30 | Bison output files to be licensed under the GNU General Public |
| 31 | License without this special exception. |
| 32 | |
| 33 | This special exception was added by the Free Software Foundation in |
| 34 | version 2.2 of Bison. */ |
| 35 | |
| 36 | /* C LALR(1) parser skeleton written by Richard Stallman, by |
| 37 | simplifying the original so-called "semantic" parser. */ |
| 38 | |
| 39 | /* All symbols defined below should begin with yy or YY, to avoid |
| 40 | infringing on user name space. This should be done even for local |
| 41 | variables, as they might otherwise be expanded by user macros. |
| 42 | There are some unavoidable exceptions within include files to |
| 43 | define necessary library symbols; they are noted "INFRINGES ON |
| 44 | USER NAME SPACE" below. */ |
| 45 | |
| 46 | /* Identify Bison output. */ |
| 47 | #define YYBISON 1 |
| 48 | |
| 49 | /* Bison version. */ |
| 50 | #define YYBISON_VERSION "2.3" |
| 51 | |
| 52 | /* Skeleton name. */ |
| 53 | #define YYSKELETON_NAME "yacc.c" |
| 54 | |
| 55 | /* Pure parsers. */ |
| 56 | #define YYPURE 0 |
| 57 | |
| 58 | /* Using locations. */ |
| 59 | #define YYLSP_NEEDED 0 |
| 60 | |
| 61 | /* Substitute the variable and function names. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 62 | #define yyparse Upgradeparse |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 63 | #define yylex Upgradelex |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 64 | #define yyerror Upgradeerror |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 65 | #define yylval Upgradelval |
| 66 | #define yychar Upgradechar |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 67 | #define yydebug Upgradedebug |
| 68 | #define yynerrs Upgradenerrs |
| 69 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 70 | |
| 71 | /* Tokens. */ |
| 72 | #ifndef YYTOKENTYPE |
| 73 | # define YYTOKENTYPE |
| 74 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 75 | know about them. */ |
| 76 | enum yytokentype { |
| 77 | ESINT64VAL = 258, |
| 78 | EUINT64VAL = 259, |
| 79 | SINTVAL = 260, |
| 80 | UINTVAL = 261, |
| 81 | FPVAL = 262, |
| 82 | VOID = 263, |
| 83 | BOOL = 264, |
| 84 | SBYTE = 265, |
| 85 | UBYTE = 266, |
| 86 | SHORT = 267, |
| 87 | USHORT = 268, |
| 88 | INT = 269, |
| 89 | UINT = 270, |
| 90 | LONG = 271, |
| 91 | ULONG = 272, |
| 92 | FLOAT = 273, |
| 93 | DOUBLE = 274, |
| 94 | TYPE = 275, |
| 95 | LABEL = 276, |
| 96 | VAR_ID = 277, |
| 97 | LABELSTR = 278, |
| 98 | STRINGCONSTANT = 279, |
| 99 | IMPLEMENTATION = 280, |
| 100 | ZEROINITIALIZER = 281, |
| 101 | TRUETOK = 282, |
| 102 | FALSETOK = 283, |
| 103 | BEGINTOK = 284, |
| 104 | ENDTOK = 285, |
| 105 | DECLARE = 286, |
| 106 | GLOBAL = 287, |
| 107 | CONSTANT = 288, |
| 108 | SECTION = 289, |
| 109 | VOLATILE = 290, |
| 110 | TO = 291, |
| 111 | DOTDOTDOT = 292, |
| 112 | NULL_TOK = 293, |
| 113 | UNDEF = 294, |
| 114 | CONST = 295, |
| 115 | INTERNAL = 296, |
| 116 | LINKONCE = 297, |
| 117 | WEAK = 298, |
| 118 | APPENDING = 299, |
| 119 | DLLIMPORT = 300, |
| 120 | DLLEXPORT = 301, |
| 121 | EXTERN_WEAK = 302, |
| 122 | OPAQUE = 303, |
| 123 | NOT = 304, |
| 124 | EXTERNAL = 305, |
| 125 | TARGET = 306, |
| 126 | TRIPLE = 307, |
| 127 | ENDIAN = 308, |
| 128 | POINTERSIZE = 309, |
| 129 | LITTLE = 310, |
| 130 | BIG = 311, |
| 131 | ALIGN = 312, |
| 132 | DEPLIBS = 313, |
| 133 | CALL = 314, |
| 134 | TAIL = 315, |
| 135 | ASM_TOK = 316, |
| 136 | MODULE = 317, |
| 137 | SIDEEFFECT = 318, |
| 138 | CC_TOK = 319, |
| 139 | CCC_TOK = 320, |
| 140 | CSRETCC_TOK = 321, |
| 141 | FASTCC_TOK = 322, |
| 142 | COLDCC_TOK = 323, |
| 143 | X86_STDCALLCC_TOK = 324, |
| 144 | X86_FASTCALLCC_TOK = 325, |
| 145 | DATALAYOUT = 326, |
| 146 | RET = 327, |
| 147 | BR = 328, |
| 148 | SWITCH = 329, |
| 149 | INVOKE = 330, |
| 150 | UNREACHABLE = 331, |
| 151 | UNWIND = 332, |
| 152 | EXCEPT = 333, |
| 153 | ADD = 334, |
| 154 | SUB = 335, |
| 155 | MUL = 336, |
| 156 | DIV = 337, |
| 157 | UDIV = 338, |
| 158 | SDIV = 339, |
| 159 | FDIV = 340, |
| 160 | REM = 341, |
| 161 | UREM = 342, |
| 162 | SREM = 343, |
| 163 | FREM = 344, |
| 164 | AND = 345, |
| 165 | OR = 346, |
| 166 | XOR = 347, |
| 167 | SHL = 348, |
| 168 | SHR = 349, |
| 169 | ASHR = 350, |
| 170 | LSHR = 351, |
| 171 | SETLE = 352, |
| 172 | SETGE = 353, |
| 173 | SETLT = 354, |
| 174 | SETGT = 355, |
| 175 | SETEQ = 356, |
| 176 | SETNE = 357, |
| 177 | ICMP = 358, |
| 178 | FCMP = 359, |
| 179 | MALLOC = 360, |
| 180 | ALLOCA = 361, |
| 181 | FREE = 362, |
| 182 | LOAD = 363, |
| 183 | STORE = 364, |
| 184 | GETELEMENTPTR = 365, |
| 185 | PHI_TOK = 366, |
| 186 | SELECT = 367, |
| 187 | VAARG = 368, |
| 188 | EXTRACTELEMENT = 369, |
| 189 | INSERTELEMENT = 370, |
| 190 | SHUFFLEVECTOR = 371, |
| 191 | VAARG_old = 372, |
| 192 | VANEXT_old = 373, |
| 193 | EQ = 374, |
| 194 | NE = 375, |
| 195 | SLT = 376, |
| 196 | SGT = 377, |
| 197 | SLE = 378, |
| 198 | SGE = 379, |
| 199 | ULT = 380, |
| 200 | UGT = 381, |
| 201 | ULE = 382, |
| 202 | UGE = 383, |
| 203 | OEQ = 384, |
| 204 | ONE = 385, |
| 205 | OLT = 386, |
| 206 | OGT = 387, |
| 207 | OLE = 388, |
| 208 | OGE = 389, |
| 209 | ORD = 390, |
| 210 | UNO = 391, |
| 211 | UEQ = 392, |
| 212 | UNE = 393, |
| 213 | CAST = 394, |
| 214 | TRUNC = 395, |
| 215 | ZEXT = 396, |
| 216 | SEXT = 397, |
| 217 | FPTRUNC = 398, |
| 218 | FPEXT = 399, |
| 219 | FPTOUI = 400, |
| 220 | FPTOSI = 401, |
| 221 | UITOFP = 402, |
| 222 | SITOFP = 403, |
| 223 | PTRTOINT = 404, |
| 224 | INTTOPTR = 405, |
| 225 | BITCAST = 406 |
| 226 | }; |
| 227 | #endif |
| 228 | /* Tokens. */ |
| 229 | #define ESINT64VAL 258 |
| 230 | #define EUINT64VAL 259 |
| 231 | #define SINTVAL 260 |
| 232 | #define UINTVAL 261 |
| 233 | #define FPVAL 262 |
| 234 | #define VOID 263 |
| 235 | #define BOOL 264 |
| 236 | #define SBYTE 265 |
| 237 | #define UBYTE 266 |
| 238 | #define SHORT 267 |
| 239 | #define USHORT 268 |
| 240 | #define INT 269 |
| 241 | #define UINT 270 |
| 242 | #define LONG 271 |
| 243 | #define ULONG 272 |
| 244 | #define FLOAT 273 |
| 245 | #define DOUBLE 274 |
| 246 | #define TYPE 275 |
| 247 | #define LABEL 276 |
| 248 | #define VAR_ID 277 |
| 249 | #define LABELSTR 278 |
| 250 | #define STRINGCONSTANT 279 |
| 251 | #define IMPLEMENTATION 280 |
| 252 | #define ZEROINITIALIZER 281 |
| 253 | #define TRUETOK 282 |
| 254 | #define FALSETOK 283 |
| 255 | #define BEGINTOK 284 |
| 256 | #define ENDTOK 285 |
| 257 | #define DECLARE 286 |
| 258 | #define GLOBAL 287 |
| 259 | #define CONSTANT 288 |
| 260 | #define SECTION 289 |
| 261 | #define VOLATILE 290 |
| 262 | #define TO 291 |
| 263 | #define DOTDOTDOT 292 |
| 264 | #define NULL_TOK 293 |
| 265 | #define UNDEF 294 |
| 266 | #define CONST 295 |
| 267 | #define INTERNAL 296 |
| 268 | #define LINKONCE 297 |
| 269 | #define WEAK 298 |
| 270 | #define APPENDING 299 |
| 271 | #define DLLIMPORT 300 |
| 272 | #define DLLEXPORT 301 |
| 273 | #define EXTERN_WEAK 302 |
| 274 | #define OPAQUE 303 |
| 275 | #define NOT 304 |
| 276 | #define EXTERNAL 305 |
| 277 | #define TARGET 306 |
| 278 | #define TRIPLE 307 |
| 279 | #define ENDIAN 308 |
| 280 | #define POINTERSIZE 309 |
| 281 | #define LITTLE 310 |
| 282 | #define BIG 311 |
| 283 | #define ALIGN 312 |
| 284 | #define DEPLIBS 313 |
| 285 | #define CALL 314 |
| 286 | #define TAIL 315 |
| 287 | #define ASM_TOK 316 |
| 288 | #define MODULE 317 |
| 289 | #define SIDEEFFECT 318 |
| 290 | #define CC_TOK 319 |
| 291 | #define CCC_TOK 320 |
| 292 | #define CSRETCC_TOK 321 |
| 293 | #define FASTCC_TOK 322 |
| 294 | #define COLDCC_TOK 323 |
| 295 | #define X86_STDCALLCC_TOK 324 |
| 296 | #define X86_FASTCALLCC_TOK 325 |
| 297 | #define DATALAYOUT 326 |
| 298 | #define RET 327 |
| 299 | #define BR 328 |
| 300 | #define SWITCH 329 |
| 301 | #define INVOKE 330 |
| 302 | #define UNREACHABLE 331 |
| 303 | #define UNWIND 332 |
| 304 | #define EXCEPT 333 |
| 305 | #define ADD 334 |
| 306 | #define SUB 335 |
| 307 | #define MUL 336 |
| 308 | #define DIV 337 |
| 309 | #define UDIV 338 |
| 310 | #define SDIV 339 |
| 311 | #define FDIV 340 |
| 312 | #define REM 341 |
| 313 | #define UREM 342 |
| 314 | #define SREM 343 |
| 315 | #define FREM 344 |
| 316 | #define AND 345 |
| 317 | #define OR 346 |
| 318 | #define XOR 347 |
| 319 | #define SHL 348 |
| 320 | #define SHR 349 |
| 321 | #define ASHR 350 |
| 322 | #define LSHR 351 |
| 323 | #define SETLE 352 |
| 324 | #define SETGE 353 |
| 325 | #define SETLT 354 |
| 326 | #define SETGT 355 |
| 327 | #define SETEQ 356 |
| 328 | #define SETNE 357 |
| 329 | #define ICMP 358 |
| 330 | #define FCMP 359 |
| 331 | #define MALLOC 360 |
| 332 | #define ALLOCA 361 |
| 333 | #define FREE 362 |
| 334 | #define LOAD 363 |
| 335 | #define STORE 364 |
| 336 | #define GETELEMENTPTR 365 |
| 337 | #define PHI_TOK 366 |
| 338 | #define SELECT 367 |
| 339 | #define VAARG 368 |
| 340 | #define EXTRACTELEMENT 369 |
| 341 | #define INSERTELEMENT 370 |
| 342 | #define SHUFFLEVECTOR 371 |
| 343 | #define VAARG_old 372 |
| 344 | #define VANEXT_old 373 |
| 345 | #define EQ 374 |
| 346 | #define NE 375 |
| 347 | #define SLT 376 |
| 348 | #define SGT 377 |
| 349 | #define SLE 378 |
| 350 | #define SGE 379 |
| 351 | #define ULT 380 |
| 352 | #define UGT 381 |
| 353 | #define ULE 382 |
| 354 | #define UGE 383 |
| 355 | #define OEQ 384 |
| 356 | #define ONE 385 |
| 357 | #define OLT 386 |
| 358 | #define OGT 387 |
| 359 | #define OLE 388 |
| 360 | #define OGE 389 |
| 361 | #define ORD 390 |
| 362 | #define UNO 391 |
| 363 | #define UEQ 392 |
| 364 | #define UNE 393 |
| 365 | #define CAST 394 |
| 366 | #define TRUNC 395 |
| 367 | #define ZEXT 396 |
| 368 | #define SEXT 397 |
| 369 | #define FPTRUNC 398 |
| 370 | #define FPEXT 399 |
| 371 | #define FPTOUI 400 |
| 372 | #define FPTOSI 401 |
| 373 | #define UITOFP 402 |
| 374 | #define SITOFP 403 |
| 375 | #define PTRTOINT 404 |
| 376 | #define INTTOPTR 405 |
| 377 | #define BITCAST 406 |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | /* Copy the first part of user declarations. */ |
| 383 | #line 14 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 384 | |
| 385 | #include "UpgradeInternals.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 386 | #include "llvm/CallingConv.h" |
| 387 | #include "llvm/InlineAsm.h" |
| 388 | #include "llvm/Instructions.h" |
| 389 | #include "llvm/Module.h" |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 390 | #include "llvm/ParameterAttributes.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 391 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 392 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 393 | #include "llvm/ADT/STLExtras.h" |
| 394 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 395 | #include <algorithm> |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 396 | #include <iostream> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 397 | #include <map> |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 398 | #include <list> |
| 399 | #include <utility> |
| 400 | |
| 401 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 402 | // relating to upreferences in the input stream. |
| 403 | // |
| 404 | //#define DEBUG_UPREFS 1 |
| 405 | #ifdef DEBUG_UPREFS |
| 406 | #define UR_OUT(X) std::cerr << X |
| 407 | #else |
| 408 | #define UR_OUT(X) |
| 409 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 410 | |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 411 | #define YYERROR_VERBOSE 1 |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 412 | #define YYINCLUDED_STDLIB_H |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 413 | #define YYDEBUG 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 414 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 415 | int yylex(); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 416 | int yyparse(); |
| 417 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 418 | int yyerror(const char*); |
| 419 | static void warning(const std::string& WarningMsg); |
| 420 | |
| 421 | namespace llvm { |
| 422 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 423 | std::istream* LexInput; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 424 | static std::string CurFilename; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 425 | |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 426 | // This bool controls whether attributes are ever added to function declarations |
| 427 | // definitions and calls. |
| 428 | static bool AddAttributes = false; |
| 429 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 430 | static Module *ParserResult; |
| 431 | static bool ObsoleteVarArgs; |
| 432 | static bool NewVarArgs; |
| 433 | static BasicBlock *CurBB; |
| 434 | static GlobalVariable *CurGV; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 435 | static unsigned lastCallingConv; |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 436 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 437 | // This contains info used when building the body of a function. It is |
| 438 | // destroyed when the function is completed. |
| 439 | // |
| 440 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 441 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 442 | typedef std::pair<std::string,TypeInfo> RenameMapKey; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 443 | typedef std::map<RenameMapKey,std::string> RenameMapType; |
| 444 | |
| 445 | static void |
| 446 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 447 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 448 | |
| 449 | static struct PerModuleInfo { |
| 450 | Module *CurrentModule; |
| 451 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 452 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 453 | std::vector<PATypeHolder> Types; |
| 454 | std::vector<Signedness> TypeSigns; |
| 455 | std::map<std::string,Signedness> NamedTypeSigns; |
| 456 | std::map<std::string,Signedness> NamedValueSigns; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 457 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 458 | static Module::Endianness Endian; |
| 459 | static Module::PointerSize PointerSize; |
| 460 | RenameMapType RenameMap; |
| 461 | |
| 462 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
| 463 | /// how they were referenced and on which line of the input they came from so |
| 464 | /// that we can resolve them later and print error messages as appropriate. |
| 465 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 466 | |
| 467 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 468 | // references to global values. Global values may be referenced before they |
| 469 | // are defined, and if so, the temporary object that they represent is held |
| 470 | // here. This is used for forward references of GlobalValues. |
| 471 | // |
| 472 | typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*> |
| 473 | GlobalRefsType; |
| 474 | GlobalRefsType GlobalRefs; |
| 475 | |
| 476 | void ModuleDone() { |
| 477 | // If we could not resolve some functions at function compilation time |
| 478 | // (calls to functions before they are defined), resolve them now... Types |
| 479 | // are resolved when the constant pool has been completely parsed. |
| 480 | // |
| 481 | ResolveDefinitions(LateResolveValues); |
| 482 | |
| 483 | // Check to make sure that all global value forward references have been |
| 484 | // resolved! |
| 485 | // |
| 486 | if (!GlobalRefs.empty()) { |
| 487 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 488 | |
| 489 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 490 | I != E; ++I) { |
| 491 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 492 | I->first.second.getName() + "\n"; |
| 493 | } |
| 494 | error(UndefinedReferences); |
| 495 | return; |
| 496 | } |
| 497 | |
| 498 | if (CurrentModule->getDataLayout().empty()) { |
| 499 | std::string dataLayout; |
| 500 | if (Endian != Module::AnyEndianness) |
| 501 | dataLayout.append(Endian == Module::BigEndian ? "E" : "e"); |
| 502 | if (PointerSize != Module::AnyPointerSize) { |
| 503 | if (!dataLayout.empty()) |
| 504 | dataLayout += "-"; |
| 505 | dataLayout.append(PointerSize == Module::Pointer64 ? |
| 506 | "p:64:64" : "p:32:32"); |
| 507 | } |
| 508 | CurrentModule->setDataLayout(dataLayout); |
| 509 | } |
| 510 | |
| 511 | Values.clear(); // Clear out function local definitions |
| 512 | Types.clear(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 513 | TypeSigns.clear(); |
| 514 | NamedTypeSigns.clear(); |
| 515 | NamedValueSigns.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 516 | CurrentModule = 0; |
| 517 | } |
| 518 | |
| 519 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 520 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 521 | // If not, just return null. |
| 522 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 523 | // Check to see if there is a forward reference to this global variable... |
| 524 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 525 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 526 | GlobalValue *Ret = 0; |
| 527 | if (I != GlobalRefs.end()) { |
| 528 | Ret = I->second; |
| 529 | GlobalRefs.erase(I); |
| 530 | } |
| 531 | return Ret; |
| 532 | } |
| 533 | void setEndianness(Module::Endianness E) { Endian = E; } |
| 534 | void setPointerSize(Module::PointerSize sz) { PointerSize = sz; } |
| 535 | } CurModule; |
| 536 | |
| 537 | Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness; |
| 538 | Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize; |
| 539 | |
| 540 | static struct PerFunctionInfo { |
| 541 | Function *CurrentFunction; // Pointer to current function being created |
| 542 | |
| 543 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
| 544 | std::map<const Type*, ValueList> LateResolveValues; |
| 545 | bool isDeclare; // Is this function a forward declararation? |
| 546 | GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration. |
| 547 | |
| 548 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 549 | /// track of them here. |
| 550 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 551 | std::vector<BasicBlock*> NumberedBlocks; |
| 552 | RenameMapType RenameMap; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 553 | unsigned NextBBNum; |
| 554 | |
| 555 | inline PerFunctionInfo() { |
| 556 | CurrentFunction = 0; |
| 557 | isDeclare = false; |
| 558 | Linkage = GlobalValue::ExternalLinkage; |
| 559 | } |
| 560 | |
| 561 | inline void FunctionStart(Function *M) { |
| 562 | CurrentFunction = M; |
| 563 | NextBBNum = 0; |
| 564 | } |
| 565 | |
| 566 | void FunctionDone() { |
| 567 | NumberedBlocks.clear(); |
| 568 | |
| 569 | // Any forward referenced blocks left? |
| 570 | if (!BBForwardRefs.empty()) { |
| 571 | error("Undefined reference to label " + |
| 572 | BBForwardRefs.begin()->first->getName()); |
| 573 | return; |
| 574 | } |
| 575 | |
| 576 | // Resolve all forward references now. |
| 577 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 578 | |
| 579 | Values.clear(); // Clear out function local definitions |
| 580 | RenameMap.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 581 | CurrentFunction = 0; |
| 582 | isDeclare = false; |
| 583 | Linkage = GlobalValue::ExternalLinkage; |
| 584 | } |
| 585 | } CurFun; // Info for the current function... |
| 586 | |
| 587 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 588 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 589 | /// This function is just a utility to make a Key value for the rename map. |
| 590 | /// The Key is a combination of the name, type, Signedness of the original |
| 591 | /// value (global/function). This just constructs the key and ensures that |
| 592 | /// named Signedness values are resolved to the actual Signedness. |
| 593 | /// @brief Make a key for the RenameMaps |
| 594 | static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty, |
| 595 | const Signedness &Sign) { |
| 596 | TypeInfo TI; |
| 597 | TI.T = Ty; |
| 598 | if (Sign.isNamed()) |
| 599 | // Don't allow Named Signedness nodes because they won't match. The actual |
| 600 | // Signedness must be looked up in the NamedTypeSigns map. |
| 601 | TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]); |
| 602 | else |
| 603 | TI.S.copy(Sign); |
| 604 | return std::make_pair(Name, TI); |
| 605 | } |
| 606 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 607 | |
| 608 | //===----------------------------------------------------------------------===// |
| 609 | // Code to handle definitions of all the types |
| 610 | //===----------------------------------------------------------------------===// |
| 611 | |
| 612 | static int InsertValue(Value *V, |
| 613 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 614 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 615 | |
| 616 | // Yes, insert the value into the value table... |
| 617 | ValueList &List = ValueTab[V->getType()]; |
| 618 | List.push_back(V); |
| 619 | return List.size()-1; |
| 620 | } |
| 621 | |
Reid Spencer | d7c4f8c | 2007-01-26 19:59:25 +0000 | [diff] [blame] | 622 | static const Type *getType(const ValID &D, bool DoNotImprovise = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 623 | switch (D.Type) { |
| 624 | case ValID::NumberVal: // Is it a numbered definition? |
| 625 | // Module constants occupy the lowest numbered slots... |
| 626 | if ((unsigned)D.Num < CurModule.Types.size()) { |
| 627 | return CurModule.Types[(unsigned)D.Num]; |
| 628 | } |
| 629 | break; |
| 630 | case ValID::NameVal: // Is it a named definition? |
| 631 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 632 | return N; |
| 633 | } |
| 634 | break; |
| 635 | default: |
| 636 | error("Internal parser error: Invalid symbol type reference"); |
| 637 | return 0; |
| 638 | } |
| 639 | |
| 640 | // If we reached here, we referenced either a symbol that we don't know about |
| 641 | // or an id number that hasn't been read yet. We may be referencing something |
| 642 | // forward, so just create an entry to be resolved later and get to it... |
| 643 | // |
| 644 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 645 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 646 | if (inFunctionScope()) { |
| 647 | if (D.Type == ValID::NameVal) { |
| 648 | error("Reference to an undefined type: '" + D.getName() + "'"); |
| 649 | return 0; |
| 650 | } else { |
| 651 | error("Reference to an undefined type: #" + itostr(D.Num)); |
| 652 | return 0; |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 657 | if (I != CurModule.LateResolveTypes.end()) |
| 658 | return I->second; |
| 659 | |
| 660 | Type *Typ = OpaqueType::get(); |
| 661 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 662 | return Typ; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | /// This is like the getType method except that instead of looking up the type |
| 666 | /// for a given ID, it looks up that type's sign. |
| 667 | /// @brief Get the signedness of a referenced type |
| 668 | static Signedness getTypeSign(const ValID &D) { |
| 669 | switch (D.Type) { |
| 670 | case ValID::NumberVal: // Is it a numbered definition? |
| 671 | // Module constants occupy the lowest numbered slots... |
| 672 | if ((unsigned)D.Num < CurModule.TypeSigns.size()) { |
| 673 | return CurModule.TypeSigns[(unsigned)D.Num]; |
| 674 | } |
| 675 | break; |
| 676 | case ValID::NameVal: { // Is it a named definition? |
| 677 | std::map<std::string,Signedness>::const_iterator I = |
| 678 | CurModule.NamedTypeSigns.find(D.Name); |
| 679 | if (I != CurModule.NamedTypeSigns.end()) |
| 680 | return I->second; |
| 681 | // Perhaps its a named forward .. just cache the name |
| 682 | Signedness S; |
| 683 | S.makeNamed(D.Name); |
| 684 | return S; |
| 685 | } |
| 686 | default: |
| 687 | break; |
| 688 | } |
| 689 | // If we don't find it, its signless |
| 690 | Signedness S; |
| 691 | S.makeSignless(); |
| 692 | return S; |
| 693 | } |
| 694 | |
| 695 | /// This function is analagous to getElementType in LLVM. It provides the same |
| 696 | /// function except that it looks up the Signedness instead of the type. This is |
| 697 | /// used when processing GEP instructions that need to extract the type of an |
| 698 | /// indexed struct/array/ptr member. |
| 699 | /// @brief Look up an element's sign. |
| 700 | static Signedness getElementSign(const ValueInfo& VI, |
| 701 | const std::vector<Value*> &Indices) { |
| 702 | const Type *Ptr = VI.V->getType(); |
| 703 | assert(isa<PointerType>(Ptr) && "Need pointer type"); |
| 704 | |
| 705 | unsigned CurIdx = 0; |
| 706 | Signedness S(VI.S); |
| 707 | while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) { |
| 708 | if (CurIdx == Indices.size()) |
| 709 | break; |
| 710 | |
| 711 | Value *Index = Indices[CurIdx++]; |
| 712 | assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type"); |
| 713 | Ptr = CT->getTypeAtIndex(Index); |
| 714 | if (const Type* Ty = Ptr->getForwardedType()) |
| 715 | Ptr = Ty; |
| 716 | assert(S.isComposite() && "Bad Signedness type"); |
| 717 | if (isa<StructType>(CT)) { |
| 718 | S = S.get(cast<ConstantInt>(Index)->getZExtValue()); |
| 719 | } else { |
| 720 | S = S.get(0UL); |
| 721 | } |
| 722 | if (S.isNamed()) |
| 723 | S = CurModule.NamedTypeSigns[S.getName()]; |
| 724 | } |
| 725 | Signedness Result; |
| 726 | Result.makeComposite(S); |
| 727 | return Result; |
| 728 | } |
| 729 | |
| 730 | /// This function just translates a ConstantInfo into a ValueInfo and calls |
| 731 | /// getElementSign(ValueInfo,...). Its just a convenience. |
| 732 | /// @brief ConstantInfo version of getElementSign. |
| 733 | static Signedness getElementSign(const ConstInfo& CI, |
| 734 | const std::vector<Constant*> &Indices) { |
| 735 | ValueInfo VI; |
| 736 | VI.V = CI.C; |
| 737 | VI.S.copy(CI.S); |
| 738 | std::vector<Value*> Idx; |
| 739 | for (unsigned i = 0; i < Indices.size(); ++i) |
| 740 | Idx.push_back(Indices[i]); |
| 741 | Signedness result = getElementSign(VI, Idx); |
| 742 | VI.destroy(); |
| 743 | return result; |
| 744 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 745 | |
| 746 | // getExistingValue - Look up the value specified by the provided type and |
| 747 | // the provided ValID. If the value exists and has already been defined, return |
| 748 | // it. Otherwise return null. |
| 749 | // |
| 750 | static Value *getExistingValue(const Type *Ty, const ValID &D) { |
| 751 | if (isa<FunctionType>(Ty)) { |
| 752 | error("Functions are not values and must be referenced as pointers"); |
| 753 | } |
| 754 | |
| 755 | switch (D.Type) { |
| 756 | case ValID::NumberVal: { // Is it a numbered definition? |
| 757 | unsigned Num = (unsigned)D.Num; |
| 758 | |
| 759 | // Module constants occupy the lowest numbered slots... |
| 760 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 761 | if (VI != CurModule.Values.end()) { |
| 762 | if (Num < VI->second.size()) |
| 763 | return VI->second[Num]; |
| 764 | Num -= VI->second.size(); |
| 765 | } |
| 766 | |
| 767 | // Make sure that our type is within bounds |
| 768 | VI = CurFun.Values.find(Ty); |
| 769 | if (VI == CurFun.Values.end()) return 0; |
| 770 | |
| 771 | // Check that the number is within bounds... |
| 772 | if (VI->second.size() <= Num) return 0; |
| 773 | |
| 774 | return VI->second[Num]; |
| 775 | } |
| 776 | |
| 777 | case ValID::NameVal: { // Is it a named definition? |
| 778 | // Get the name out of the ID |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 779 | RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S); |
| 780 | Value *V = 0; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 781 | if (inFunctionScope()) { |
| 782 | // See if the name was renamed |
| 783 | RenameMapType::const_iterator I = CurFun.RenameMap.find(Key); |
| 784 | std::string LookupName; |
| 785 | if (I != CurFun.RenameMap.end()) |
| 786 | LookupName = I->second; |
| 787 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 788 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 789 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 790 | V = SymTab.lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 791 | if (V && V->getType() != Ty) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 792 | V = 0; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 793 | } |
| 794 | if (!V) { |
| 795 | RenameMapType::const_iterator I = CurModule.RenameMap.find(Key); |
| 796 | std::string LookupName; |
| 797 | if (I != CurModule.RenameMap.end()) |
| 798 | LookupName = I->second; |
| 799 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 800 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 801 | V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 802 | if (V && V->getType() != Ty) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 803 | V = 0; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 804 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 805 | if (!V) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 806 | return 0; |
| 807 | |
| 808 | D.destroy(); // Free old strdup'd memory... |
| 809 | return V; |
| 810 | } |
| 811 | |
| 812 | // Check to make sure that "Ty" is an integral type, and that our |
| 813 | // value will fit into the specified type... |
| 814 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
| 815 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
| 816 | error("Signed integral constant '" + itostr(D.ConstPool64) + |
| 817 | "' is invalid for type '" + Ty->getDescription() + "'"); |
| 818 | } |
| 819 | return ConstantInt::get(Ty, D.ConstPool64); |
| 820 | |
| 821 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
| 822 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 823 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) |
| 824 | error("Integral constant '" + utostr(D.UConstPool64) + |
| 825 | "' is invalid or out of range"); |
| 826 | else // This is really a signed reference. Transmogrify. |
| 827 | return ConstantInt::get(Ty, D.ConstPool64); |
| 828 | } else |
| 829 | return ConstantInt::get(Ty, D.UConstPool64); |
| 830 | |
| 831 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 832 | if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 833 | error("FP constant invalid for type"); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 834 | // Lexer has no type info, so builds all FP constants as double. |
| 835 | // Fix this here. |
| 836 | if (Ty==Type::FloatTy) |
| 837 | D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); |
| 838 | return ConstantFP::get(Ty, *D.ConstPoolFP); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 839 | |
| 840 | case ValID::ConstNullVal: // Is it a null value? |
| 841 | if (!isa<PointerType>(Ty)) |
| 842 | error("Cannot create a a non pointer null"); |
| 843 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 844 | |
| 845 | case ValID::ConstUndefVal: // Is it an undef value? |
| 846 | return UndefValue::get(Ty); |
| 847 | |
| 848 | case ValID::ConstZeroVal: // Is it a zero value? |
| 849 | return Constant::getNullValue(Ty); |
| 850 | |
| 851 | case ValID::ConstantVal: // Fully resolved constant? |
| 852 | if (D.ConstantValue->getType() != Ty) |
| 853 | error("Constant expression type different from required type"); |
| 854 | return D.ConstantValue; |
| 855 | |
| 856 | case ValID::InlineAsmVal: { // Inline asm expression |
| 857 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 858 | const FunctionType *FTy = |
| 859 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
| 860 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) |
| 861 | error("Invalid type for asm constraint string"); |
| 862 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 863 | D.IAD->HasSideEffects); |
| 864 | D.destroy(); // Free InlineAsmDescriptor. |
| 865 | return IA; |
| 866 | } |
| 867 | default: |
| 868 | assert(0 && "Unhandled case"); |
| 869 | return 0; |
| 870 | } // End of switch |
| 871 | |
| 872 | assert(0 && "Unhandled case"); |
| 873 | return 0; |
| 874 | } |
| 875 | |
| 876 | // getVal - This function is identical to getExistingValue, except that if a |
| 877 | // value is not already defined, it "improvises" by creating a placeholder var |
| 878 | // that looks and acts just like the requested variable. When the value is |
| 879 | // defined later, all uses of the placeholder variable are replaced with the |
| 880 | // real thing. |
| 881 | // |
| 882 | static Value *getVal(const Type *Ty, const ValID &ID) { |
| 883 | if (Ty == Type::LabelTy) |
| 884 | error("Cannot use a basic block here"); |
| 885 | |
| 886 | // See if the value has already been defined. |
| 887 | Value *V = getExistingValue(Ty, ID); |
| 888 | if (V) return V; |
| 889 | |
| 890 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) |
| 891 | error("Invalid use of a composite type"); |
| 892 | |
| 893 | // If we reached here, we referenced either a symbol that we don't know about |
| 894 | // or an id number that hasn't been read yet. We may be referencing something |
| 895 | // forward, so just create an entry to be resolved later and get to it... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 896 | V = new Argument(Ty); |
| 897 | |
| 898 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 899 | // to recycle these things?? |
| 900 | CurModule.PlaceHolderInfo.insert( |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 901 | std::make_pair(V, std::make_pair(ID, Upgradelineno))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 902 | |
| 903 | if (inFunctionScope()) |
| 904 | InsertValue(V, CurFun.LateResolveValues); |
| 905 | else |
| 906 | InsertValue(V, CurModule.LateResolveValues); |
| 907 | return V; |
| 908 | } |
| 909 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 910 | /// @brief This just makes any name given to it unique, up to MAX_UINT times. |
| 911 | static std::string makeNameUnique(const std::string& Name) { |
| 912 | static unsigned UniqueNameCounter = 1; |
| 913 | std::string Result(Name); |
| 914 | Result += ".upgrd." + llvm::utostr(UniqueNameCounter++); |
| 915 | return Result; |
| 916 | } |
| 917 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 918 | /// getBBVal - This is used for two purposes: |
| 919 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 920 | /// defined. |
| 921 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 922 | /// or may not be a forward reference. |
| 923 | /// |
| 924 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 925 | assert(inFunctionScope() && "Can't get basic block at global scope"); |
| 926 | |
| 927 | std::string Name; |
| 928 | BasicBlock *BB = 0; |
| 929 | switch (ID.Type) { |
| 930 | default: |
| 931 | error("Illegal label reference " + ID.getName()); |
| 932 | break; |
| 933 | case ValID::NumberVal: // Is it a numbered definition? |
| 934 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 935 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 936 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 937 | break; |
| 938 | case ValID::NameVal: // Is it a named definition? |
| 939 | Name = ID.Name; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 940 | if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 941 | if (N->getType() != Type::LabelTy) { |
| 942 | // Register names didn't use to conflict with basic block names |
| 943 | // because of type planes. Now they all have to be unique. So, we just |
| 944 | // rename the register and treat this name as if no basic block |
| 945 | // had been found. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 946 | RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 947 | N->setName(makeNameUnique(N->getName())); |
| 948 | CurModule.RenameMap[Key] = N->getName(); |
| 949 | BB = 0; |
| 950 | } else { |
| 951 | BB = cast<BasicBlock>(N); |
| 952 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 953 | } |
| 954 | break; |
| 955 | } |
| 956 | |
| 957 | // See if the block has already been defined. |
| 958 | if (BB) { |
| 959 | // If this is the definition of the block, make sure the existing value was |
| 960 | // just a forward reference. If it was a forward reference, there will be |
| 961 | // an entry for it in the PlaceHolderInfo map. |
| 962 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) |
| 963 | // The existing value was a definition, not a forward reference. |
| 964 | error("Redefinition of label " + ID.getName()); |
| 965 | |
| 966 | ID.destroy(); // Free strdup'd memory. |
| 967 | return BB; |
| 968 | } |
| 969 | |
| 970 | // Otherwise this block has not been seen before. |
| 971 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 972 | if (ID.Type == ValID::NameVal) { |
| 973 | BB->setName(ID.Name); |
| 974 | } else { |
| 975 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 976 | } |
| 977 | |
| 978 | // If this is not a definition, keep track of it so we can use it as a forward |
| 979 | // reference. |
| 980 | if (!isDefinition) { |
| 981 | // Remember where this forward reference came from. |
| 982 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno); |
| 983 | } else { |
| 984 | // The forward declaration could have been inserted anywhere in the |
| 985 | // function: insert it into the correct place now. |
| 986 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 987 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 988 | } |
| 989 | ID.destroy(); |
| 990 | return BB; |
| 991 | } |
| 992 | |
| 993 | |
| 994 | //===----------------------------------------------------------------------===// |
| 995 | // Code to handle forward references in instructions |
| 996 | //===----------------------------------------------------------------------===// |
| 997 | // |
| 998 | // This code handles the late binding needed with statements that reference |
| 999 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 1000 | // a loop body. |
| 1001 | // |
| 1002 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 1003 | // and back patchs after we are done. |
| 1004 | // |
| 1005 | |
| 1006 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 1007 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 1008 | // defs now... |
| 1009 | // |
| 1010 | static void |
| 1011 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 1012 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1013 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1014 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 1015 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 1016 | E = LateResolvers.end(); LRI != E; ++LRI) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1017 | const Type* Ty = LRI->first; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1018 | ValueList &List = LRI->second; |
| 1019 | while (!List.empty()) { |
| 1020 | Value *V = List.back(); |
| 1021 | List.pop_back(); |
| 1022 | |
| 1023 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 1024 | CurModule.PlaceHolderInfo.find(V); |
| 1025 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error"); |
| 1026 | |
| 1027 | ValID &DID = PHI->second.first; |
| 1028 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1029 | Value *TheRealValue = getExistingValue(Ty, DID); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1030 | if (TheRealValue) { |
| 1031 | V->replaceAllUsesWith(TheRealValue); |
| 1032 | delete V; |
| 1033 | CurModule.PlaceHolderInfo.erase(PHI); |
| 1034 | } else if (FutureLateResolvers) { |
| 1035 | // Functions have their unresolved items forwarded to the module late |
| 1036 | // resolver table |
| 1037 | InsertValue(V, *FutureLateResolvers); |
| 1038 | } else { |
| 1039 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1040 | error("Reference to an invalid definition: '" + DID.getName() + |
| 1041 | "' of type '" + V->getType()->getDescription() + "'", |
| 1042 | PHI->second.second); |
Reid Spencer | 7de2e01 | 2007-01-29 19:08:46 +0000 | [diff] [blame] | 1043 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1044 | } else { |
| 1045 | error("Reference to an invalid definition: #" + |
| 1046 | itostr(DID.Num) + " of type '" + |
| 1047 | V->getType()->getDescription() + "'", PHI->second.second); |
| 1048 | return; |
| 1049 | } |
| 1050 | } |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | LateResolvers.clear(); |
| 1055 | } |
| 1056 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1057 | /// This function is used for type resolution and upref handling. When a type |
| 1058 | /// becomes concrete, this function is called to adjust the signedness for the |
| 1059 | /// concrete type. |
| 1060 | static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) { |
| 1061 | std::string TyName = CurModule.CurrentModule->getTypeName(oldTy); |
| 1062 | if (!TyName.empty()) |
| 1063 | CurModule.NamedTypeSigns[TyName] = Sign; |
| 1064 | } |
| 1065 | |
| 1066 | /// ResolveTypeTo - A brand new type was just declared. This means that (if |
| 1067 | /// name is not null) things referencing Name can be resolved. Otherwise, |
| 1068 | /// things refering to the number can be resolved. Do this now. |
| 1069 | static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1070 | ValID D; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1071 | if (Name) |
| 1072 | D = ValID::create(Name); |
| 1073 | else |
| 1074 | D = ValID::create((int)CurModule.Types.size()); |
| 1075 | D.S.copy(Sign); |
| 1076 | |
Reid Spencer | baba98a | 2007-04-11 12:10:58 +0000 | [diff] [blame] | 1077 | if (Name) |
| 1078 | CurModule.NamedTypeSigns[Name] = Sign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1079 | |
| 1080 | std::map<ValID, PATypeHolder>::iterator I = |
| 1081 | CurModule.LateResolveTypes.find(D); |
| 1082 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1083 | const Type *OldTy = I->second.get(); |
| 1084 | ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1085 | CurModule.LateResolveTypes.erase(I); |
| 1086 | } |
| 1087 | } |
| 1088 | |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1089 | /// This is the implementation portion of TypeHasInteger. It traverses the |
| 1090 | /// type given, avoiding recursive types, and returns true as soon as it finds |
| 1091 | /// an integer type. If no integer type is found, it returns false. |
| 1092 | static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) { |
| 1093 | // Handle some easy cases |
| 1094 | if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID)) |
| 1095 | return false; |
| 1096 | if (Ty->isInteger()) |
| 1097 | return true; |
| 1098 | if (const SequentialType *STy = dyn_cast<SequentialType>(Ty)) |
| 1099 | return STy->getElementType()->isInteger(); |
| 1100 | |
| 1101 | // Avoid type structure recursion |
| 1102 | for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end(); |
| 1103 | I != E; ++I) |
| 1104 | if (Ty == *I) |
| 1105 | return false; |
| 1106 | |
| 1107 | // Push us on the type stack |
| 1108 | Stack.push_back(Ty); |
| 1109 | |
| 1110 | if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) { |
| 1111 | if (TypeHasIntegerI(FTy->getReturnType(), Stack)) |
| 1112 | return true; |
| 1113 | FunctionType::param_iterator I = FTy->param_begin(); |
| 1114 | FunctionType::param_iterator E = FTy->param_end(); |
| 1115 | for (; I != E; ++I) |
| 1116 | if (TypeHasIntegerI(*I, Stack)) |
| 1117 | return true; |
| 1118 | return false; |
| 1119 | } else if (const StructType *STy = dyn_cast<StructType>(Ty)) { |
| 1120 | StructType::element_iterator I = STy->element_begin(); |
| 1121 | StructType::element_iterator E = STy->element_end(); |
| 1122 | for (; I != E; ++I) { |
| 1123 | if (TypeHasIntegerI(*I, Stack)) |
| 1124 | return true; |
| 1125 | } |
| 1126 | return false; |
| 1127 | } |
| 1128 | // There shouldn't be anything else, but its definitely not integer |
| 1129 | assert(0 && "What type is this?"); |
| 1130 | return false; |
| 1131 | } |
| 1132 | |
| 1133 | /// This is the interface to TypeHasIntegerI. It just provides the type stack, |
| 1134 | /// to avoid recursion, and then calls TypeHasIntegerI. |
| 1135 | static inline bool TypeHasInteger(const Type *Ty) { |
| 1136 | std::vector<const Type*> TyStack; |
| 1137 | return TypeHasIntegerI(Ty, TyStack); |
| 1138 | } |
| 1139 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1140 | // setValueName - Set the specified value to the name given. The name may be |
| 1141 | // null potentially, in which case this is a noop. The string passed in is |
| 1142 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 1143 | // |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1144 | static void setValueName(const ValueInfo &V, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1145 | if (NameStr) { |
| 1146 | std::string Name(NameStr); // Copy string |
| 1147 | free(NameStr); // Free old string |
| 1148 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1149 | if (V.V->getType() == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1150 | error("Can't assign name '" + Name + "' to value with void type"); |
| 1151 | return; |
| 1152 | } |
| 1153 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1154 | assert(inFunctionScope() && "Must be in function scope"); |
| 1155 | |
| 1156 | // Search the function's symbol table for an existing value of this name |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1157 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 1158 | Value* Existing = ST.lookup(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1159 | if (Existing) { |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1160 | // An existing value of the same name was found. This might have happened |
| 1161 | // because of the integer type planes collapsing in LLVM 2.0. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1162 | if (Existing->getType() == V.V->getType() && |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1163 | !TypeHasInteger(Existing->getType())) { |
| 1164 | // If the type does not contain any integers in them then this can't be |
| 1165 | // a type plane collapsing issue. It truly is a redefinition and we |
| 1166 | // should error out as the assembly is invalid. |
| 1167 | error("Redefinition of value named '" + Name + "' of type '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1168 | V.V->getType()->getDescription() + "'"); |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1169 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1170 | } |
| 1171 | // In LLVM 2.0 we don't allow names to be re-used for any values in a |
| 1172 | // function, regardless of Type. Previously re-use of names was okay as |
| 1173 | // long as they were distinct types. With type planes collapsing because |
| 1174 | // of the signedness change and because of PR411, this can no longer be |
| 1175 | // supported. We must search the entire symbol table for a conflicting |
| 1176 | // name and make the name unique. No warning is needed as this can't |
| 1177 | // cause a problem. |
| 1178 | std::string NewName = makeNameUnique(Name); |
| 1179 | // We're changing the name but it will probably be used by other |
| 1180 | // instructions as operands later on. Consequently we have to retain |
| 1181 | // a mapping of the renaming that we're doing. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1182 | RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1183 | CurFun.RenameMap[Key] = NewName; |
| 1184 | Name = NewName; |
| 1185 | } |
| 1186 | |
| 1187 | // Set the name. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1188 | V.V->setName(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 1193 | /// this is a declaration, otherwise it is a definition. |
| 1194 | static GlobalVariable * |
| 1195 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 1196 | bool isConstantGlobal, const Type *Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1197 | Constant *Initializer, |
| 1198 | const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1199 | if (isa<FunctionType>(Ty)) |
| 1200 | error("Cannot declare global vars of function type"); |
| 1201 | |
| 1202 | const PointerType *PTy = PointerType::get(Ty); |
| 1203 | |
| 1204 | std::string Name; |
| 1205 | if (NameStr) { |
| 1206 | Name = NameStr; // Copy string |
| 1207 | free(NameStr); // Free old string |
| 1208 | } |
| 1209 | |
| 1210 | // See if this global value was forward referenced. If so, recycle the |
| 1211 | // object. |
| 1212 | ValID ID; |
| 1213 | if (!Name.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1214 | ID = ValID::create((char*)Name.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1215 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1216 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1217 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1218 | ID.S.makeComposite(Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1219 | |
| 1220 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1221 | // Move the global to the end of the list, from whereever it was |
| 1222 | // previously inserted. |
| 1223 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1224 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1225 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1226 | GV->setInitializer(Initializer); |
| 1227 | GV->setLinkage(Linkage); |
| 1228 | GV->setConstant(isConstantGlobal); |
| 1229 | InsertValue(GV, CurModule.Values); |
| 1230 | return GV; |
| 1231 | } |
| 1232 | |
| 1233 | // If this global has a name, check to see if there is already a definition |
| 1234 | // of this global in the module and emit warnings if there are conflicts. |
| 1235 | if (!Name.empty()) { |
| 1236 | // The global has a name. See if there's an existing one of the same name. |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 1237 | if (CurModule.CurrentModule->getNamedGlobal(Name) || |
| 1238 | CurModule.CurrentModule->getFunction(Name)) { |
| 1239 | // We found an existing global of the same name. This isn't allowed |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1240 | // in LLVM 2.0. Consequently, we must alter the name of the global so it |
| 1241 | // can at least compile. This can happen because of type planes |
| 1242 | // There is alread a global of the same name which means there is a |
| 1243 | // conflict. Let's see what we can do about it. |
| 1244 | std::string NewName(makeNameUnique(Name)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1245 | if (Linkage != GlobalValue::InternalLinkage) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1246 | // The linkage of this gval is external so we can't reliably rename |
| 1247 | // it because it could potentially create a linking problem. |
| 1248 | // However, we can't leave the name conflict in the output either or |
| 1249 | // it won't assemble with LLVM 2.0. So, all we can do is rename |
| 1250 | // this one to something unique and emit a warning about the problem. |
| 1251 | warning("Renaming global variable '" + Name + "' to '" + NewName + |
| 1252 | "' may cause linkage errors"); |
| 1253 | } |
| 1254 | |
| 1255 | // Put the renaming in the global rename map |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1256 | RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1257 | CurModule.RenameMap[Key] = NewName; |
| 1258 | |
| 1259 | // Rename it |
| 1260 | Name = NewName; |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | // Otherwise there is no existing GV to use, create one now. |
| 1265 | GlobalVariable *GV = |
| 1266 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 1267 | CurModule.CurrentModule); |
| 1268 | InsertValue(GV, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1269 | // Remember the sign of this global. |
| 1270 | CurModule.NamedValueSigns[Name] = ID.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1271 | return GV; |
| 1272 | } |
| 1273 | |
| 1274 | // setTypeName - Set the specified type to the name given. The name may be |
| 1275 | // null potentially, in which case this is a noop. The string passed in is |
| 1276 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1277 | // |
| 1278 | // This function returns true if the type has already been defined, but is |
| 1279 | // allowed to be redefined in the specified context. If the name is a new name |
| 1280 | // for the type plane, it is inserted and false is returned. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1281 | static bool setTypeName(const PATypeInfo& TI, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1282 | assert(!inFunctionScope() && "Can't give types function-local names"); |
| 1283 | if (NameStr == 0) return false; |
| 1284 | |
| 1285 | std::string Name(NameStr); // Copy string |
| 1286 | free(NameStr); // Free old string |
| 1287 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1288 | const Type* Ty = TI.PAT->get(); |
| 1289 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1290 | // We don't allow assigning names to void type |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1291 | if (Ty == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1292 | error("Can't assign name '" + Name + "' to the void type"); |
| 1293 | return false; |
| 1294 | } |
| 1295 | |
| 1296 | // Set the type name, checking for conflicts as we do so. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1297 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty); |
| 1298 | |
| 1299 | // Save the sign information for later use |
| 1300 | CurModule.NamedTypeSigns[Name] = TI.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1301 | |
| 1302 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1303 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 1304 | assert(Existing && "Conflict but no matching type?"); |
| 1305 | |
| 1306 | // There is only one case where this is allowed: when we are refining an |
| 1307 | // opaque type. In this case, Existing will be an opaque type. |
| 1308 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1309 | // We ARE replacing an opaque type! |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1310 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1311 | return true; |
| 1312 | } |
| 1313 | |
| 1314 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1315 | // the redefinition is identical to the original. This will be so if |
| 1316 | // Existing and T point to the same Type object. In this one case we |
| 1317 | // allow the equivalent redefinition. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1318 | if (Existing == Ty) return true; // Yes, it's equal. |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1319 | |
| 1320 | // Any other kind of (non-equivalent) redefinition is an error. |
| 1321 | error("Redefinition of type named '" + Name + "' in the '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1322 | Ty->getDescription() + "' type plane"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1323 | } |
| 1324 | |
| 1325 | return false; |
| 1326 | } |
| 1327 | |
| 1328 | //===----------------------------------------------------------------------===// |
| 1329 | // Code for handling upreferences in type names... |
| 1330 | // |
| 1331 | |
| 1332 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1333 | // |
| 1334 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1335 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1336 | E) != Ty->subtype_end(); |
| 1337 | } |
| 1338 | |
| 1339 | namespace { |
| 1340 | struct UpRefRecord { |
| 1341 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1342 | // this type is resolved. |
| 1343 | unsigned NestingLevel; |
| 1344 | |
| 1345 | // LastContainedTy - This is the type at the current binding level for the |
| 1346 | // type. Every time we reduce the nesting level, this gets updated. |
| 1347 | const Type *LastContainedTy; |
| 1348 | |
| 1349 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1350 | // represented with. |
| 1351 | OpaqueType *UpRefTy; |
| 1352 | |
| 1353 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1354 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1355 | }; |
| 1356 | } |
| 1357 | |
| 1358 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1359 | static std::vector<UpRefRecord> UpRefs; |
| 1360 | |
| 1361 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1362 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1363 | /// currently active types. For each type, if the up reference is contained in |
| 1364 | /// the newly completed type, we decrement the level count. When the level |
| 1365 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1366 | /// thus we can complete the cycle. |
| 1367 | /// |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1368 | static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1369 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1370 | // nothing to resolve here. |
| 1371 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1372 | |
| 1373 | PATypeHolder Ty(ty); |
| 1374 | UR_OUT("Type '" << Ty->getDescription() << |
| 1375 | "' newly formed. Resolving upreferences.\n" << |
| 1376 | UpRefs.size() << " upreferences active!\n"); |
| 1377 | |
| 1378 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1379 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1380 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1381 | // this variable. |
| 1382 | OpaqueType *TypeToResolve = 0; |
| 1383 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1384 | unsigned i = 0; |
| 1385 | for (; i != UpRefs.size(); ++i) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1386 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1387 | << UpRefs[i].UpRefTy->getDescription() << ") = " |
| 1388 | << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1389 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1390 | // Decrement level of upreference |
| 1391 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1392 | UpRefs[i].LastContainedTy = Ty; |
| 1393 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1394 | if (Level == 0) { // Upreference should be resolved! |
| 1395 | if (!TypeToResolve) { |
| 1396 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1397 | } else { |
| 1398 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1399 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
| 1400 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1401 | ResolveTypeSign(UpRefs[i].UpRefTy, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1402 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1403 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1404 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1405 | } |
| 1406 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1407 | --i; // Do not skip the next element... |
| 1408 | } |
| 1409 | } |
| 1410 | } |
| 1411 | |
| 1412 | if (TypeToResolve) { |
| 1413 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1414 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1415 | std::string OldName = TypeToResolve->getDescription()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1416 | ResolveTypeSign(TypeToResolve, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1417 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1418 | } |
| 1419 | |
| 1420 | return Ty; |
| 1421 | } |
| 1422 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1423 | bool Signedness::operator<(const Signedness &that) const { |
| 1424 | if (isNamed()) { |
| 1425 | if (that.isNamed()) |
| 1426 | return *(this->name) < *(that.name); |
| 1427 | else |
| 1428 | return CurModule.NamedTypeSigns[*name] < that; |
| 1429 | } else if (that.isNamed()) { |
| 1430 | return *this < CurModule.NamedTypeSigns[*that.name]; |
| 1431 | } |
| 1432 | |
| 1433 | if (isComposite() && that.isComposite()) { |
| 1434 | if (sv->size() == that.sv->size()) { |
| 1435 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1436 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1437 | thatE = that.sv->end(); |
| 1438 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1439 | if (*thisI < *thatI) |
| 1440 | return true; |
| 1441 | else if (!(*thisI == *thatI)) |
| 1442 | return false; |
| 1443 | } |
| 1444 | return false; |
| 1445 | } |
| 1446 | return sv->size() < that.sv->size(); |
| 1447 | } |
| 1448 | return kind < that.kind; |
| 1449 | } |
| 1450 | |
| 1451 | bool Signedness::operator==(const Signedness &that) const { |
| 1452 | if (isNamed()) |
| 1453 | if (that.isNamed()) |
| 1454 | return *(this->name) == *(that.name); |
| 1455 | else |
| 1456 | return CurModule.NamedTypeSigns[*(this->name)] == that; |
| 1457 | else if (that.isNamed()) |
| 1458 | return *this == CurModule.NamedTypeSigns[*(that.name)]; |
| 1459 | if (isComposite() && that.isComposite()) { |
| 1460 | if (sv->size() == that.sv->size()) { |
| 1461 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1462 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1463 | thatE = that.sv->end(); |
| 1464 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1465 | if (!(*thisI == *thatI)) |
| 1466 | return false; |
| 1467 | } |
| 1468 | return true; |
| 1469 | } |
| 1470 | return false; |
| 1471 | } |
| 1472 | return kind == that.kind; |
| 1473 | } |
| 1474 | |
| 1475 | void Signedness::copy(const Signedness &that) { |
| 1476 | if (that.isNamed()) { |
| 1477 | kind = Named; |
| 1478 | name = new std::string(*that.name); |
| 1479 | } else if (that.isComposite()) { |
| 1480 | kind = Composite; |
| 1481 | sv = new SignVector(); |
| 1482 | *sv = *that.sv; |
| 1483 | } else { |
| 1484 | kind = that.kind; |
| 1485 | sv = 0; |
| 1486 | } |
| 1487 | } |
| 1488 | |
| 1489 | void Signedness::destroy() { |
| 1490 | if (isNamed()) { |
| 1491 | delete name; |
| 1492 | } else if (isComposite()) { |
| 1493 | delete sv; |
| 1494 | } |
| 1495 | } |
| 1496 | |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1497 | #ifndef NDEBUG |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1498 | void Signedness::dump() const { |
| 1499 | if (isComposite()) { |
| 1500 | if (sv->size() == 1) { |
| 1501 | (*sv)[0].dump(); |
| 1502 | std::cerr << "*"; |
| 1503 | } else { |
| 1504 | std::cerr << "{ " ; |
| 1505 | for (unsigned i = 0; i < sv->size(); ++i) { |
| 1506 | if (i != 0) |
| 1507 | std::cerr << ", "; |
| 1508 | (*sv)[i].dump(); |
| 1509 | } |
| 1510 | std::cerr << "} " ; |
| 1511 | } |
| 1512 | } else if (isNamed()) { |
| 1513 | std::cerr << *name; |
| 1514 | } else if (isSigned()) { |
| 1515 | std::cerr << "S"; |
| 1516 | } else if (isUnsigned()) { |
| 1517 | std::cerr << "U"; |
| 1518 | } else |
| 1519 | std::cerr << "."; |
| 1520 | } |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1521 | #endif |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1522 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1523 | static inline Instruction::TermOps |
| 1524 | getTermOp(TermOps op) { |
| 1525 | switch (op) { |
| 1526 | default : assert(0 && "Invalid OldTermOp"); |
| 1527 | case RetOp : return Instruction::Ret; |
| 1528 | case BrOp : return Instruction::Br; |
| 1529 | case SwitchOp : return Instruction::Switch; |
| 1530 | case InvokeOp : return Instruction::Invoke; |
| 1531 | case UnwindOp : return Instruction::Unwind; |
| 1532 | case UnreachableOp: return Instruction::Unreachable; |
| 1533 | } |
| 1534 | } |
| 1535 | |
| 1536 | static inline Instruction::BinaryOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1537 | getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1538 | switch (op) { |
| 1539 | default : assert(0 && "Invalid OldBinaryOps"); |
| 1540 | case SetEQ : |
| 1541 | case SetNE : |
| 1542 | case SetLE : |
| 1543 | case SetGE : |
| 1544 | case SetLT : |
| 1545 | case SetGT : assert(0 && "Should use getCompareOp"); |
| 1546 | case AddOp : return Instruction::Add; |
| 1547 | case SubOp : return Instruction::Sub; |
| 1548 | case MulOp : return Instruction::Mul; |
| 1549 | case DivOp : { |
| 1550 | // This is an obsolete instruction so we must upgrade it based on the |
| 1551 | // types of its operands. |
| 1552 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1553 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1554 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1555 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1556 | if (isFP) |
| 1557 | return Instruction::FDiv; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1558 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1559 | return Instruction::SDiv; |
| 1560 | return Instruction::UDiv; |
| 1561 | } |
| 1562 | case UDivOp : return Instruction::UDiv; |
| 1563 | case SDivOp : return Instruction::SDiv; |
| 1564 | case FDivOp : return Instruction::FDiv; |
| 1565 | case RemOp : { |
| 1566 | // This is an obsolete instruction so we must upgrade it based on the |
| 1567 | // types of its operands. |
| 1568 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1569 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1570 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1571 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1572 | // Select correct opcode |
| 1573 | if (isFP) |
| 1574 | return Instruction::FRem; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1575 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1576 | return Instruction::SRem; |
| 1577 | return Instruction::URem; |
| 1578 | } |
| 1579 | case URemOp : return Instruction::URem; |
| 1580 | case SRemOp : return Instruction::SRem; |
| 1581 | case FRemOp : return Instruction::FRem; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1582 | case LShrOp : return Instruction::LShr; |
| 1583 | case AShrOp : return Instruction::AShr; |
| 1584 | case ShlOp : return Instruction::Shl; |
| 1585 | case ShrOp : |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1586 | if (Sign.isSigned()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1587 | return Instruction::AShr; |
| 1588 | return Instruction::LShr; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1589 | case AndOp : return Instruction::And; |
| 1590 | case OrOp : return Instruction::Or; |
| 1591 | case XorOp : return Instruction::Xor; |
| 1592 | } |
| 1593 | } |
| 1594 | |
| 1595 | static inline Instruction::OtherOps |
| 1596 | getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1597 | const Signedness &Sign) { |
| 1598 | bool isSigned = Sign.isSigned(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1599 | bool isFP = Ty->isFloatingPoint(); |
| 1600 | switch (op) { |
| 1601 | default : assert(0 && "Invalid OldSetCC"); |
| 1602 | case SetEQ : |
| 1603 | if (isFP) { |
| 1604 | predicate = FCmpInst::FCMP_OEQ; |
| 1605 | return Instruction::FCmp; |
| 1606 | } else { |
| 1607 | predicate = ICmpInst::ICMP_EQ; |
| 1608 | return Instruction::ICmp; |
| 1609 | } |
| 1610 | case SetNE : |
| 1611 | if (isFP) { |
| 1612 | predicate = FCmpInst::FCMP_UNE; |
| 1613 | return Instruction::FCmp; |
| 1614 | } else { |
| 1615 | predicate = ICmpInst::ICMP_NE; |
| 1616 | return Instruction::ICmp; |
| 1617 | } |
| 1618 | case SetLE : |
| 1619 | if (isFP) { |
| 1620 | predicate = FCmpInst::FCMP_OLE; |
| 1621 | return Instruction::FCmp; |
| 1622 | } else { |
| 1623 | if (isSigned) |
| 1624 | predicate = ICmpInst::ICMP_SLE; |
| 1625 | else |
| 1626 | predicate = ICmpInst::ICMP_ULE; |
| 1627 | return Instruction::ICmp; |
| 1628 | } |
| 1629 | case SetGE : |
| 1630 | if (isFP) { |
| 1631 | predicate = FCmpInst::FCMP_OGE; |
| 1632 | return Instruction::FCmp; |
| 1633 | } else { |
| 1634 | if (isSigned) |
| 1635 | predicate = ICmpInst::ICMP_SGE; |
| 1636 | else |
| 1637 | predicate = ICmpInst::ICMP_UGE; |
| 1638 | return Instruction::ICmp; |
| 1639 | } |
| 1640 | case SetLT : |
| 1641 | if (isFP) { |
| 1642 | predicate = FCmpInst::FCMP_OLT; |
| 1643 | return Instruction::FCmp; |
| 1644 | } else { |
| 1645 | if (isSigned) |
| 1646 | predicate = ICmpInst::ICMP_SLT; |
| 1647 | else |
| 1648 | predicate = ICmpInst::ICMP_ULT; |
| 1649 | return Instruction::ICmp; |
| 1650 | } |
| 1651 | case SetGT : |
| 1652 | if (isFP) { |
| 1653 | predicate = FCmpInst::FCMP_OGT; |
| 1654 | return Instruction::FCmp; |
| 1655 | } else { |
| 1656 | if (isSigned) |
| 1657 | predicate = ICmpInst::ICMP_SGT; |
| 1658 | else |
| 1659 | predicate = ICmpInst::ICMP_UGT; |
| 1660 | return Instruction::ICmp; |
| 1661 | } |
| 1662 | } |
| 1663 | } |
| 1664 | |
| 1665 | static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) { |
| 1666 | switch (op) { |
| 1667 | default : assert(0 && "Invalid OldMemoryOps"); |
| 1668 | case MallocOp : return Instruction::Malloc; |
| 1669 | case FreeOp : return Instruction::Free; |
| 1670 | case AllocaOp : return Instruction::Alloca; |
| 1671 | case LoadOp : return Instruction::Load; |
| 1672 | case StoreOp : return Instruction::Store; |
| 1673 | case GetElementPtrOp : return Instruction::GetElementPtr; |
| 1674 | } |
| 1675 | } |
| 1676 | |
| 1677 | static inline Instruction::OtherOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1678 | getOtherOp(OtherOps op, const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1679 | switch (op) { |
| 1680 | default : assert(0 && "Invalid OldOtherOps"); |
| 1681 | case PHIOp : return Instruction::PHI; |
| 1682 | case CallOp : return Instruction::Call; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1683 | case SelectOp : return Instruction::Select; |
| 1684 | case UserOp1 : return Instruction::UserOp1; |
| 1685 | case UserOp2 : return Instruction::UserOp2; |
| 1686 | case VAArg : return Instruction::VAArg; |
| 1687 | case ExtractElementOp : return Instruction::ExtractElement; |
| 1688 | case InsertElementOp : return Instruction::InsertElement; |
| 1689 | case ShuffleVectorOp : return Instruction::ShuffleVector; |
| 1690 | case ICmpOp : return Instruction::ICmp; |
| 1691 | case FCmpOp : return Instruction::FCmp; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1692 | }; |
| 1693 | } |
| 1694 | |
| 1695 | static inline Value* |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1696 | getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy, |
| 1697 | const Signedness &DstSign, bool ForceInstruction = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1698 | Instruction::CastOps Opcode; |
| 1699 | const Type* SrcTy = Src->getType(); |
| 1700 | if (op == CastOp) { |
| 1701 | if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) { |
| 1702 | // fp -> ptr cast is no longer supported but we must upgrade this |
| 1703 | // by doing a double cast: fp -> int -> ptr |
| 1704 | SrcTy = Type::Int64Ty; |
| 1705 | Opcode = Instruction::IntToPtr; |
| 1706 | if (isa<Constant>(Src)) { |
| 1707 | Src = ConstantExpr::getCast(Instruction::FPToUI, |
| 1708 | cast<Constant>(Src), SrcTy); |
| 1709 | } else { |
| 1710 | std::string NewName(makeNameUnique(Src->getName())); |
| 1711 | Src = new FPToUIInst(Src, SrcTy, NewName, CurBB); |
| 1712 | } |
| 1713 | } else if (isa<IntegerType>(DstTy) && |
| 1714 | cast<IntegerType>(DstTy)->getBitWidth() == 1) { |
| 1715 | // cast type %x to bool was previously defined as setne type %x, null |
| 1716 | // The cast semantic is now to truncate, not compare so we must retain |
| 1717 | // the original intent by replacing the cast with a setne |
| 1718 | Constant* Null = Constant::getNullValue(SrcTy); |
| 1719 | Instruction::OtherOps Opcode = Instruction::ICmp; |
| 1720 | unsigned short predicate = ICmpInst::ICMP_NE; |
| 1721 | if (SrcTy->isFloatingPoint()) { |
| 1722 | Opcode = Instruction::FCmp; |
| 1723 | predicate = FCmpInst::FCMP_ONE; |
| 1724 | } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) { |
| 1725 | error("Invalid cast to bool"); |
| 1726 | } |
| 1727 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1728 | return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null); |
| 1729 | else |
| 1730 | return CmpInst::create(Opcode, predicate, Src, Null); |
| 1731 | } |
| 1732 | // Determine the opcode to use by calling CastInst::getCastOpcode |
| 1733 | Opcode = |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1734 | CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy, |
| 1735 | DstSign.isSigned()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1736 | |
| 1737 | } else switch (op) { |
| 1738 | default: assert(0 && "Invalid cast token"); |
| 1739 | case TruncOp: Opcode = Instruction::Trunc; break; |
| 1740 | case ZExtOp: Opcode = Instruction::ZExt; break; |
| 1741 | case SExtOp: Opcode = Instruction::SExt; break; |
| 1742 | case FPTruncOp: Opcode = Instruction::FPTrunc; break; |
| 1743 | case FPExtOp: Opcode = Instruction::FPExt; break; |
| 1744 | case FPToUIOp: Opcode = Instruction::FPToUI; break; |
| 1745 | case FPToSIOp: Opcode = Instruction::FPToSI; break; |
| 1746 | case UIToFPOp: Opcode = Instruction::UIToFP; break; |
| 1747 | case SIToFPOp: Opcode = Instruction::SIToFP; break; |
| 1748 | case PtrToIntOp: Opcode = Instruction::PtrToInt; break; |
| 1749 | case IntToPtrOp: Opcode = Instruction::IntToPtr; break; |
| 1750 | case BitCastOp: Opcode = Instruction::BitCast; break; |
| 1751 | } |
| 1752 | |
| 1753 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1754 | return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy); |
| 1755 | return CastInst::create(Opcode, Src, DstTy); |
| 1756 | } |
| 1757 | |
| 1758 | static Instruction * |
| 1759 | upgradeIntrinsicCall(const Type* RetTy, const ValID &ID, |
| 1760 | std::vector<Value*>& Args) { |
| 1761 | |
| 1762 | std::string Name = ID.Type == ValID::NameVal ? ID.Name : ""; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 1763 | if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' || |
| 1764 | Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.') |
| 1765 | return 0; |
| 1766 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1767 | switch (Name[5]) { |
| 1768 | case 'i': |
| 1769 | if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") { |
| 1770 | if (Args.size() != 2) |
| 1771 | error("Invalid prototype for " + Name); |
| 1772 | return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]); |
| 1773 | } |
| 1774 | break; |
Reid Spencer | 8166a6c | 2007-04-02 02:08:35 +0000 | [diff] [blame] | 1775 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1776 | case 'v' : { |
| 1777 | const Type* PtrTy = PointerType::get(Type::Int8Ty); |
| 1778 | std::vector<const Type*> Params; |
| 1779 | if (Name == "llvm.va_start" || Name == "llvm.va_end") { |
| 1780 | if (Args.size() != 1) |
| 1781 | error("Invalid prototype for " + Name + " prototype"); |
| 1782 | Params.push_back(PtrTy); |
| 1783 | const FunctionType *FTy = |
| 1784 | FunctionType::get(Type::VoidTy, Params, false); |
| 1785 | const PointerType *PFTy = PointerType::get(FTy); |
| 1786 | Value* Func = getVal(PFTy, ID); |
| 1787 | Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 1788 | return new CallInst(Func, Args.begin(), Args.end()); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1789 | } else if (Name == "llvm.va_copy") { |
| 1790 | if (Args.size() != 2) |
| 1791 | error("Invalid prototype for " + Name + " prototype"); |
| 1792 | Params.push_back(PtrTy); |
| 1793 | Params.push_back(PtrTy); |
| 1794 | const FunctionType *FTy = |
| 1795 | FunctionType::get(Type::VoidTy, Params, false); |
| 1796 | const PointerType *PFTy = PointerType::get(FTy); |
| 1797 | Value* Func = getVal(PFTy, ID); |
| 1798 | std::string InstName0(makeNameUnique("va0")); |
| 1799 | std::string InstName1(makeNameUnique("va1")); |
| 1800 | Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB); |
| 1801 | Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 1802 | return new CallInst(Func, Args.begin(), Args.end()); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1803 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1804 | } |
| 1805 | } |
| 1806 | return 0; |
| 1807 | } |
| 1808 | |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1809 | const Type* upgradeGEPCEIndices(const Type* PTy, |
| 1810 | std::vector<ValueInfo> *Indices, |
| 1811 | std::vector<Constant*> &Result) { |
| 1812 | const Type *Ty = PTy; |
| 1813 | Result.clear(); |
| 1814 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1815 | Constant *Index = cast<Constant>((*Indices)[i].V); |
| 1816 | |
| 1817 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1818 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1819 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1820 | if (CI->getBitWidth() < 32) |
| 1821 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1822 | } |
| 1823 | |
| 1824 | if (isa<SequentialType>(Ty)) { |
| 1825 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1826 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1827 | // all indices for SequentialType elements. We must retain the same |
| 1828 | // semantic (zext) for unsigned types. |
| 1829 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
| 1830 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
| 1831 | Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty); |
| 1832 | } |
| 1833 | } |
| 1834 | } |
| 1835 | Result.push_back(Index); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1836 | Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(), |
| 1837 | Result.end(),true); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1838 | if (!Ty) |
| 1839 | error("Index list invalid for constant getelementptr"); |
| 1840 | } |
| 1841 | return Ty; |
| 1842 | } |
| 1843 | |
| 1844 | const Type* upgradeGEPInstIndices(const Type* PTy, |
| 1845 | std::vector<ValueInfo> *Indices, |
| 1846 | std::vector<Value*> &Result) { |
| 1847 | const Type *Ty = PTy; |
| 1848 | Result.clear(); |
| 1849 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1850 | Value *Index = (*Indices)[i].V; |
| 1851 | |
| 1852 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1853 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1854 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1855 | if (CI->getBitWidth() < 32) |
| 1856 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1857 | } |
| 1858 | |
| 1859 | |
| 1860 | if (isa<StructType>(Ty)) { // Only change struct indices |
| 1861 | if (!isa<Constant>(Index)) { |
| 1862 | error("Invalid non-constant structure index"); |
| 1863 | return 0; |
| 1864 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1865 | } else { |
| 1866 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1867 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1868 | // all indices for SequentialType elements. We must retain the same |
| 1869 | // semantic (zext) for unsigned types. |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1870 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1871 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1872 | if (isa<Constant>(Index)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1873 | Index = ConstantExpr::getCast(Instruction::ZExt, |
| 1874 | cast<Constant>(Index), Type::Int64Ty); |
| 1875 | else |
| 1876 | Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty, |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1877 | makeNameUnique("gep"), CurBB); |
Reid Spencer | 38f682b | 2007-01-26 20:31:18 +0000 | [diff] [blame] | 1878 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1879 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1880 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1881 | Result.push_back(Index); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1882 | Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(), |
| 1883 | Result.end(),true); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1884 | if (!Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1885 | error("Index list invalid for constant getelementptr"); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1886 | } |
| 1887 | return Ty; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1888 | } |
| 1889 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 1890 | unsigned upgradeCallingConv(unsigned CC) { |
| 1891 | switch (CC) { |
| 1892 | case OldCallingConv::C : return CallingConv::C; |
| 1893 | case OldCallingConv::CSRet : return CallingConv::C; |
| 1894 | case OldCallingConv::Fast : return CallingConv::Fast; |
| 1895 | case OldCallingConv::Cold : return CallingConv::Cold; |
| 1896 | case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall; |
| 1897 | case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall; |
| 1898 | default: |
| 1899 | return CC; |
| 1900 | } |
| 1901 | } |
| 1902 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1903 | Module* UpgradeAssembly(const std::string &infile, std::istream& in, |
| 1904 | bool debug, bool addAttrs) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1905 | { |
| 1906 | Upgradelineno = 1; |
| 1907 | CurFilename = infile; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 1908 | LexInput = ∈ |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1909 | yydebug = debug; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 1910 | AddAttributes = addAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1911 | ObsoleteVarArgs = false; |
| 1912 | NewVarArgs = false; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1913 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1914 | CurModule.CurrentModule = new Module(CurFilename); |
| 1915 | |
| 1916 | // Check to make sure the parser succeeded |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1917 | if (yyparse()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1918 | if (ParserResult) |
| 1919 | delete ParserResult; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1920 | std::cerr << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1921 | return 0; |
| 1922 | } |
| 1923 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1924 | // Check to make sure that parsing produced a result |
| 1925 | if (!ParserResult) { |
| 1926 | std::cerr << "llvm-upgrade: no parse result.\n"; |
| 1927 | return 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1928 | } |
| 1929 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1930 | // Reset ParserResult variable while saving its value for the result. |
| 1931 | Module *Result = ParserResult; |
| 1932 | ParserResult = 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1933 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1934 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1935 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1936 | Function* F; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1937 | if ((F = Result->getFunction("llvm.va_start")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1938 | && F->getFunctionType()->getNumParams() == 0) |
| 1939 | ObsoleteVarArgs = true; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1940 | if((F = Result->getFunction("llvm.va_copy")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1941 | && F->getFunctionType()->getNumParams() == 1) |
| 1942 | ObsoleteVarArgs = true; |
Reid Spencer | 280d801 | 2006-12-01 23:40:53 +0000 | [diff] [blame] | 1943 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1944 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1945 | if (ObsoleteVarArgs && NewVarArgs) { |
| 1946 | error("This file is corrupt: it uses both new and old style varargs"); |
| 1947 | return 0; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1948 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1949 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1950 | if(ObsoleteVarArgs) { |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1951 | if(Function* F = Result->getFunction("llvm.va_start")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1952 | if (F->arg_size() != 0) { |
| 1953 | error("Obsolete va_start takes 0 argument"); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1954 | return 0; |
| 1955 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1956 | |
| 1957 | //foo = va_start() |
| 1958 | // -> |
| 1959 | //bar = alloca typeof(foo) |
| 1960 | //va_start(bar) |
| 1961 | //foo = load bar |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1962 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1963 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1964 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1965 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1966 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 1967 | "llvm.va_start", RetTy, ArgTyPtr, (Type *)0)); |
| 1968 | |
| 1969 | while (!F->use_empty()) { |
| 1970 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1971 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 1972 | new CallInst(NF, bar, "", CI); |
| 1973 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 1974 | CI->replaceAllUsesWith(foo); |
| 1975 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1976 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1977 | Result->getFunctionList().erase(F); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1978 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1979 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1980 | if(Function* F = Result->getFunction("llvm.va_end")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1981 | if(F->arg_size() != 1) { |
| 1982 | error("Obsolete va_end takes 1 argument"); |
| 1983 | return 0; |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1984 | } |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1985 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1986 | //vaend foo |
| 1987 | // -> |
| 1988 | //bar = alloca 1 of typeof(foo) |
| 1989 | //vaend bar |
| 1990 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1991 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 1992 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1993 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 1994 | "llvm.va_end", RetTy, ArgTyPtr, (Type *)0)); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1995 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1996 | while (!F->use_empty()) { |
| 1997 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1998 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 1999 | new StoreInst(CI->getOperand(1), bar, CI); |
| 2000 | new CallInst(NF, bar, "", CI); |
| 2001 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2002 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2003 | Result->getFunctionList().erase(F); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2004 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2005 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2006 | if(Function* F = Result->getFunction("llvm.va_copy")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2007 | if(F->arg_size() != 1) { |
| 2008 | error("Obsolete va_copy takes 1 argument"); |
| 2009 | return 0; |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2010 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2011 | //foo = vacopy(bar) |
| 2012 | // -> |
| 2013 | //a = alloca 1 of typeof(foo) |
| 2014 | //b = alloca 1 of typeof(foo) |
| 2015 | //store bar -> b |
| 2016 | //vacopy(a, b) |
| 2017 | //foo = load a |
| 2018 | |
| 2019 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2020 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2021 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2022 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2023 | "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0)); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2024 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2025 | while (!F->use_empty()) { |
| 2026 | CallInst* CI = cast<CallInst>(F->use_back()); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2027 | Value *Args[2] = { |
| 2028 | new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI), |
| 2029 | new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI) |
| 2030 | }; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 2031 | new StoreInst(CI->getOperand(1), Args[1], CI); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2032 | new CallInst(NF, Args, Args + 2, "", CI); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 2033 | Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2034 | CI->replaceAllUsesWith(foo); |
| 2035 | CI->getParent()->getInstList().erase(CI); |
| 2036 | } |
| 2037 | Result->getFunctionList().erase(F); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2038 | } |
| 2039 | } |
| 2040 | |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 2041 | return Result; |
| 2042 | } |
| 2043 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2044 | } // end llvm namespace |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2045 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2046 | using namespace llvm; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2047 | |
| 2048 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2049 | |
| 2050 | /* Enabling traces. */ |
| 2051 | #ifndef YYDEBUG |
| 2052 | # define YYDEBUG 0 |
| 2053 | #endif |
| 2054 | |
| 2055 | /* Enabling verbose error messages. */ |
| 2056 | #ifdef YYERROR_VERBOSE |
| 2057 | # undef YYERROR_VERBOSE |
| 2058 | # define YYERROR_VERBOSE 1 |
| 2059 | #else |
| 2060 | # define YYERROR_VERBOSE 0 |
| 2061 | #endif |
| 2062 | |
| 2063 | /* Enabling the token table. */ |
| 2064 | #ifndef YYTOKEN_TABLE |
| 2065 | # define YYTOKEN_TABLE 0 |
| 2066 | #endif |
| 2067 | |
| 2068 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 2069 | typedef union YYSTYPE |
| 2070 | #line 1680 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 2071 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2072 | llvm::Module *ModuleVal; |
| 2073 | llvm::Function *FunctionVal; |
| 2074 | std::pair<llvm::PATypeInfo, char*> *ArgVal; |
| 2075 | llvm::BasicBlock *BasicBlockVal; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 2076 | llvm::TermInstInfo TermInstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2077 | llvm::InstrInfo InstVal; |
| 2078 | llvm::ConstInfo ConstVal; |
| 2079 | llvm::ValueInfo ValueVal; |
| 2080 | llvm::PATypeInfo TypeVal; |
| 2081 | llvm::TypeInfo PrimType; |
| 2082 | llvm::PHIListInfo PHIList; |
| 2083 | std::list<llvm::PATypeInfo> *TypeList; |
| 2084 | std::vector<llvm::ValueInfo> *ValueList; |
| 2085 | std::vector<llvm::ConstInfo> *ConstVector; |
| 2086 | |
| 2087 | |
| 2088 | std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList; |
| 2089 | // Represent the RHS of PHI node |
| 2090 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 2091 | |
| 2092 | llvm::GlobalValue::LinkageTypes Linkage; |
| 2093 | int64_t SInt64Val; |
| 2094 | uint64_t UInt64Val; |
| 2095 | int SIntVal; |
| 2096 | unsigned UIntVal; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 2097 | llvm::APFloat *FPVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2098 | bool BoolVal; |
| 2099 | |
| 2100 | char *StrVal; // This memory is strdup'd! |
| 2101 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 2102 | |
| 2103 | llvm::BinaryOps BinaryOpVal; |
| 2104 | llvm::TermOps TermOpVal; |
| 2105 | llvm::MemoryOps MemOpVal; |
| 2106 | llvm::OtherOps OtherOpVal; |
| 2107 | llvm::CastOps CastOpVal; |
| 2108 | llvm::ICmpInst::Predicate IPred; |
| 2109 | llvm::FCmpInst::Predicate FPred; |
| 2110 | llvm::Module::Endianness Endianness; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2111 | } |
| 2112 | /* Line 187 of yacc.c. */ |
| 2113 | #line 2114 "UpgradeParser.tab.c" |
| 2114 | YYSTYPE; |
| 2115 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 2116 | # define YYSTYPE_IS_DECLARED 1 |
| 2117 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2118 | #endif |
| 2119 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2120 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2121 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2122 | /* Copy the second part of user declarations. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2123 | |
| 2124 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2125 | /* Line 216 of yacc.c. */ |
| 2126 | #line 2127 "UpgradeParser.tab.c" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2127 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2128 | #ifdef short |
| 2129 | # undef short |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2130 | #endif |
| 2131 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2132 | #ifdef YYTYPE_UINT8 |
| 2133 | typedef YYTYPE_UINT8 yytype_uint8; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2134 | #else |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2135 | typedef unsigned char yytype_uint8; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2136 | #endif |
| 2137 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2138 | #ifdef YYTYPE_INT8 |
| 2139 | typedef YYTYPE_INT8 yytype_int8; |
| 2140 | #elif (defined __STDC__ || defined __C99__FUNC__ \ |
| 2141 | || defined __cplusplus || defined _MSC_VER) |
| 2142 | typedef signed char yytype_int8; |
| 2143 | #else |
| 2144 | typedef short int yytype_int8; |
| 2145 | #endif |
| 2146 | |
| 2147 | #ifdef YYTYPE_UINT16 |
| 2148 | typedef YYTYPE_UINT16 yytype_uint16; |
| 2149 | #else |
| 2150 | typedef unsigned short int yytype_uint16; |
| 2151 | #endif |
| 2152 | |
| 2153 | #ifdef YYTYPE_INT16 |
| 2154 | typedef YYTYPE_INT16 yytype_int16; |
| 2155 | #else |
| 2156 | typedef short int yytype_int16; |
| 2157 | #endif |
| 2158 | |
| 2159 | #ifndef YYSIZE_T |
| 2160 | # ifdef __SIZE_TYPE__ |
| 2161 | # define YYSIZE_T __SIZE_TYPE__ |
| 2162 | # elif defined size_t |
| 2163 | # define YYSIZE_T size_t |
| 2164 | # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ |
| 2165 | || defined __cplusplus || defined _MSC_VER) |
| 2166 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 2167 | # define YYSIZE_T size_t |
| 2168 | # else |
| 2169 | # define YYSIZE_T unsigned int |
| 2170 | # endif |
| 2171 | #endif |
| 2172 | |
| 2173 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
| 2174 | |
| 2175 | #ifndef YY_ |
| 2176 | # if YYENABLE_NLS |
| 2177 | # if ENABLE_NLS |
| 2178 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 2179 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 2180 | # endif |
| 2181 | # endif |
| 2182 | # ifndef YY_ |
| 2183 | # define YY_(msgid) msgid |
| 2184 | # endif |
| 2185 | #endif |
| 2186 | |
| 2187 | /* Suppress unused-variable warnings by "using" E. */ |
| 2188 | #if ! defined lint || defined __GNUC__ |
| 2189 | # define YYUSE(e) ((void) (e)) |
| 2190 | #else |
| 2191 | # define YYUSE(e) /* empty */ |
| 2192 | #endif |
| 2193 | |
| 2194 | /* Identity function, used to suppress warnings about constant conditions. */ |
| 2195 | #ifndef lint |
| 2196 | # define YYID(n) (n) |
| 2197 | #else |
| 2198 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2199 | || defined __cplusplus || defined _MSC_VER) |
| 2200 | static int |
| 2201 | YYID (int i) |
| 2202 | #else |
| 2203 | static int |
| 2204 | YYID (i) |
| 2205 | int i; |
| 2206 | #endif |
| 2207 | { |
| 2208 | return i; |
| 2209 | } |
| 2210 | #endif |
| 2211 | |
| 2212 | #if ! defined yyoverflow || YYERROR_VERBOSE |
| 2213 | |
| 2214 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 2215 | |
| 2216 | # ifdef YYSTACK_USE_ALLOCA |
| 2217 | # if YYSTACK_USE_ALLOCA |
| 2218 | # ifdef __GNUC__ |
| 2219 | # define YYSTACK_ALLOC __builtin_alloca |
| 2220 | # elif defined __BUILTIN_VA_ARG_INCR |
| 2221 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ |
| 2222 | # elif defined _AIX |
| 2223 | # define YYSTACK_ALLOC __alloca |
| 2224 | # elif defined _MSC_VER |
| 2225 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ |
| 2226 | # define alloca _alloca |
| 2227 | # else |
| 2228 | # define YYSTACK_ALLOC alloca |
| 2229 | # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
| 2230 | || defined __cplusplus || defined _MSC_VER) |
| 2231 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 2232 | # ifndef _STDLIB_H |
| 2233 | # define _STDLIB_H 1 |
| 2234 | # endif |
| 2235 | # endif |
| 2236 | # endif |
| 2237 | # endif |
| 2238 | # endif |
| 2239 | |
| 2240 | # ifdef YYSTACK_ALLOC |
| 2241 | /* Pacify GCC's `empty if-body' warning. */ |
| 2242 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) |
| 2243 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 2244 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 2245 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 2246 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 2247 | to allow for a few compiler-allocated temporary stack slots. */ |
| 2248 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ |
| 2249 | # endif |
| 2250 | # else |
| 2251 | # define YYSTACK_ALLOC YYMALLOC |
| 2252 | # define YYSTACK_FREE YYFREE |
| 2253 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 2254 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
| 2255 | # endif |
| 2256 | # if (defined __cplusplus && ! defined _STDLIB_H \ |
| 2257 | && ! ((defined YYMALLOC || defined malloc) \ |
| 2258 | && (defined YYFREE || defined free))) |
| 2259 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 2260 | # ifndef _STDLIB_H |
| 2261 | # define _STDLIB_H 1 |
| 2262 | # endif |
| 2263 | # endif |
| 2264 | # ifndef YYMALLOC |
| 2265 | # define YYMALLOC malloc |
| 2266 | # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
| 2267 | || defined __cplusplus || defined _MSC_VER) |
| 2268 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 2269 | # endif |
| 2270 | # endif |
| 2271 | # ifndef YYFREE |
| 2272 | # define YYFREE free |
| 2273 | # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
| 2274 | || defined __cplusplus || defined _MSC_VER) |
| 2275 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 2276 | # endif |
| 2277 | # endif |
| 2278 | # endif |
| 2279 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ |
| 2280 | |
| 2281 | |
| 2282 | #if (! defined yyoverflow \ |
| 2283 | && (! defined __cplusplus \ |
| 2284 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) |
| 2285 | |
| 2286 | /* A type that is properly aligned for any stack member. */ |
| 2287 | union yyalloc |
| 2288 | { |
| 2289 | yytype_int16 yyss; |
| 2290 | YYSTYPE yyvs; |
| 2291 | }; |
| 2292 | |
| 2293 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 2294 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 2295 | |
| 2296 | /* The size of an array large to enough to hold all stacks, each with |
| 2297 | N elements. */ |
| 2298 | # define YYSTACK_BYTES(N) \ |
| 2299 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ |
| 2300 | + YYSTACK_GAP_MAXIMUM) |
| 2301 | |
| 2302 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 2303 | not overlap. */ |
| 2304 | # ifndef YYCOPY |
| 2305 | # if defined __GNUC__ && 1 < __GNUC__ |
| 2306 | # define YYCOPY(To, From, Count) \ |
| 2307 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 2308 | # else |
| 2309 | # define YYCOPY(To, From, Count) \ |
| 2310 | do \ |
| 2311 | { \ |
| 2312 | YYSIZE_T yyi; \ |
| 2313 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 2314 | (To)[yyi] = (From)[yyi]; \ |
| 2315 | } \ |
| 2316 | while (YYID (0)) |
| 2317 | # endif |
| 2318 | # endif |
| 2319 | |
| 2320 | /* Relocate STACK from its old location to the new one. The |
| 2321 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 2322 | elements in the stack, and YYPTR gives the new location of the |
| 2323 | stack. Advance YYPTR to a properly aligned location for the next |
| 2324 | stack. */ |
| 2325 | # define YYSTACK_RELOCATE(Stack) \ |
| 2326 | do \ |
| 2327 | { \ |
| 2328 | YYSIZE_T yynewbytes; \ |
| 2329 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 2330 | Stack = &yyptr->Stack; \ |
| 2331 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 2332 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 2333 | } \ |
| 2334 | while (YYID (0)) |
| 2335 | |
| 2336 | #endif |
| 2337 | |
| 2338 | /* YYFINAL -- State number of the termination state. */ |
| 2339 | #define YYFINAL 4 |
| 2340 | /* YYLAST -- Last index in YYTABLE. */ |
| 2341 | #define YYLAST 1630 |
| 2342 | |
| 2343 | /* YYNTOKENS -- Number of terminals. */ |
| 2344 | #define YYNTOKENS 166 |
| 2345 | /* YYNNTS -- Number of nonterminals. */ |
| 2346 | #define YYNNTS 81 |
| 2347 | /* YYNRULES -- Number of rules. */ |
| 2348 | #define YYNRULES 310 |
| 2349 | /* YYNRULES -- Number of states. */ |
| 2350 | #define YYNSTATES 606 |
| 2351 | |
| 2352 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 2353 | #define YYUNDEFTOK 2 |
| 2354 | #define YYMAXUTOK 406 |
| 2355 | |
| 2356 | #define YYTRANSLATE(YYX) \ |
| 2357 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 2358 | |
| 2359 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 2360 | static const yytype_uint8 yytranslate[] = |
| 2361 | { |
| 2362 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2363 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2364 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2365 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2366 | 155, 156, 164, 2, 153, 2, 2, 2, 2, 2, |
| 2367 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2368 | 160, 152, 161, 2, 2, 2, 2, 2, 2, 2, |
| 2369 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2370 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2371 | 2, 157, 154, 159, 2, 2, 2, 2, 2, 165, |
| 2372 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2373 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2374 | 158, 2, 2, 162, 2, 163, 2, 2, 2, 2, |
| 2375 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2376 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2377 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2378 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2379 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2380 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2381 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2382 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2383 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2384 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2385 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2386 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2387 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 2388 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 2389 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 2390 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 2391 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 2392 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 2393 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 2394 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 2395 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2396 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2397 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2398 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 2399 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2400 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
| 2401 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 2402 | 145, 146, 147, 148, 149, 150, 151 |
| 2403 | }; |
| 2404 | |
| 2405 | #if YYDEBUG |
| 2406 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 2407 | YYRHS. */ |
| 2408 | static const yytype_uint16 yyprhs[] = |
| 2409 | { |
| 2410 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 2411 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 2412 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 2413 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 2414 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 2415 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 2416 | 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, |
| 2417 | 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, |
| 2418 | 159, 161, 164, 165, 167, 169, 171, 173, 175, 177, |
| 2419 | 179, 180, 181, 183, 185, 187, 189, 191, 193, 196, |
| 2420 | 197, 200, 201, 205, 208, 209, 211, 212, 216, 218, |
| 2421 | 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, |
| 2422 | 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, |
| 2423 | 261, 264, 269, 275, 281, 285, 288, 294, 299, 302, |
| 2424 | 304, 308, 310, 314, 316, 317, 322, 326, 330, 335, |
| 2425 | 340, 344, 351, 357, 360, 363, 366, 369, 372, 375, |
| 2426 | 378, 381, 384, 387, 394, 400, 409, 416, 423, 430, |
| 2427 | 438, 446, 453, 460, 469, 478, 482, 484, 486, 488, |
| 2428 | 490, 493, 496, 501, 504, 506, 511, 514, 519, 520, |
| 2429 | 528, 529, 537, 538, 546, 547, 555, 559, 564, 565, |
| 2430 | 567, 569, 571, 575, 579, 583, 587, 591, 595, 597, |
| 2431 | 598, 600, 602, 604, 605, 608, 612, 614, 616, 620, |
| 2432 | 622, 623, 632, 634, 636, 637, 642, 644, 646, 649, |
| 2433 | 650, 652, 654, 655, 656, 662, 663, 665, 667, 669, |
| 2434 | 671, 673, 675, 677, 679, 681, 685, 687, 693, 695, |
| 2435 | 697, 699, 701, 704, 707, 710, 714, 717, 718, 720, |
| 2436 | 722, 724, 727, 730, 734, 744, 754, 763, 777, 779, |
| 2437 | 781, 788, 794, 797, 804, 812, 814, 818, 820, 821, |
| 2438 | 824, 826, 832, 838, 844, 851, 858, 861, 866, 871, |
| 2439 | 878, 883, 888, 893, 898, 905, 912, 915, 923, 925, |
| 2440 | 928, 929, 931, 932, 936, 943, 947, 954, 957, 962, |
| 2441 | 969 |
| 2442 | }; |
| 2443 | |
| 2444 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 2445 | static const yytype_int16 yyrhs[] = |
| 2446 | { |
| 2447 | 200, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
| 2448 | -1, 79, -1, 80, -1, 81, -1, 82, -1, 83, |
| 2449 | -1, 84, -1, 85, -1, 86, -1, 87, -1, 88, |
| 2450 | -1, 89, -1, 90, -1, 91, -1, 92, -1, 97, |
| 2451 | -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, |
| 2452 | -1, 119, -1, 120, -1, 121, -1, 122, -1, 123, |
| 2453 | -1, 124, -1, 125, -1, 126, -1, 127, -1, 128, |
| 2454 | -1, 129, -1, 130, -1, 131, -1, 132, -1, 133, |
| 2455 | -1, 134, -1, 135, -1, 136, -1, 137, -1, 138, |
| 2456 | -1, 125, -1, 126, -1, 127, -1, 128, -1, 27, |
| 2457 | -1, 28, -1, 93, -1, 94, -1, 95, -1, 96, |
| 2458 | -1, 140, -1, 141, -1, 142, -1, 143, -1, 144, |
| 2459 | -1, 145, -1, 146, -1, 147, -1, 148, -1, 149, |
| 2460 | -1, 150, -1, 151, -1, 139, -1, 16, -1, 14, |
| 2461 | -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, |
| 2462 | -1, 11, -1, 176, -1, 177, -1, 18, -1, 19, |
| 2463 | -1, 212, 152, -1, -1, 41, -1, 42, -1, 43, |
| 2464 | -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, |
| 2465 | -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, |
| 2466 | -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, |
| 2467 | -1, 153, 57, 4, -1, 34, 24, -1, -1, 185, |
| 2468 | -1, -1, 153, 188, 187, -1, 185, -1, 57, 4, |
| 2469 | -1, 191, -1, 8, -1, 193, -1, 8, -1, 193, |
| 2470 | -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, |
| 2471 | -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, |
| 2472 | -1, 19, -1, 21, -1, 192, -1, 48, -1, 229, |
| 2473 | -1, 154, 4, -1, 190, 155, 195, 156, -1, 157, |
| 2474 | 4, 158, 193, 159, -1, 160, 4, 158, 193, 161, |
| 2475 | -1, 162, 194, 163, -1, 162, 163, -1, 160, 162, |
| 2476 | 194, 163, 161, -1, 160, 162, 163, 161, -1, 193, |
| 2477 | 164, -1, 193, -1, 194, 153, 193, -1, 194, -1, |
| 2478 | 194, 153, 37, -1, 37, -1, -1, 191, 157, 198, |
| 2479 | 159, -1, 191, 157, 159, -1, 191, 165, 24, -1, |
| 2480 | 191, 160, 198, 161, -1, 191, 162, 198, 163, -1, |
| 2481 | 191, 162, 163, -1, 191, 160, 162, 198, 163, 161, |
| 2482 | -1, 191, 160, 162, 163, 161, -1, 191, 38, -1, |
| 2483 | 191, 39, -1, 191, 229, -1, 191, 197, -1, 191, |
| 2484 | 26, -1, 176, 168, -1, 177, 4, -1, 9, 27, |
| 2485 | -1, 9, 28, -1, 179, 7, -1, 175, 155, 196, |
| 2486 | 36, 191, 156, -1, 110, 155, 196, 244, 156, -1, |
| 2487 | 112, 155, 196, 153, 196, 153, 196, 156, -1, 169, |
| 2488 | 155, 196, 153, 196, 156, -1, 170, 155, 196, 153, |
| 2489 | 196, 156, -1, 171, 155, 196, 153, 196, 156, -1, |
| 2490 | 103, 172, 155, 196, 153, 196, 156, -1, 104, 173, |
| 2491 | 155, 196, 153, 196, 156, -1, 174, 155, 196, 153, |
| 2492 | 196, 156, -1, 114, 155, 196, 153, 196, 156, -1, |
| 2493 | 115, 155, 196, 153, 196, 153, 196, 156, -1, 116, |
| 2494 | 155, 196, 153, 196, 153, 196, 156, -1, 198, 153, |
| 2495 | 196, -1, 196, -1, 32, -1, 33, -1, 201, -1, |
| 2496 | 201, 222, -1, 201, 224, -1, 201, 62, 61, 207, |
| 2497 | -1, 201, 25, -1, 202, -1, 202, 180, 20, 189, |
| 2498 | -1, 202, 224, -1, 202, 62, 61, 207, -1, -1, |
| 2499 | 202, 180, 181, 199, 196, 203, 187, -1, -1, 202, |
| 2500 | 180, 50, 199, 191, 204, 187, -1, -1, 202, 180, |
| 2501 | 45, 199, 191, 205, 187, -1, -1, 202, 180, 47, |
| 2502 | 199, 191, 206, 187, -1, 202, 51, 209, -1, 202, |
| 2503 | 58, 152, 210, -1, -1, 24, -1, 56, -1, 55, |
| 2504 | -1, 53, 152, 208, -1, 54, 152, 4, -1, 52, |
| 2505 | 152, 24, -1, 71, 152, 24, -1, 157, 211, 159, |
| 2506 | -1, 211, 153, 24, -1, 24, -1, -1, 22, -1, |
| 2507 | 24, -1, 212, -1, -1, 191, 213, -1, 215, 153, |
| 2508 | 214, -1, 214, -1, 215, -1, 215, 153, 37, -1, |
| 2509 | 37, -1, -1, 182, 189, 212, 155, 216, 156, 186, |
| 2510 | 183, -1, 29, -1, 162, -1, -1, 181, 220, 217, |
| 2511 | 218, -1, 30, -1, 163, -1, 232, 221, -1, -1, |
| 2512 | 45, -1, 47, -1, -1, -1, 31, 225, 223, 226, |
| 2513 | 217, -1, -1, 63, -1, 3, -1, 4, -1, 7, |
| 2514 | -1, 27, -1, 28, -1, 38, -1, 39, -1, 26, |
| 2515 | -1, 160, 198, 161, -1, 197, -1, 61, 227, 24, |
| 2516 | 153, 24, -1, 167, -1, 212, -1, 229, -1, 228, |
| 2517 | -1, 191, 230, -1, 232, 233, -1, 219, 233, -1, |
| 2518 | 234, 180, 236, -1, 234, 238, -1, -1, 23, -1, |
| 2519 | 77, -1, 78, -1, 72, 231, -1, 72, 8, -1, |
| 2520 | 73, 21, 230, -1, 73, 9, 230, 153, 21, 230, |
| 2521 | 153, 21, 230, -1, 74, 178, 230, 153, 21, 230, |
| 2522 | 157, 237, 159, -1, 74, 178, 230, 153, 21, 230, |
| 2523 | 157, 159, -1, 75, 182, 189, 230, 155, 241, 156, |
| 2524 | 36, 21, 230, 235, 21, 230, -1, 235, -1, 76, |
| 2525 | -1, 237, 178, 228, 153, 21, 230, -1, 178, 228, |
| 2526 | 153, 21, 230, -1, 180, 243, -1, 191, 157, 230, |
| 2527 | 153, 230, 159, -1, 239, 153, 157, 230, 153, 230, |
| 2528 | 159, -1, 231, -1, 240, 153, 231, -1, 240, -1, |
| 2529 | -1, 60, 59, -1, 59, -1, 169, 191, 230, 153, |
| 2530 | 230, -1, 170, 191, 230, 153, 230, -1, 171, 191, |
| 2531 | 230, 153, 230, -1, 103, 172, 191, 230, 153, 230, |
| 2532 | -1, 104, 173, 191, 230, 153, 230, -1, 49, 231, |
| 2533 | -1, 174, 231, 153, 231, -1, 175, 231, 36, 191, |
| 2534 | -1, 112, 231, 153, 231, 153, 231, -1, 113, 231, |
| 2535 | 153, 191, -1, 117, 231, 153, 191, -1, 118, 231, |
| 2536 | 153, 191, -1, 114, 231, 153, 231, -1, 115, 231, |
| 2537 | 153, 231, 153, 231, -1, 116, 231, 153, 231, 153, |
| 2538 | 231, -1, 111, 239, -1, 242, 182, 189, 230, 155, |
| 2539 | 241, 156, -1, 246, -1, 153, 240, -1, -1, 35, |
| 2540 | -1, -1, 105, 191, 184, -1, 105, 191, 153, 15, |
| 2541 | 230, 184, -1, 106, 191, 184, -1, 106, 191, 153, |
| 2542 | 15, 230, 184, -1, 107, 231, -1, 245, 108, 191, |
| 2543 | 230, -1, 245, 109, 231, 153, 191, 230, -1, 110, |
| 2544 | 191, 230, 244, -1 |
| 2545 | }; |
| 2546 | |
| 2547 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 2548 | static const yytype_uint16 yyrline[] = |
| 2549 | { |
| 2550 | 0, 1820, 1820, 1821, 1829, 1830, 1840, 1840, 1840, 1840, |
| 2551 | 1840, 1840, 1840, 1840, 1840, 1840, 1840, 1844, 1844, 1844, |
| 2552 | 1848, 1848, 1848, 1848, 1848, 1848, 1852, 1852, 1853, 1853, |
| 2553 | 1854, 1854, 1855, 1855, 1856, 1856, 1860, 1860, 1861, 1861, |
| 2554 | 1862, 1862, 1863, 1863, 1864, 1864, 1865, 1865, 1866, 1866, |
| 2555 | 1867, 1868, 1871, 1871, 1871, 1871, 1875, 1875, 1875, 1875, |
| 2556 | 1875, 1875, 1875, 1876, 1876, 1876, 1876, 1876, 1876, 1882, |
| 2557 | 1882, 1882, 1882, 1886, 1886, 1886, 1886, 1890, 1890, 1894, |
| 2558 | 1894, 1899, 1902, 1907, 1908, 1909, 1910, 1911, 1912, 1913, |
| 2559 | 1914, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1935, |
| 2560 | 1936, 1944, 1945, 1953, 1962, 1963, 1970, 1971, 1975, 1979, |
| 2561 | 1995, 1996, 2003, 2004, 2011, 2019, 2019, 2019, 2019, 2019, |
| 2562 | 2019, 2019, 2020, 2020, 2020, 2020, 2020, 2025, 2029, 2033, |
| 2563 | 2038, 2047, 2074, 2080, 2093, 2104, 2108, 2121, 2125, 2139, |
| 2564 | 2143, 2150, 2151, 2157, 2164, 2176, 2206, 2219, 2242, 2270, |
| 2565 | 2292, 2303, 2325, 2336, 2345, 2350, 2409, 2416, 2424, 2431, |
| 2566 | 2438, 2442, 2446, 2460, 2475, 2487, 2496, 2524, 2537, 2546, |
| 2567 | 2552, 2558, 2569, 2575, 2581, 2592, 2593, 2602, 2603, 2615, |
| 2568 | 2624, 2625, 2626, 2627, 2628, 2644, 2664, 2666, 2668, 2668, |
| 2569 | 2675, 2675, 2683, 2683, 2691, 2691, 2700, 2702, 2704, 2709, |
| 2570 | 2723, 2724, 2728, 2731, 2739, 2743, 2750, 2754, 2758, 2762, |
| 2571 | 2770, 2770, 2774, 2775, 2779, 2787, 2792, 2800, 2801, 2808, |
| 2572 | 2815, 2819, 3007, 3007, 3011, 3011, 3021, 3021, 3025, 3030, |
| 2573 | 3031, 3032, 3036, 3037, 3036, 3049, 3050, 3055, 3056, 3057, |
| 2574 | 3058, 3062, 3066, 3067, 3068, 3069, 3090, 3094, 3108, 3109, |
| 2575 | 3114, 3114, 3122, 3132, 3135, 3144, 3155, 3160, 3169, 3180, |
| 2576 | 3180, 3183, 3187, 3191, 3196, 3206, 3224, 3233, 3306, 3310, |
| 2577 | 3317, 3329, 3344, 3374, 3384, 3394, 3398, 3405, 3406, 3410, |
| 2578 | 3413, 3419, 3438, 3456, 3472, 3486, 3500, 3511, 3529, 3538, |
| 2579 | 3547, 3554, 3575, 3599, 3605, 3611, 3617, 3633, 3725, 3733, |
| 2580 | 3734, 3738, 3739, 3743, 3749, 3756, 3762, 3769, 3776, 3789, |
| 2581 | 3809 |
| 2582 | }; |
| 2583 | #endif |
| 2584 | |
| 2585 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 2586 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 2587 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 2588 | static const char *const yytname[] = |
| 2589 | { |
| 2590 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 2591 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 2592 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 2593 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 2594 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 2595 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 2596 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 2597 | "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 2598 | "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", |
| 2599 | "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", |
| 2600 | "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", |
| 2601 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 2602 | "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT", |
| 2603 | "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM", |
| 2604 | "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR", |
| 2605 | "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP", |
| 2606 | "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", |
| 2607 | "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", |
| 2608 | "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", |
| 2609 | "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", |
| 2610 | "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", |
| 2611 | "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR", |
| 2612 | "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", |
| 2613 | "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL", |
| 2614 | "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates", |
| 2615 | "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType", |
| 2616 | "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", |
| 2617 | "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes", |
| 2618 | "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", |
| 2619 | "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", |
| 2620 | "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", |
| 2621 | "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition", |
| 2622 | "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal", |
| 2623 | "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", |
| 2624 | "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7", |
| 2625 | "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", |
| 2626 | "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", |
| 2627 | "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList", |
| 2628 | "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList", |
| 2629 | "OptVolatile", "MemoryInst", 0 |
| 2630 | }; |
| 2631 | #endif |
| 2632 | |
| 2633 | # ifdef YYPRINT |
| 2634 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 2635 | token YYLEX-NUM. */ |
| 2636 | static const yytype_uint16 yytoknum[] = |
| 2637 | { |
| 2638 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 2639 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 2640 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 2641 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 2642 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 2643 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 2644 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 2645 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 2646 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 2647 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 2648 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 2649 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 2650 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 2651 | 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, |
| 2652 | 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, |
| 2653 | 405, 406, 61, 44, 92, 40, 41, 91, 120, 93, |
| 2654 | 60, 62, 123, 125, 42, 99 |
| 2655 | }; |
| 2656 | # endif |
| 2657 | |
| 2658 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 2659 | static const yytype_uint8 yyr1[] = |
| 2660 | { |
| 2661 | 0, 166, 167, 167, 168, 168, 169, 169, 169, 169, |
| 2662 | 169, 169, 169, 169, 169, 169, 169, 170, 170, 170, |
| 2663 | 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, |
| 2664 | 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, |
| 2665 | 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, |
| 2666 | 173, 173, 174, 174, 174, 174, 175, 175, 175, 175, |
| 2667 | 175, 175, 175, 175, 175, 175, 175, 175, 175, 176, |
| 2668 | 176, 176, 176, 177, 177, 177, 177, 178, 178, 179, |
| 2669 | 179, 180, 180, 181, 181, 181, 181, 181, 181, 181, |
| 2670 | 181, 182, 182, 182, 182, 182, 182, 182, 182, 183, |
| 2671 | 183, 184, 184, 185, 186, 186, 187, 187, 188, 188, |
| 2672 | 189, 189, 190, 190, 191, 192, 192, 192, 192, 192, |
| 2673 | 192, 192, 192, 192, 192, 192, 192, 193, 193, 193, |
| 2674 | 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, |
| 2675 | 194, 195, 195, 195, 195, 196, 196, 196, 196, 196, |
| 2676 | 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, |
| 2677 | 196, 196, 196, 197, 197, 197, 197, 197, 197, 197, |
| 2678 | 197, 197, 197, 197, 197, 198, 198, 199, 199, 200, |
| 2679 | 201, 201, 201, 201, 201, 202, 202, 202, 203, 202, |
| 2680 | 204, 202, 205, 202, 206, 202, 202, 202, 202, 207, |
| 2681 | 208, 208, 209, 209, 209, 209, 210, 211, 211, 211, |
| 2682 | 212, 212, 213, 213, 214, 215, 215, 216, 216, 216, |
| 2683 | 216, 217, 218, 218, 220, 219, 221, 221, 222, 223, |
| 2684 | 223, 223, 225, 226, 224, 227, 227, 228, 228, 228, |
| 2685 | 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, |
| 2686 | 230, 230, 231, 232, 232, 233, 234, 234, 234, 235, |
| 2687 | 235, 236, 236, 236, 236, 236, 236, 236, 236, 236, |
| 2688 | 237, 237, 238, 239, 239, 240, 240, 241, 241, 242, |
| 2689 | 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, |
| 2690 | 243, 243, 243, 243, 243, 243, 243, 243, 243, 244, |
| 2691 | 244, 245, 245, 246, 246, 246, 246, 246, 246, 246, |
| 2692 | 246 |
| 2693 | }; |
| 2694 | |
| 2695 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 2696 | static const yytype_uint8 yyr2[] = |
| 2697 | { |
| 2698 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2699 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2700 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2701 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2702 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2703 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2704 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2705 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2706 | 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, |
| 2707 | 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, |
| 2708 | 2, 0, 3, 2, 0, 1, 0, 3, 1, 2, |
| 2709 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2710 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2711 | 2, 4, 5, 5, 3, 2, 5, 4, 2, 1, |
| 2712 | 3, 1, 3, 1, 0, 4, 3, 3, 4, 4, |
| 2713 | 3, 6, 5, 2, 2, 2, 2, 2, 2, 2, |
| 2714 | 2, 2, 2, 6, 5, 8, 6, 6, 6, 7, |
| 2715 | 7, 6, 6, 8, 8, 3, 1, 1, 1, 1, |
| 2716 | 2, 2, 4, 2, 1, 4, 2, 4, 0, 7, |
| 2717 | 0, 7, 0, 7, 0, 7, 3, 4, 0, 1, |
| 2718 | 1, 1, 3, 3, 3, 3, 3, 3, 1, 0, |
| 2719 | 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, |
| 2720 | 0, 8, 1, 1, 0, 4, 1, 1, 2, 0, |
| 2721 | 1, 1, 0, 0, 5, 0, 1, 1, 1, 1, |
| 2722 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 2723 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 1, |
| 2724 | 1, 2, 2, 3, 9, 9, 8, 13, 1, 1, |
| 2725 | 6, 5, 2, 6, 7, 1, 3, 1, 0, 2, |
| 2726 | 1, 5, 5, 5, 6, 6, 2, 4, 4, 6, |
| 2727 | 4, 4, 4, 4, 6, 6, 2, 7, 1, 2, |
| 2728 | 0, 1, 0, 3, 6, 3, 6, 2, 4, 6, |
| 2729 | 4 |
| 2730 | }; |
| 2731 | |
| 2732 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 2733 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 2734 | means the default is an error. */ |
| 2735 | static const yytype_uint16 yydefact[] = |
| 2736 | { |
| 2737 | 198, 0, 90, 184, 1, 183, 232, 83, 84, 85, |
| 2738 | 86, 87, 88, 89, 0, 224, 257, 180, 181, 257, |
| 2739 | 210, 211, 0, 0, 0, 90, 0, 186, 229, 0, |
| 2740 | 91, 258, 254, 82, 226, 227, 228, 253, 0, 0, |
| 2741 | 0, 0, 196, 0, 0, 0, 0, 0, 0, 0, |
| 2742 | 81, 230, 231, 233, 199, 182, 0, 92, 93, 94, |
| 2743 | 95, 96, 97, 0, 0, 302, 256, 0, 0, 0, |
| 2744 | 0, 209, 197, 187, 2, 3, 111, 115, 116, 117, |
| 2745 | 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, |
| 2746 | 0, 0, 0, 0, 248, 185, 0, 110, 127, 114, |
| 2747 | 249, 129, 177, 178, 0, 0, 0, 0, 91, 98, |
| 2748 | 0, 222, 223, 225, 301, 0, 280, 0, 0, 0, |
| 2749 | 0, 91, 269, 259, 260, 6, 7, 8, 9, 10, |
| 2750 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 52, |
| 2751 | 53, 54, 55, 20, 21, 22, 23, 24, 25, 0, |
| 2752 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2753 | 0, 0, 0, 68, 56, 57, 58, 59, 60, 61, |
| 2754 | 62, 63, 64, 65, 66, 67, 0, 0, 0, 0, |
| 2755 | 0, 268, 255, 91, 272, 0, 298, 204, 201, 200, |
| 2756 | 202, 203, 205, 208, 0, 130, 0, 0, 0, 113, |
| 2757 | 135, 139, 0, 144, 138, 192, 194, 190, 115, 116, |
| 2758 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, |
| 2759 | 0, 0, 0, 188, 234, 0, 0, 286, 279, 262, |
| 2760 | 261, 0, 0, 72, 76, 71, 75, 70, 74, 69, |
| 2761 | 73, 77, 78, 0, 0, 26, 27, 28, 29, 30, |
| 2762 | 31, 32, 33, 34, 35, 0, 50, 51, 46, 47, |
| 2763 | 48, 49, 36, 37, 38, 39, 40, 41, 42, 43, |
| 2764 | 44, 45, 0, 101, 101, 307, 0, 0, 296, 0, |
| 2765 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2766 | 0, 0, 0, 0, 0, 206, 0, 0, 0, 0, |
| 2767 | 0, 134, 143, 141, 0, 106, 106, 106, 160, 161, |
| 2768 | 4, 5, 158, 159, 162, 157, 153, 154, 0, 0, |
| 2769 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2770 | 0, 0, 0, 0, 156, 155, 106, 220, 237, 238, |
| 2771 | 239, 244, 240, 241, 242, 243, 235, 0, 246, 251, |
| 2772 | 250, 252, 0, 263, 0, 0, 0, 0, 0, 303, |
| 2773 | 0, 305, 300, 0, 0, 0, 0, 0, 0, 0, |
| 2774 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2775 | 207, 112, 112, 137, 0, 140, 0, 131, 0, 193, |
| 2776 | 195, 191, 0, 0, 0, 0, 0, 0, 0, 146, |
| 2777 | 176, 0, 0, 0, 150, 0, 147, 0, 0, 0, |
| 2778 | 0, 0, 189, 219, 213, 216, 217, 0, 236, 0, |
| 2779 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2780 | 310, 0, 0, 0, 290, 293, 0, 0, 291, 292, |
| 2781 | 0, 0, 0, 287, 288, 0, 308, 0, 132, 133, |
| 2782 | 136, 142, 0, 0, 108, 106, 0, 0, 300, 0, |
| 2783 | 0, 0, 0, 0, 145, 135, 114, 0, 148, 149, |
| 2784 | 0, 0, 0, 0, 0, 212, 214, 0, 104, 0, |
| 2785 | 245, 0, 0, 278, 0, 0, 101, 102, 101, 275, |
| 2786 | 299, 0, 0, 0, 0, 0, 281, 282, 283, 278, |
| 2787 | 0, 103, 109, 107, 0, 0, 0, 0, 0, 0, |
| 2788 | 0, 175, 152, 0, 0, 0, 0, 0, 0, 218, |
| 2789 | 215, 105, 99, 0, 0, 0, 277, 0, 284, 285, |
| 2790 | 0, 304, 306, 0, 0, 0, 289, 294, 295, 0, |
| 2791 | 309, 0, 0, 164, 0, 0, 0, 0, 151, 0, |
| 2792 | 0, 0, 0, 0, 0, 221, 247, 0, 0, 0, |
| 2793 | 276, 273, 0, 297, 0, 0, 0, 172, 0, 0, |
| 2794 | 166, 167, 168, 171, 163, 100, 0, 266, 0, 0, |
| 2795 | 0, 274, 169, 170, 0, 0, 0, 264, 0, 265, |
| 2796 | 0, 0, 165, 173, 174, 0, 0, 0, 0, 0, |
| 2797 | 0, 271, 0, 0, 270, 267 |
| 2798 | }; |
| 2799 | |
| 2800 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 2801 | static const yytype_int16 yydefgoto[] = |
| 2802 | { |
| 2803 | -1, 94, 312, 329, 330, 331, 255, 272, 332, 333, |
| 2804 | 219, 220, 243, 221, 25, 15, 63, 555, 359, 454, |
| 2805 | 522, 389, 455, 95, 96, 222, 98, 99, 202, 304, |
| 2806 | 400, 348, 401, 104, 1, 2, 3, 336, 307, 305, |
| 2807 | 306, 55, 190, 42, 72, 194, 100, 476, 415, 416, |
| 2808 | 417, 64, 113, 16, 30, 36, 17, 53, 18, 28, |
| 2809 | 108, 419, 349, 101, 351, 489, 19, 32, 33, 181, |
| 2810 | 182, 579, 66, 278, 526, 527, 183, 184, 430, 185, |
| 2811 | 186 |
| 2812 | }; |
| 2813 | |
| 2814 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 2815 | STATE-NUM. */ |
| 2816 | #define YYPACT_NINF -542 |
| 2817 | static const yytype_int16 yypact[] = |
| 2818 | { |
| 2819 | -542, 13, 162, 567, -542, -542, -542, -542, -542, -542, |
| 2820 | -542, -542, -542, -542, 83, -542, 19, -542, -542, -14, |
| 2821 | -542, -542, 50, -87, 87, 233, 27, -542, 123, 141, |
| 2822 | 175, -542, -542, 98, -542, -542, -542, -542, 33, 40, |
| 2823 | 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156, |
| 2824 | -542, -542, -542, -542, -542, -542, 221, -542, -542, -542, |
| 2825 | -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226, |
| 2826 | 227, 235, -542, -542, -542, -542, 81, -542, -542, -542, |
| 2827 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2828 | 256, 257, 4, 15, -542, -542, 108, -542, -542, 12, |
| 2829 | -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542, |
| 2830 | 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116, |
| 2831 | 479, 175, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2832 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2833 | -542, -542, -542, -542, -542, -542, -542, -542, -542, 355, |
| 2834 | 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, |
| 2835 | 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542, |
| 2836 | -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306, |
| 2837 | 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542, |
| 2838 | -542, -542, -542, -542, -13, -542, 110, 111, 75, -542, |
| 2839 | -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208, |
| 2840 | 266, 210, 267, 212, 268, 230, 277, 275, 278, 246, |
| 2841 | 280, 279, 566, -542, -542, 136, 766, -542, -542, 81, |
| 2842 | -542, 766, 766, -542, -542, -542, -542, -542, -542, -542, |
| 2843 | -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542, |
| 2844 | -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542, |
| 2845 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2846 | -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147, |
| 2847 | 148, 149, 151, 152, 158, 160, 766, 766, 766, 161, |
| 2848 | 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27, |
| 2849 | 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542, |
| 2850 | -542, -542, -542, -542, -542, -542, -542, -542, 355, 429, |
| 2851 | 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184, |
| 2852 | 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542, |
| 2853 | -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542, |
| 2854 | -542, -542, 193, -542, 194, 766, 766, 766, 7, -542, |
| 2855 | 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306, |
| 2856 | 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207, |
| 2857 | -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542, |
| 2858 | -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542, |
| 2859 | -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326, |
| 2860 | 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337, |
| 2861 | -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306, |
| 2862 | -542, 223, 766, 224, -542, -542, 225, 234, -542, -542, |
| 2863 | 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542, |
| 2864 | -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236, |
| 2865 | 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542, |
| 2866 | 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252, |
| 2867 | -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542, |
| 2868 | 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306, |
| 2869 | 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326, |
| 2870 | 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542, |
| 2871 | -542, -542, 368, 402, 274, 276, 259, 287, -542, -542, |
| 2872 | 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290, |
| 2873 | -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296, |
| 2874 | 297, 299, 302, 303, 430, -542, -542, 414, 41, 425, |
| 2875 | -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326, |
| 2876 | -542, -542, -542, -542, -542, -542, 766, -542, 893, 144, |
| 2877 | 448, -542, -542, -542, 314, 315, 316, -542, 331, -542, |
| 2878 | 893, 766, -542, -542, -542, 464, 334, 180, 766, 481, |
| 2879 | 482, -542, 766, 766, -542, -542 |
| 2880 | }; |
| 2881 | |
| 2882 | /* YYPGOTO[NTERM-NUM]. */ |
| 2883 | static const yytype_int16 yypgoto[] = |
| 2884 | { |
| 2885 | -542, -542, -542, 435, 439, 441, 191, 197, 442, 445, |
| 2886 | -119, -116, -541, -542, 478, 489, -107, -542, -267, 37, |
| 2887 | -542, -238, -542, -60, -542, -45, -542, -74, -51, -542, |
| 2888 | -101, 300, -252, 134, -542, -542, -542, -542, -542, -542, |
| 2889 | -542, 473, -542, -542, -542, -542, 8, -542, 46, -542, |
| 2890 | -542, 410, -542, -542, -542, -542, -542, -542, 518, -542, |
| 2891 | -542, -542, -528, 142, -90, -113, -542, 505, -542, -72, |
| 2892 | -542, -542, -542, -542, 97, 28, -542, -542, 70, -542, |
| 2893 | -542 |
| 2894 | }; |
| 2895 | |
| 2896 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2897 | positive, shift that token. If negative, reduce the rule which |
| 2898 | number is the opposite. If zero, do what YYDEFACT says. |
| 2899 | If YYTABLE_NINF, syntax error. */ |
| 2900 | #define YYTABLE_NINF -180 |
| 2901 | static const yytype_int16 yytable[] = |
| 2902 | { |
| 2903 | 97, 241, 227, 110, 242, 230, 223, 361, 197, 31, |
| 2904 | 111, 26, 449, 4, 244, 204, 34, 578, 97, 201, |
| 2905 | 74, 75, 426, 199, 77, 78, 79, 80, 81, 82, |
| 2906 | 83, 84, 85, 86, 87, 428, 88, 20, 590, 21, |
| 2907 | 275, 26, 31, 279, 280, 281, 282, 283, 284, 285, |
| 2908 | 588, 233, 234, 235, 236, 237, 238, 239, 240, 205, |
| 2909 | 206, 207, 596, 89, 427, 43, 289, 290, 390, 391, |
| 2910 | 226, 463, 300, 226, 403, 405, 291, 427, 452, 468, |
| 2911 | 74, 75, 301, 199, 77, 78, 79, 80, 81, 82, |
| 2912 | 83, 84, 85, 86, 87, 420, 88, 20, 412, 21, |
| 2913 | 448, 453, 38, 39, 40, 204, 273, 274, 226, 276, |
| 2914 | 277, 226, 226, 226, 226, 226, 226, 226, 225, 463, |
| 2915 | 20, 41, 21, 89, 201, 231, 300, 480, -139, 201, |
| 2916 | -112, 286, 287, 288, 226, 226, 384, 232, -139, 204, |
| 2917 | 294, 352, 353, 112, 29, 463, 295, 299, 44, 35, |
| 2918 | 467, 464, 303, 354, 233, 234, 235, 236, 237, 238, |
| 2919 | 239, 240, -179, 463, 463, 54, 198, -112, 51, 90, |
| 2920 | 52, 71, 91, 469, 513, 92, 204, 93, 200, 50, |
| 2921 | 379, 105, 106, 107, 355, 67, 362, 5, 102, 103, |
| 2922 | 188, 189, 68, 6, 292, 293, 372, 373, 374, 97, |
| 2923 | 577, 308, 309, 7, 8, 9, 10, 11, 12, 13, |
| 2924 | 356, -72, -72, -71, -71, -70, -70, 503, 69, 531, |
| 2925 | 70, 532, 381, 382, 14, 109, 385, 357, 187, 90, |
| 2926 | 191, 377, 91, -69, -69, 92, -113, 93, 298, 56, |
| 2927 | 57, 58, 59, 60, 61, 62, 97, 378, 226, 310, |
| 2928 | 311, 192, 433, 45, 435, 436, 437, 123, 124, 193, |
| 2929 | 195, 196, 443, 203, 228, 423, 424, 425, 296, 297, |
| 2930 | -76, -75, -74, 431, 7, 8, 9, 10, 46, 12, |
| 2931 | 47, -73, -79, 48, 313, -80, 314, 445, 446, 363, |
| 2932 | 358, 337, 414, 458, 459, 460, 461, 462, 360, 364, |
| 2933 | 365, 366, 367, 589, 368, 369, 470, 471, 472, 473, |
| 2934 | 474, 370, 385, 371, 375, 380, 383, 376, 386, 387, |
| 2935 | 226, 434, 226, 226, 226, 438, 439, 394, 466, 388, |
| 2936 | 226, 444, 395, 396, 397, 406, 486, 398, 488, 407, |
| 2937 | 408, 409, 492, 410, 411, 418, 421, 422, 429, 432, |
| 2938 | 496, 497, 498, 440, 441, 504, 505, 450, 456, 442, |
| 2939 | 447, 479, 511, 481, 335, 478, 457, 477, 350, 482, |
| 2940 | 483, 484, 485, 350, 350, 487, 491, 493, 494, 502, |
| 2941 | 536, 537, 538, 499, 226, 350, 501, 495, 518, 507, |
| 2942 | 508, 524, 525, 509, 528, 529, 510, 514, 515, 512, |
| 2943 | 516, 534, 500, 517, 452, 523, 544, 545, 546, 547, |
| 2944 | 540, 530, 533, 549, 550, 551, 552, 535, 350, 543, |
| 2945 | 560, 548, 475, 541, 542, 554, 556, 557, 350, 350, |
| 2946 | 350, 427, 414, 558, 575, 576, 566, 568, 226, 241, |
| 2947 | 564, 565, 242, 559, 561, 562, 563, 569, 226, 226, |
| 2948 | 226, 567, 570, 571, 226, 572, 256, 257, 573, 574, |
| 2949 | 241, 580, 582, 242, 581, 584, 583, 585, 586, 591, |
| 2950 | 592, 593, 594, 553, 245, 246, 247, 248, 249, 250, |
| 2951 | 251, 252, 253, 254, 595, 598, 587, 599, 226, 233, |
| 2952 | 234, 235, 236, 237, 238, 239, 240, 350, 350, 350, |
| 2953 | 176, 597, 602, 603, 177, 350, 178, 179, 601, 392, |
| 2954 | 180, 65, 604, 605, 49, 521, 393, 73, 224, 350, |
| 2955 | 350, 27, 334, 520, 37, 600, 490, 539, 506, 0, |
| 2956 | 0, 0, 0, 0, 74, 75, 0, 199, 208, 209, |
| 2957 | 210, 211, 212, 213, 214, 215, 216, 217, 218, 0, |
| 2958 | 88, 20, 0, 21, 258, 259, 260, 261, 262, 263, |
| 2959 | 264, 265, 266, 267, 268, 269, 270, 271, 350, 0, |
| 2960 | 350, 74, 75, 0, 350, 0, 0, 89, 0, 0, |
| 2961 | 0, 0, 350, 350, 350, 0, 0, -82, 20, 20, |
| 2962 | 21, 21, 315, 0, 0, 0, 0, 0, 6, -82, |
| 2963 | -82, 0, 0, 0, 316, 317, 0, 0, -82, -82, |
| 2964 | -82, -82, -82, -82, -82, 0, 0, -82, 22, 0, |
| 2965 | 0, 0, 0, 350, 350, 23, 350, 350, 0, 24, |
| 2966 | 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2967 | 0, 0, 350, 0, 0, 125, 126, 127, 128, 129, |
| 2968 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2969 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
| 2970 | 319, 0, 0, 0, 0, 0, 320, 350, 321, 0, |
| 2971 | 322, 323, 324, 90, 0, 0, 91, 0, 0, 92, |
| 2972 | 0, 93, 404, 0, 0, 0, 0, 0, 0, 0, |
| 2973 | 0, 0, 0, 0, 0, 163, 164, 165, 166, 167, |
| 2974 | 168, 169, 170, 171, 172, 173, 174, 175, 350, 0, |
| 2975 | 0, 0, 0, 325, 0, 0, 326, 0, 327, 0, |
| 2976 | 0, 328, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2977 | 350, 0, 0, 0, 350, 350, 74, 75, 0, 199, |
| 2978 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, |
| 2979 | 218, 0, 88, 20, 0, 21, 0, 0, 0, 338, |
| 2980 | 339, 74, 75, 340, 0, 0, 0, 0, 0, 0, |
| 2981 | 0, 0, 0, 0, 0, 0, 0, 0, 20, 89, |
| 2982 | 21, 0, 341, 342, 343, 0, 0, 0, 0, 0, |
| 2983 | 0, 0, 0, 0, 344, 345, 0, 0, 0, 0, |
| 2984 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2985 | 0, 0, 0, 0, 0, 0, 0, 346, 0, 0, |
| 2986 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2987 | 0, 0, 0, 0, 0, 125, 126, 127, 128, 129, |
| 2988 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2989 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
| 2990 | 319, 0, 0, 0, 0, 0, 320, 0, 321, 0, |
| 2991 | 322, 323, 324, 0, 0, 0, 0, 0, 0, 0, |
| 2992 | 0, 0, 0, 0, 0, 90, 338, 339, 91, 0, |
| 2993 | 340, 92, 0, 93, 465, 163, 164, 165, 166, 167, |
| 2994 | 168, 169, 170, 171, 172, 173, 174, 175, 0, 341, |
| 2995 | 342, 343, 0, 0, 0, 0, 347, 0, 0, 0, |
| 2996 | 0, 344, 345, 0, 0, 0, 0, 0, 0, 0, |
| 2997 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2998 | 0, 0, 0, 0, 346, 0, 0, 0, 0, 0, |
| 2999 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3000 | 0, 0, 125, 126, 127, 128, 129, 130, 131, 132, |
| 3001 | 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, |
| 3002 | 143, 144, 145, 146, 147, 148, 318, 319, 0, 0, |
| 3003 | 0, 0, 0, 320, 0, 321, 0, 322, 323, 324, |
| 3004 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3005 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3006 | 0, 0, 163, 164, 165, 166, 167, 168, 169, 170, |
| 3007 | 171, 172, 173, 174, 175, 0, 0, 0, 0, 0, |
| 3008 | 0, 74, 75, 347, 199, 77, 78, 79, 80, 81, |
| 3009 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 3010 | 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3011 | 0, 0, 0, 302, 0, 0, 0, 0, 0, 0, |
| 3012 | 0, 0, 74, 75, 89, 199, 208, 209, 210, 211, |
| 3013 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 3014 | 0, 21, 74, 75, 0, 199, 77, 78, 79, 80, |
| 3015 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 3016 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 0, |
| 3017 | 0, 0, 0, 0, 413, 0, 0, 0, 0, 0, |
| 3018 | 0, 0, 0, 74, 75, 89, 199, 77, 78, 79, |
| 3019 | 80, 81, 82, 83, 84, 85, 86, 87, 0, 88, |
| 3020 | 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, |
| 3021 | 0, 0, 0, 0, 0, 451, 0, 0, 0, 0, |
| 3022 | 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, |
| 3023 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
| 3024 | 74, 75, 0, 199, 77, 78, 79, 80, 81, 82, |
| 3025 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
| 3026 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3027 | 0, 90, 519, 0, 91, 0, 399, 92, 0, 93, |
| 3028 | 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, |
| 3029 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 93, |
| 3030 | 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, |
| 3031 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
| 3032 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3033 | 0, 0, 90, 0, 0, 91, 0, 0, 92, 0, |
| 3034 | 93, 74, 75, 89, 199, 77, 78, 79, 80, 81, |
| 3035 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 3036 | 21, 74, 75, 0, 199, 208, 209, 210, 211, 212, |
| 3037 | 213, 214, 215, 216, 217, 218, 0, 88, 20, 0, |
| 3038 | 21, 0, 0, 0, 89, 0, 0, 0, 0, 90, |
| 3039 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 3040 | 0, 0, 74, 75, 89, 229, 77, 78, 79, 80, |
| 3041 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 3042 | 0, 21, 74, 75, 0, 199, 208, 209, 210, 211, |
| 3043 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 3044 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 90, |
| 3045 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 3046 | 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, |
| 3047 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3048 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3049 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
| 3050 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3051 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
| 3052 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3053 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3054 | 0, 0, 0, 0, 114, 0, 0, 0, 0, 0, |
| 3055 | 0, 90, 0, 0, 91, 0, 0, 92, 115, 93, |
| 3056 | 0, 0, 0, 0, 0, 0, 0, 0, 116, 117, |
| 3057 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 402, |
| 3058 | 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 3059 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3060 | 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3061 | 147, 148, 149, 150, 151, 152, 153, 0, 0, 154, |
| 3062 | 155, 156, 157, 158, 159, 160, 161, 162, 0, 0, |
| 3063 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3064 | 0, 0, 0, 0, 0, 0, 0, 0, 163, 164, |
| 3065 | 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 3066 | 175 |
| 3067 | }; |
| 3068 | |
| 3069 | static const yytype_int16 yycheck[] = |
| 3070 | { |
| 3071 | 45, 120, 115, 63, 120, 118, 107, 274, 4, 23, |
| 3072 | 29, 3, 161, 0, 121, 164, 30, 558, 63, 93, |
| 3073 | 5, 6, 15, 8, 9, 10, 11, 12, 13, 14, |
| 3074 | 15, 16, 17, 18, 19, 15, 21, 22, 579, 24, |
| 3075 | 153, 33, 23, 156, 157, 158, 159, 160, 161, 162, |
| 3076 | 578, 10, 11, 12, 13, 14, 15, 16, 17, 104, |
| 3077 | 105, 106, 590, 48, 57, 152, 179, 180, 306, 307, |
| 3078 | 115, 153, 153, 118, 326, 327, 183, 57, 34, 161, |
| 3079 | 5, 6, 163, 8, 9, 10, 11, 12, 13, 14, |
| 3080 | 15, 16, 17, 18, 19, 347, 21, 22, 336, 24, |
| 3081 | 159, 57, 52, 53, 54, 164, 151, 152, 153, 154, |
| 3082 | 155, 156, 157, 158, 159, 160, 161, 162, 110, 153, |
| 3083 | 22, 71, 24, 48, 198, 9, 153, 161, 153, 203, |
| 3084 | 155, 176, 177, 178, 179, 180, 163, 21, 163, 164, |
| 3085 | 153, 231, 232, 162, 61, 153, 159, 198, 61, 163, |
| 3086 | 402, 159, 203, 243, 10, 11, 12, 13, 14, 15, |
| 3087 | 16, 17, 0, 153, 153, 24, 162, 155, 45, 154, |
| 3088 | 47, 157, 157, 163, 163, 160, 164, 162, 163, 152, |
| 3089 | 293, 47, 48, 49, 244, 152, 276, 25, 32, 33, |
| 3090 | 55, 56, 152, 31, 108, 109, 286, 287, 288, 244, |
| 3091 | 159, 27, 28, 41, 42, 43, 44, 45, 46, 47, |
| 3092 | 255, 3, 4, 3, 4, 3, 4, 455, 152, 486, |
| 3093 | 152, 488, 296, 297, 62, 4, 300, 272, 24, 154, |
| 3094 | 4, 291, 157, 3, 4, 160, 155, 162, 163, 64, |
| 3095 | 65, 66, 67, 68, 69, 70, 291, 292, 293, 3, |
| 3096 | 4, 24, 365, 20, 367, 368, 369, 77, 78, 24, |
| 3097 | 4, 4, 375, 155, 59, 355, 356, 357, 158, 158, |
| 3098 | 4, 4, 4, 363, 41, 42, 43, 44, 45, 46, |
| 3099 | 47, 4, 7, 50, 4, 7, 7, 377, 378, 157, |
| 3100 | 153, 155, 337, 394, 395, 396, 397, 398, 153, 153, |
| 3101 | 153, 153, 153, 159, 153, 153, 407, 408, 409, 410, |
| 3102 | 411, 153, 386, 153, 153, 24, 161, 36, 153, 156, |
| 3103 | 365, 366, 367, 368, 369, 370, 371, 155, 402, 153, |
| 3104 | 375, 376, 155, 155, 155, 24, 426, 155, 428, 155, |
| 3105 | 155, 155, 432, 155, 155, 63, 153, 153, 153, 157, |
| 3106 | 440, 441, 442, 153, 153, 456, 457, 161, 155, 153, |
| 3107 | 153, 24, 463, 21, 222, 156, 155, 153, 226, 21, |
| 3108 | 155, 153, 153, 231, 232, 4, 153, 153, 153, 4, |
| 3109 | 493, 494, 495, 155, 429, 243, 24, 153, 36, 153, |
| 3110 | 153, 481, 482, 153, 484, 485, 153, 153, 153, 161, |
| 3111 | 153, 491, 447, 153, 34, 153, 507, 508, 509, 510, |
| 3112 | 500, 153, 153, 514, 515, 516, 517, 153, 276, 156, |
| 3113 | 533, 161, 414, 153, 153, 57, 24, 153, 286, 287, |
| 3114 | 288, 57, 477, 157, 4, 21, 153, 153, 483, 558, |
| 3115 | 541, 542, 558, 156, 159, 535, 156, 153, 493, 494, |
| 3116 | 495, 156, 156, 156, 499, 156, 27, 28, 156, 156, |
| 3117 | 579, 36, 156, 579, 159, 566, 156, 568, 569, 21, |
| 3118 | 156, 156, 156, 518, 119, 120, 121, 122, 123, 124, |
| 3119 | 125, 126, 127, 128, 153, 21, 576, 153, 533, 10, |
| 3120 | 11, 12, 13, 14, 15, 16, 17, 355, 356, 357, |
| 3121 | 65, 591, 21, 21, 65, 363, 65, 65, 598, 318, |
| 3122 | 65, 33, 602, 603, 25, 478, 319, 44, 108, 377, |
| 3123 | 378, 3, 222, 477, 19, 597, 429, 499, 458, -1, |
| 3124 | -1, -1, -1, -1, 5, 6, -1, 8, 9, 10, |
| 3125 | 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, |
| 3126 | 21, 22, -1, 24, 125, 126, 127, 128, 129, 130, |
| 3127 | 131, 132, 133, 134, 135, 136, 137, 138, 426, -1, |
| 3128 | 428, 5, 6, -1, 432, -1, -1, 48, -1, -1, |
| 3129 | -1, -1, 440, 441, 442, -1, -1, 20, 22, 22, |
| 3130 | 24, 24, 26, -1, -1, -1, -1, -1, 31, 32, |
| 3131 | 33, -1, -1, -1, 38, 39, -1, -1, 41, 42, |
| 3132 | 43, 44, 45, 46, 47, -1, -1, 50, 51, -1, |
| 3133 | -1, -1, -1, 481, 482, 58, 484, 485, -1, 62, |
| 3134 | -1, -1, -1, 491, -1, -1, -1, -1, -1, -1, |
| 3135 | -1, -1, 500, -1, -1, 79, 80, 81, 82, 83, |
| 3136 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3137 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3138 | 104, -1, -1, -1, -1, -1, 110, 535, 112, -1, |
| 3139 | 114, 115, 116, 154, -1, -1, 157, -1, -1, 160, |
| 3140 | -1, 162, 163, -1, -1, -1, -1, -1, -1, -1, |
| 3141 | -1, -1, -1, -1, -1, 139, 140, 141, 142, 143, |
| 3142 | 144, 145, 146, 147, 148, 149, 150, 151, 576, -1, |
| 3143 | -1, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3144 | -1, 165, -1, 591, -1, -1, -1, -1, -1, -1, |
| 3145 | 598, -1, -1, -1, 602, 603, 5, 6, -1, 8, |
| 3146 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
| 3147 | 19, -1, 21, 22, -1, 24, -1, -1, -1, 3, |
| 3148 | 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, |
| 3149 | -1, -1, -1, -1, -1, -1, -1, -1, 22, 48, |
| 3150 | 24, -1, 26, 27, 28, -1, -1, -1, -1, -1, |
| 3151 | -1, -1, -1, -1, 38, 39, -1, -1, -1, -1, |
| 3152 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3153 | -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, |
| 3154 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3155 | -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, |
| 3156 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3157 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3158 | 104, -1, -1, -1, -1, -1, 110, -1, 112, -1, |
| 3159 | 114, 115, 116, -1, -1, -1, -1, -1, -1, -1, |
| 3160 | -1, -1, -1, -1, -1, 154, 3, 4, 157, -1, |
| 3161 | 7, 160, -1, 162, 163, 139, 140, 141, 142, 143, |
| 3162 | 144, 145, 146, 147, 148, 149, 150, 151, -1, 26, |
| 3163 | 27, 28, -1, -1, -1, -1, 160, -1, -1, -1, |
| 3164 | -1, 38, 39, -1, -1, -1, -1, -1, -1, -1, |
| 3165 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3166 | -1, -1, -1, -1, 61, -1, -1, -1, -1, -1, |
| 3167 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3168 | -1, -1, 79, 80, 81, 82, 83, 84, 85, 86, |
| 3169 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 3170 | 97, 98, 99, 100, 101, 102, 103, 104, -1, -1, |
| 3171 | -1, -1, -1, 110, -1, 112, -1, 114, 115, 116, |
| 3172 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3173 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3174 | -1, -1, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3175 | 147, 148, 149, 150, 151, -1, -1, -1, -1, -1, |
| 3176 | -1, 5, 6, 160, 8, 9, 10, 11, 12, 13, |
| 3177 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3178 | 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3179 | -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, |
| 3180 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 3181 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3182 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3183 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3184 | -1, 24, -1, -1, -1, 48, -1, -1, -1, -1, |
| 3185 | -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, |
| 3186 | -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, |
| 3187 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 3188 | 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, |
| 3189 | -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, |
| 3190 | -1, -1, -1, -1, -1, -1, 48, -1, -1, -1, |
| 3191 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3192 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3193 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 3194 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3195 | -1, 154, 37, -1, 157, -1, 159, 160, -1, 162, |
| 3196 | -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, |
| 3197 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 3198 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3199 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 3200 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3201 | -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, |
| 3202 | 162, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 3203 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3204 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 3205 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3206 | 24, -1, -1, -1, 48, -1, -1, -1, -1, 154, |
| 3207 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3208 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 3209 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3210 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3211 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3212 | -1, 24, -1, -1, -1, 48, -1, -1, -1, 154, |
| 3213 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3214 | -1, -1, -1, -1, -1, 48, -1, -1, -1, -1, |
| 3215 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3216 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3217 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3218 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3219 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3220 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3221 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3222 | -1, -1, -1, -1, 35, -1, -1, -1, -1, -1, |
| 3223 | -1, 154, -1, -1, 157, -1, -1, 160, 49, 162, |
| 3224 | -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, |
| 3225 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 3226 | -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 3227 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 3228 | 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, |
| 3229 | 101, 102, 103, 104, 105, 106, 107, -1, -1, 110, |
| 3230 | 111, 112, 113, 114, 115, 116, 117, 118, -1, -1, |
| 3231 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3232 | -1, -1, -1, -1, -1, -1, -1, -1, 139, 140, |
| 3233 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, |
| 3234 | 151 |
| 3235 | }; |
| 3236 | |
| 3237 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 3238 | symbol of state STATE-NUM. */ |
| 3239 | static const yytype_uint8 yystos[] = |
| 3240 | { |
| 3241 | 0, 200, 201, 202, 0, 25, 31, 41, 42, 43, |
| 3242 | 44, 45, 46, 47, 62, 181, 219, 222, 224, 232, |
| 3243 | 22, 24, 51, 58, 62, 180, 212, 224, 225, 61, |
| 3244 | 220, 23, 233, 234, 30, 163, 221, 233, 52, 53, |
| 3245 | 54, 71, 209, 152, 61, 20, 45, 47, 50, 181, |
| 3246 | 152, 45, 47, 223, 24, 207, 64, 65, 66, 67, |
| 3247 | 68, 69, 70, 182, 217, 180, 238, 152, 152, 152, |
| 3248 | 152, 157, 210, 207, 5, 6, 8, 9, 10, 11, |
| 3249 | 12, 13, 14, 15, 16, 17, 18, 19, 21, 48, |
| 3250 | 154, 157, 160, 162, 167, 189, 190, 191, 192, 193, |
| 3251 | 212, 229, 32, 33, 199, 199, 199, 199, 226, 4, |
| 3252 | 189, 29, 162, 218, 35, 49, 59, 60, 72, 73, |
| 3253 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 3254 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3255 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3256 | 104, 105, 106, 107, 110, 111, 112, 113, 114, 115, |
| 3257 | 116, 117, 118, 139, 140, 141, 142, 143, 144, 145, |
| 3258 | 146, 147, 148, 149, 150, 151, 169, 170, 171, 174, |
| 3259 | 175, 235, 236, 242, 243, 245, 246, 24, 55, 56, |
| 3260 | 208, 4, 24, 24, 211, 4, 4, 4, 162, 8, |
| 3261 | 163, 193, 194, 155, 164, 191, 191, 191, 9, 10, |
| 3262 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 176, |
| 3263 | 177, 179, 191, 196, 217, 212, 191, 231, 59, 8, |
| 3264 | 231, 9, 21, 10, 11, 12, 13, 14, 15, 16, |
| 3265 | 17, 176, 177, 178, 182, 119, 120, 121, 122, 123, |
| 3266 | 124, 125, 126, 127, 128, 172, 27, 28, 125, 126, |
| 3267 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3268 | 137, 138, 173, 191, 191, 231, 191, 191, 239, 231, |
| 3269 | 231, 231, 231, 231, 231, 231, 191, 191, 191, 231, |
| 3270 | 231, 182, 108, 109, 153, 159, 158, 158, 163, 194, |
| 3271 | 153, 163, 37, 194, 195, 205, 206, 204, 27, 28, |
| 3272 | 3, 4, 168, 4, 7, 26, 38, 39, 103, 104, |
| 3273 | 110, 112, 114, 115, 116, 157, 160, 162, 165, 169, |
| 3274 | 170, 171, 174, 175, 197, 229, 203, 155, 3, 4, |
| 3275 | 7, 26, 27, 28, 38, 39, 61, 160, 197, 228, |
| 3276 | 229, 230, 230, 230, 230, 189, 191, 191, 153, 184, |
| 3277 | 153, 184, 230, 157, 153, 153, 153, 153, 153, 153, |
| 3278 | 153, 153, 230, 230, 230, 153, 36, 189, 191, 231, |
| 3279 | 24, 193, 193, 161, 163, 193, 153, 156, 153, 187, |
| 3280 | 187, 187, 172, 173, 155, 155, 155, 155, 155, 159, |
| 3281 | 196, 198, 162, 198, 163, 198, 24, 155, 155, 155, |
| 3282 | 155, 155, 187, 37, 191, 214, 215, 216, 63, 227, |
| 3283 | 198, 153, 153, 230, 230, 230, 15, 57, 15, 153, |
| 3284 | 244, 230, 157, 231, 191, 231, 231, 231, 191, 191, |
| 3285 | 153, 153, 153, 231, 191, 230, 230, 153, 159, 161, |
| 3286 | 161, 37, 34, 57, 185, 188, 155, 155, 196, 196, |
| 3287 | 196, 196, 196, 153, 159, 163, 193, 198, 161, 163, |
| 3288 | 196, 196, 196, 196, 196, 212, 213, 153, 156, 24, |
| 3289 | 161, 21, 21, 155, 153, 153, 230, 4, 230, 231, |
| 3290 | 240, 153, 230, 153, 153, 153, 230, 230, 230, 155, |
| 3291 | 191, 24, 4, 187, 196, 196, 244, 153, 153, 153, |
| 3292 | 153, 196, 161, 163, 153, 153, 153, 153, 36, 37, |
| 3293 | 214, 185, 186, 153, 230, 230, 240, 241, 230, 230, |
| 3294 | 153, 184, 184, 153, 230, 153, 231, 231, 231, 241, |
| 3295 | 230, 153, 153, 156, 196, 196, 196, 196, 161, 196, |
| 3296 | 196, 196, 196, 191, 57, 183, 24, 153, 157, 156, |
| 3297 | 231, 159, 230, 156, 196, 196, 153, 156, 153, 153, |
| 3298 | 156, 156, 156, 156, 156, 4, 21, 159, 178, 237, |
| 3299 | 36, 159, 156, 156, 196, 196, 196, 230, 228, 159, |
| 3300 | 178, 21, 156, 156, 156, 153, 228, 230, 21, 153, |
| 3301 | 235, 230, 21, 21, 230, 230 |
| 3302 | }; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3303 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3304 | #define yyerrok (yyerrstatus = 0) |
| 3305 | #define yyclearin (yychar = YYEMPTY) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3306 | #define YYEMPTY (-2) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3307 | #define YYEOF 0 |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3308 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3309 | #define YYACCEPT goto yyacceptlab |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3310 | #define YYABORT goto yyabortlab |
| 3311 | #define YYERROR goto yyerrorlab |
| 3312 | |
| 3313 | |
| 3314 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 3315 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3316 | Once GCC version 2 has supplanted version 1, this can go. */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3317 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3318 | #define YYFAIL goto yyerrlab |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3319 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3320 | #define YYRECOVERING() (!!yyerrstatus) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3321 | |
| 3322 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3323 | do \ |
| 3324 | if (yychar == YYEMPTY && yylen == 1) \ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3325 | { \ |
| 3326 | yychar = (Token); \ |
| 3327 | yylval = (Value); \ |
| 3328 | yytoken = YYTRANSLATE (yychar); \ |
| 3329 | YYPOPSTACK (1); \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3330 | goto yybackup; \ |
| 3331 | } \ |
| 3332 | else \ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3333 | { \ |
| 3334 | yyerror (YY_("syntax error: cannot back up")); \ |
| 3335 | YYERROR; \ |
| 3336 | } \ |
| 3337 | while (YYID (0)) |
| 3338 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3339 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3340 | #define YYTERROR 1 |
| 3341 | #define YYERRCODE 256 |
| 3342 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3343 | |
| 3344 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 3345 | If N is 0, then set CURRENT to the empty location which ends |
| 3346 | the previous symbol: RHS[0] (always defined). */ |
| 3347 | |
| 3348 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 3349 | #ifndef YYLLOC_DEFAULT |
| 3350 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 3351 | do \ |
| 3352 | if (YYID (N)) \ |
| 3353 | { \ |
| 3354 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 3355 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 3356 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 3357 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 3358 | } \ |
| 3359 | else \ |
| 3360 | { \ |
| 3361 | (Current).first_line = (Current).last_line = \ |
| 3362 | YYRHSLOC (Rhs, 0).last_line; \ |
| 3363 | (Current).first_column = (Current).last_column = \ |
| 3364 | YYRHSLOC (Rhs, 0).last_column; \ |
| 3365 | } \ |
| 3366 | while (YYID (0)) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3367 | #endif |
| 3368 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3369 | |
| 3370 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 3371 | This macro was not mandated originally: define only if we know |
| 3372 | we won't break user code: when these are the locations we know. */ |
| 3373 | |
| 3374 | #ifndef YY_LOCATION_PRINT |
| 3375 | # if YYLTYPE_IS_TRIVIAL |
| 3376 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 3377 | fprintf (File, "%d.%d-%d.%d", \ |
| 3378 | (Loc).first_line, (Loc).first_column, \ |
| 3379 | (Loc).last_line, (Loc).last_column) |
| 3380 | # else |
| 3381 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 3382 | # endif |
| 3383 | #endif |
| 3384 | |
| 3385 | |
| 3386 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 3387 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3388 | #ifdef YYLEX_PARAM |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3389 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3390 | #else |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3391 | # define YYLEX yylex () |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3392 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3393 | |
| 3394 | /* Enable debugging if requested. */ |
| 3395 | #if YYDEBUG |
| 3396 | |
| 3397 | # ifndef YYFPRINTF |
| 3398 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 3399 | # define YYFPRINTF fprintf |
| 3400 | # endif |
| 3401 | |
| 3402 | # define YYDPRINTF(Args) \ |
| 3403 | do { \ |
| 3404 | if (yydebug) \ |
| 3405 | YYFPRINTF Args; \ |
| 3406 | } while (YYID (0)) |
| 3407 | |
| 3408 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 3409 | do { \ |
| 3410 | if (yydebug) \ |
| 3411 | { \ |
| 3412 | YYFPRINTF (stderr, "%s ", Title); \ |
| 3413 | yy_symbol_print (stderr, \ |
| 3414 | Type, Value); \ |
| 3415 | YYFPRINTF (stderr, "\n"); \ |
| 3416 | } \ |
| 3417 | } while (YYID (0)) |
| 3418 | |
| 3419 | |
| 3420 | /*--------------------------------. |
| 3421 | | Print this symbol on YYOUTPUT. | |
| 3422 | `--------------------------------*/ |
| 3423 | |
| 3424 | /*ARGSUSED*/ |
| 3425 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3426 | || defined __cplusplus || defined _MSC_VER) |
| 3427 | static void |
| 3428 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3429 | #else |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3430 | static void |
| 3431 | yy_symbol_value_print (yyoutput, yytype, yyvaluep) |
| 3432 | FILE *yyoutput; |
| 3433 | int yytype; |
| 3434 | YYSTYPE const * const yyvaluep; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3435 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3436 | { |
| 3437 | if (!yyvaluep) |
| 3438 | return; |
| 3439 | # ifdef YYPRINT |
| 3440 | if (yytype < YYNTOKENS) |
| 3441 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 3442 | # else |
| 3443 | YYUSE (yyoutput); |
| 3444 | # endif |
| 3445 | switch (yytype) |
| 3446 | { |
| 3447 | default: |
| 3448 | break; |
| 3449 | } |
| 3450 | } |
| 3451 | |
| 3452 | |
| 3453 | /*--------------------------------. |
| 3454 | | Print this symbol on YYOUTPUT. | |
| 3455 | `--------------------------------*/ |
| 3456 | |
| 3457 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3458 | || defined __cplusplus || defined _MSC_VER) |
| 3459 | static void |
| 3460 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
| 3461 | #else |
| 3462 | static void |
| 3463 | yy_symbol_print (yyoutput, yytype, yyvaluep) |
| 3464 | FILE *yyoutput; |
| 3465 | int yytype; |
| 3466 | YYSTYPE const * const yyvaluep; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3467 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3468 | { |
| 3469 | if (yytype < YYNTOKENS) |
| 3470 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 3471 | else |
| 3472 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3473 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3474 | yy_symbol_value_print (yyoutput, yytype, yyvaluep); |
| 3475 | YYFPRINTF (yyoutput, ")"); |
| 3476 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3477 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3478 | /*------------------------------------------------------------------. |
| 3479 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 3480 | | TOP (included). | |
| 3481 | `------------------------------------------------------------------*/ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3482 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3483 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3484 | || defined __cplusplus || defined _MSC_VER) |
| 3485 | static void |
| 3486 | yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) |
| 3487 | #else |
| 3488 | static void |
| 3489 | yy_stack_print (bottom, top) |
| 3490 | yytype_int16 *bottom; |
| 3491 | yytype_int16 *top; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3492 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3493 | { |
| 3494 | YYFPRINTF (stderr, "Stack now"); |
| 3495 | for (; bottom <= top; ++bottom) |
| 3496 | YYFPRINTF (stderr, " %d", *bottom); |
| 3497 | YYFPRINTF (stderr, "\n"); |
| 3498 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3499 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3500 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 3501 | do { \ |
| 3502 | if (yydebug) \ |
| 3503 | yy_stack_print ((Bottom), (Top)); \ |
| 3504 | } while (YYID (0)) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3505 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3506 | |
| 3507 | /*------------------------------------------------. |
| 3508 | | Report that the YYRULE is going to be reduced. | |
| 3509 | `------------------------------------------------*/ |
| 3510 | |
| 3511 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3512 | || defined __cplusplus || defined _MSC_VER) |
| 3513 | static void |
| 3514 | yy_reduce_print (YYSTYPE *yyvsp, int yyrule) |
| 3515 | #else |
| 3516 | static void |
| 3517 | yy_reduce_print (yyvsp, yyrule) |
| 3518 | YYSTYPE *yyvsp; |
| 3519 | int yyrule; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3520 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3521 | { |
| 3522 | int yynrhs = yyr2[yyrule]; |
| 3523 | int yyi; |
| 3524 | unsigned long int yylno = yyrline[yyrule]; |
| 3525 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", |
| 3526 | yyrule - 1, yylno); |
| 3527 | /* The symbols being reduced. */ |
| 3528 | for (yyi = 0; yyi < yynrhs; yyi++) |
| 3529 | { |
| 3530 | fprintf (stderr, " $%d = ", yyi + 1); |
| 3531 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], |
| 3532 | &(yyvsp[(yyi + 1) - (yynrhs)]) |
| 3533 | ); |
| 3534 | fprintf (stderr, "\n"); |
| 3535 | } |
| 3536 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3537 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3538 | # define YY_REDUCE_PRINT(Rule) \ |
| 3539 | do { \ |
| 3540 | if (yydebug) \ |
| 3541 | yy_reduce_print (yyvsp, Rule); \ |
| 3542 | } while (YYID (0)) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3543 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3544 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 3545 | multiple parsers can coexist. */ |
| 3546 | int yydebug; |
| 3547 | #else /* !YYDEBUG */ |
| 3548 | # define YYDPRINTF(Args) |
| 3549 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 3550 | # define YY_STACK_PRINT(Bottom, Top) |
| 3551 | # define YY_REDUCE_PRINT(Rule) |
| 3552 | #endif /* !YYDEBUG */ |
| 3553 | |
| 3554 | |
| 3555 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3556 | #ifndef YYINITDEPTH |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3557 | # define YYINITDEPTH 200 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3558 | #endif |
| 3559 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3560 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 3561 | if the built-in stack extension method is used). |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3562 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3563 | Do not make this value too large; the results are undefined if |
| 3564 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 3565 | evaluated with infinite-precision integer arithmetic. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3566 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3567 | #ifndef YYMAXDEPTH |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3568 | # define YYMAXDEPTH 10000 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3569 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3570 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3571 | |
| 3572 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3573 | #if YYERROR_VERBOSE |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3574 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3575 | # ifndef yystrlen |
| 3576 | # if defined __GLIBC__ && defined _STRING_H |
| 3577 | # define yystrlen strlen |
| 3578 | # else |
| 3579 | /* Return the length of YYSTR. */ |
| 3580 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3581 | || defined __cplusplus || defined _MSC_VER) |
| 3582 | static YYSIZE_T |
| 3583 | yystrlen (const char *yystr) |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3584 | #else |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3585 | static YYSIZE_T |
| 3586 | yystrlen (yystr) |
| 3587 | const char *yystr; |
| 3588 | #endif |
| 3589 | { |
| 3590 | YYSIZE_T yylen; |
| 3591 | for (yylen = 0; yystr[yylen]; yylen++) |
| 3592 | continue; |
| 3593 | return yylen; |
| 3594 | } |
| 3595 | # endif |
| 3596 | # endif |
| 3597 | |
| 3598 | # ifndef yystpcpy |
| 3599 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE |
| 3600 | # define yystpcpy stpcpy |
| 3601 | # else |
| 3602 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 3603 | YYDEST. */ |
| 3604 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3605 | || defined __cplusplus || defined _MSC_VER) |
| 3606 | static char * |
| 3607 | yystpcpy (char *yydest, const char *yysrc) |
| 3608 | #else |
| 3609 | static char * |
| 3610 | yystpcpy (yydest, yysrc) |
| 3611 | char *yydest; |
| 3612 | const char *yysrc; |
| 3613 | #endif |
| 3614 | { |
| 3615 | char *yyd = yydest; |
| 3616 | const char *yys = yysrc; |
| 3617 | |
| 3618 | while ((*yyd++ = *yys++) != '\0') |
| 3619 | continue; |
| 3620 | |
| 3621 | return yyd - 1; |
| 3622 | } |
| 3623 | # endif |
| 3624 | # endif |
| 3625 | |
| 3626 | # ifndef yytnamerr |
| 3627 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 3628 | quotes and backslashes, so that it's suitable for yyerror. The |
| 3629 | heuristic is that double-quoting is unnecessary unless the string |
| 3630 | contains an apostrophe, a comma, or backslash (other than |
| 3631 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 3632 | null, do not copy; instead, return the length of what the result |
| 3633 | would have been. */ |
| 3634 | static YYSIZE_T |
| 3635 | yytnamerr (char *yyres, const char *yystr) |
| 3636 | { |
| 3637 | if (*yystr == '"') |
| 3638 | { |
| 3639 | YYSIZE_T yyn = 0; |
| 3640 | char const *yyp = yystr; |
| 3641 | |
| 3642 | for (;;) |
| 3643 | switch (*++yyp) |
| 3644 | { |
| 3645 | case '\'': |
| 3646 | case ',': |
| 3647 | goto do_not_strip_quotes; |
| 3648 | |
| 3649 | case '\\': |
| 3650 | if (*++yyp != '\\') |
| 3651 | goto do_not_strip_quotes; |
| 3652 | /* Fall through. */ |
| 3653 | default: |
| 3654 | if (yyres) |
| 3655 | yyres[yyn] = *yyp; |
| 3656 | yyn++; |
| 3657 | break; |
| 3658 | |
| 3659 | case '"': |
| 3660 | if (yyres) |
| 3661 | yyres[yyn] = '\0'; |
| 3662 | return yyn; |
| 3663 | } |
| 3664 | do_not_strip_quotes: ; |
| 3665 | } |
| 3666 | |
| 3667 | if (! yyres) |
| 3668 | return yystrlen (yystr); |
| 3669 | |
| 3670 | return yystpcpy (yyres, yystr) - yyres; |
| 3671 | } |
| 3672 | # endif |
| 3673 | |
| 3674 | /* Copy into YYRESULT an error message about the unexpected token |
| 3675 | YYCHAR while in state YYSTATE. Return the number of bytes copied, |
| 3676 | including the terminating null byte. If YYRESULT is null, do not |
| 3677 | copy anything; just return the number of bytes that would be |
| 3678 | copied. As a special case, return 0 if an ordinary "syntax error" |
| 3679 | message will do. Return YYSIZE_MAXIMUM if overflow occurs during |
| 3680 | size calculation. */ |
| 3681 | static YYSIZE_T |
| 3682 | yysyntax_error (char *yyresult, int yystate, int yychar) |
| 3683 | { |
| 3684 | int yyn = yypact[yystate]; |
| 3685 | |
| 3686 | if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) |
| 3687 | return 0; |
| 3688 | else |
| 3689 | { |
| 3690 | int yytype = YYTRANSLATE (yychar); |
| 3691 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 3692 | YYSIZE_T yysize = yysize0; |
| 3693 | YYSIZE_T yysize1; |
| 3694 | int yysize_overflow = 0; |
| 3695 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
| 3696 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 3697 | int yyx; |
| 3698 | |
| 3699 | # if 0 |
| 3700 | /* This is so xgettext sees the translatable formats that are |
| 3701 | constructed on the fly. */ |
| 3702 | YY_("syntax error, unexpected %s"); |
| 3703 | YY_("syntax error, unexpected %s, expecting %s"); |
| 3704 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 3705 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 3706 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 3707 | # endif |
| 3708 | char *yyfmt; |
| 3709 | char const *yyf; |
| 3710 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 3711 | static char const yyexpecting[] = ", expecting %s"; |
| 3712 | static char const yyor[] = " or %s"; |
| 3713 | char yyformat[sizeof yyunexpected |
| 3714 | + sizeof yyexpecting - 1 |
| 3715 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 3716 | * (sizeof yyor - 1))]; |
| 3717 | char const *yyprefix = yyexpecting; |
| 3718 | |
| 3719 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 3720 | YYCHECK. */ |
| 3721 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 3722 | |
| 3723 | /* Stay within bounds of both yycheck and yytname. */ |
| 3724 | int yychecklim = YYLAST - yyn + 1; |
| 3725 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 3726 | int yycount = 1; |
| 3727 | |
| 3728 | yyarg[0] = yytname[yytype]; |
| 3729 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 3730 | |
| 3731 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 3732 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 3733 | { |
| 3734 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 3735 | { |
| 3736 | yycount = 1; |
| 3737 | yysize = yysize0; |
| 3738 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 3739 | break; |
| 3740 | } |
| 3741 | yyarg[yycount++] = yytname[yyx]; |
| 3742 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 3743 | yysize_overflow |= (yysize1 < yysize); |
| 3744 | yysize = yysize1; |
| 3745 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 3746 | yyprefix = yyor; |
| 3747 | } |
| 3748 | |
| 3749 | yyf = YY_(yyformat); |
| 3750 | yysize1 = yysize + yystrlen (yyf); |
| 3751 | yysize_overflow |= (yysize1 < yysize); |
| 3752 | yysize = yysize1; |
| 3753 | |
| 3754 | if (yysize_overflow) |
| 3755 | return YYSIZE_MAXIMUM; |
| 3756 | |
| 3757 | if (yyresult) |
| 3758 | { |
| 3759 | /* Avoid sprintf, as that infringes on the user's name space. |
| 3760 | Don't have undefined behavior even if the translation |
| 3761 | produced a string with the wrong number of "%s"s. */ |
| 3762 | char *yyp = yyresult; |
| 3763 | int yyi = 0; |
| 3764 | while ((*yyp = *yyf) != '\0') |
| 3765 | { |
| 3766 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 3767 | { |
| 3768 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 3769 | yyf += 2; |
| 3770 | } |
| 3771 | else |
| 3772 | { |
| 3773 | yyp++; |
| 3774 | yyf++; |
| 3775 | } |
| 3776 | } |
| 3777 | } |
| 3778 | return yysize; |
| 3779 | } |
| 3780 | } |
| 3781 | #endif /* YYERROR_VERBOSE */ |
| 3782 | |
| 3783 | |
| 3784 | /*-----------------------------------------------. |
| 3785 | | Release the memory associated to this symbol. | |
| 3786 | `-----------------------------------------------*/ |
| 3787 | |
| 3788 | /*ARGSUSED*/ |
| 3789 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3790 | || defined __cplusplus || defined _MSC_VER) |
| 3791 | static void |
| 3792 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 3793 | #else |
| 3794 | static void |
| 3795 | yydestruct (yymsg, yytype, yyvaluep) |
| 3796 | const char *yymsg; |
| 3797 | int yytype; |
| 3798 | YYSTYPE *yyvaluep; |
| 3799 | #endif |
| 3800 | { |
| 3801 | YYUSE (yyvaluep); |
| 3802 | |
| 3803 | if (!yymsg) |
| 3804 | yymsg = "Deleting"; |
| 3805 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 3806 | |
| 3807 | switch (yytype) |
| 3808 | { |
| 3809 | |
| 3810 | default: |
| 3811 | break; |
| 3812 | } |
| 3813 | } |
| 3814 | |
| 3815 | |
| 3816 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 3817 | |
| 3818 | #ifdef YYPARSE_PARAM |
| 3819 | #if defined __STDC__ || defined __cplusplus |
| 3820 | int yyparse (void *YYPARSE_PARAM); |
| 3821 | #else |
| 3822 | int yyparse (); |
| 3823 | #endif |
| 3824 | #else /* ! YYPARSE_PARAM */ |
| 3825 | #if defined __STDC__ || defined __cplusplus |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3826 | int yyparse (void); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3827 | #else |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3828 | int yyparse (); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3829 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3830 | #endif /* ! YYPARSE_PARAM */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3831 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3832 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3833 | |
| 3834 | /* The look-ahead symbol. */ |
| 3835 | int yychar; |
| 3836 | |
| 3837 | /* The semantic value of the look-ahead symbol. */ |
| 3838 | YYSTYPE yylval; |
| 3839 | |
| 3840 | /* Number of syntax errors so far. */ |
| 3841 | int yynerrs; |
| 3842 | |
| 3843 | |
| 3844 | |
| 3845 | /*----------. |
| 3846 | | yyparse. | |
| 3847 | `----------*/ |
| 3848 | |
| 3849 | #ifdef YYPARSE_PARAM |
| 3850 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3851 | || defined __cplusplus || defined _MSC_VER) |
| 3852 | int |
| 3853 | yyparse (void *YYPARSE_PARAM) |
| 3854 | #else |
| 3855 | int |
| 3856 | yyparse (YYPARSE_PARAM) |
| 3857 | void *YYPARSE_PARAM; |
| 3858 | #endif |
| 3859 | #else /* ! YYPARSE_PARAM */ |
| 3860 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3861 | || defined __cplusplus || defined _MSC_VER) |
| 3862 | int |
| 3863 | yyparse (void) |
| 3864 | #else |
| 3865 | int |
| 3866 | yyparse () |
| 3867 | |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3868 | #endif |
| 3869 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3870 | { |
| 3871 | |
| 3872 | int yystate; |
| 3873 | int yyn; |
| 3874 | int yyresult; |
| 3875 | /* Number of tokens to shift before error messages enabled. */ |
| 3876 | int yyerrstatus; |
| 3877 | /* Look-ahead token as an internal (translated) token number. */ |
| 3878 | int yytoken = 0; |
| 3879 | #if YYERROR_VERBOSE |
| 3880 | /* Buffer for error messages, and its allocated size. */ |
| 3881 | char yymsgbuf[128]; |
| 3882 | char *yymsg = yymsgbuf; |
| 3883 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3884 | #endif |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3885 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3886 | /* Three stacks and their tools: |
| 3887 | `yyss': related to states, |
| 3888 | `yyvs': related to semantic values, |
| 3889 | `yyls': related to locations. |
| 3890 | |
| 3891 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 3892 | to reallocate them elsewhere. */ |
| 3893 | |
| 3894 | /* The state stack. */ |
| 3895 | yytype_int16 yyssa[YYINITDEPTH]; |
| 3896 | yytype_int16 *yyss = yyssa; |
| 3897 | yytype_int16 *yyssp; |
| 3898 | |
| 3899 | /* The semantic value stack. */ |
| 3900 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 3901 | YYSTYPE *yyvs = yyvsa; |
| 3902 | YYSTYPE *yyvsp; |
| 3903 | |
| 3904 | |
| 3905 | |
| 3906 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) |
| 3907 | |
| 3908 | YYSIZE_T yystacksize = YYINITDEPTH; |
| 3909 | |
| 3910 | /* The variables used to return semantic value and location from the |
| 3911 | action routines. */ |
| 3912 | YYSTYPE yyval; |
| 3913 | |
| 3914 | |
| 3915 | /* The number of symbols on the RHS of the reduced rule. |
| 3916 | Keep to zero when no symbol should be popped. */ |
| 3917 | int yylen = 0; |
| 3918 | |
| 3919 | YYDPRINTF ((stderr, "Starting parse\n")); |
| 3920 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3921 | yystate = 0; |
| 3922 | yyerrstatus = 0; |
| 3923 | yynerrs = 0; |
| 3924 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 3925 | |
| 3926 | /* Initialize stack pointers. |
| 3927 | Waste one element of value and location stack |
| 3928 | so that they stay on the same level as the state stack. |
| 3929 | The wasted elements are never initialized. */ |
| 3930 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3931 | yyssp = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3932 | yyvsp = yyvs; |
| 3933 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3934 | goto yysetstate; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3935 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3936 | /*------------------------------------------------------------. |
| 3937 | | yynewstate -- Push a new state, which is found in yystate. | |
| 3938 | `------------------------------------------------------------*/ |
| 3939 | yynewstate: |
| 3940 | /* In all cases, when you get here, the value and location stacks |
| 3941 | have just been pushed. So pushing a state here evens the stacks. */ |
| 3942 | yyssp++; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3943 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3944 | yysetstate: |
| 3945 | *yyssp = yystate; |
| 3946 | |
| 3947 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3948 | { |
| 3949 | /* Get the current used size of the three stacks, in elements. */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3950 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3951 | |
| 3952 | #ifdef yyoverflow |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3953 | { |
| 3954 | /* Give user a chance to reallocate the stack. Use copies of |
| 3955 | these so that the &'s don't force the real ones into |
| 3956 | memory. */ |
| 3957 | YYSTYPE *yyvs1 = yyvs; |
| 3958 | yytype_int16 *yyss1 = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3959 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3960 | |
| 3961 | /* Each stack pointer address is followed by the size of the |
| 3962 | data in use in that stack, in bytes. This used to be a |
| 3963 | conditional around just the two extra args, but that might |
| 3964 | be undefined if yyoverflow is a macro. */ |
| 3965 | yyoverflow (YY_("memory exhausted"), |
| 3966 | &yyss1, yysize * sizeof (*yyssp), |
| 3967 | &yyvs1, yysize * sizeof (*yyvsp), |
| 3968 | |
| 3969 | &yystacksize); |
| 3970 | |
| 3971 | yyss = yyss1; |
| 3972 | yyvs = yyvs1; |
| 3973 | } |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3974 | #else /* no yyoverflow */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3975 | # ifndef YYSTACK_RELOCATE |
| 3976 | goto yyexhaustedlab; |
| 3977 | # else |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3978 | /* Extend the stack our own way. */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3979 | if (YYMAXDEPTH <= yystacksize) |
| 3980 | goto yyexhaustedlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3981 | yystacksize *= 2; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3982 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3983 | yystacksize = YYMAXDEPTH; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3984 | |
| 3985 | { |
| 3986 | yytype_int16 *yyss1 = yyss; |
| 3987 | union yyalloc *yyptr = |
| 3988 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 3989 | if (! yyptr) |
| 3990 | goto yyexhaustedlab; |
| 3991 | YYSTACK_RELOCATE (yyss); |
| 3992 | YYSTACK_RELOCATE (yyvs); |
| 3993 | |
| 3994 | # undef YYSTACK_RELOCATE |
| 3995 | if (yyss1 != yyssa) |
| 3996 | YYSTACK_FREE (yyss1); |
| 3997 | } |
| 3998 | # endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3999 | #endif /* no yyoverflow */ |
| 4000 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4001 | yyssp = yyss + yysize - 1; |
| 4002 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4003 | |
| 4004 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4005 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 4006 | (unsigned long int) yystacksize)); |
| 4007 | |
| 4008 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4009 | YYABORT; |
| 4010 | } |
| 4011 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4012 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4013 | |
| 4014 | goto yybackup; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4015 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4016 | /*-----------. |
| 4017 | | yybackup. | |
| 4018 | `-----------*/ |
| 4019 | yybackup: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4020 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4021 | /* Do appropriate processing given the current state. Read a |
| 4022 | look-ahead token if we need one and don't already have one. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4023 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4024 | /* First try to decide what to do without reference to look-ahead token. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4025 | yyn = yypact[yystate]; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4026 | if (yyn == YYPACT_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4027 | goto yydefault; |
| 4028 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4029 | /* Not known => get a look-ahead token if don't already have one. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4030 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4031 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4032 | if (yychar == YYEMPTY) |
| 4033 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4034 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4035 | yychar = YYLEX; |
| 4036 | } |
| 4037 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4038 | if (yychar <= YYEOF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4039 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4040 | yychar = yytoken = YYEOF; |
| 4041 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4042 | } |
| 4043 | else |
| 4044 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4045 | yytoken = YYTRANSLATE (yychar); |
| 4046 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4047 | } |
| 4048 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4049 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 4050 | detect an error, take that action. */ |
| 4051 | yyn += yytoken; |
| 4052 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4053 | goto yydefault; |
| 4054 | yyn = yytable[yyn]; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4055 | if (yyn <= 0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4056 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4057 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4058 | goto yyerrlab; |
| 4059 | yyn = -yyn; |
| 4060 | goto yyreduce; |
| 4061 | } |
| 4062 | |
| 4063 | if (yyn == YYFINAL) |
| 4064 | YYACCEPT; |
| 4065 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4066 | /* Count tokens shifted since error; after three, turn off error |
| 4067 | status. */ |
| 4068 | if (yyerrstatus) |
| 4069 | yyerrstatus--; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 4070 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4071 | /* Shift the look-ahead token. */ |
| 4072 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4073 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4074 | /* Discard the shifted token unless it is eof. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 4075 | if (yychar != YYEOF) |
| 4076 | yychar = YYEMPTY; |
| 4077 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 4078 | yystate = yyn; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4079 | *++yyvsp = yylval; |
| 4080 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4081 | goto yynewstate; |
| 4082 | |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 4083 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4084 | /*-----------------------------------------------------------. |
| 4085 | | yydefault -- do the default action for the current state. | |
| 4086 | `-----------------------------------------------------------*/ |
| 4087 | yydefault: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4088 | yyn = yydefact[yystate]; |
| 4089 | if (yyn == 0) |
| 4090 | goto yyerrlab; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4091 | goto yyreduce; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4092 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4093 | |
| 4094 | /*-----------------------------. |
| 4095 | | yyreduce -- Do a reduction. | |
| 4096 | `-----------------------------*/ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4097 | yyreduce: |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4098 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4099 | yylen = yyr2[yyn]; |
| 4100 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4101 | /* If YYLEN is nonzero, implement the default value of the action: |
| 4102 | `$$ = $1'. |
| 4103 | |
| 4104 | Otherwise, the following line sets YYVAL to garbage. |
| 4105 | This behavior is undocumented and Bison |
| 4106 | users should not rely upon it. Assigning to YYVAL |
| 4107 | unconditionally makes the parser a bit smaller, and it avoids a |
| 4108 | GCC warning that YYVAL may be used uninitialized. */ |
| 4109 | yyval = yyvsp[1-yylen]; |
| 4110 | |
| 4111 | |
| 4112 | YY_REDUCE_PRINT (yyn); |
| 4113 | switch (yyn) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4114 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4115 | case 3: |
| 4116 | #line 1821 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4117 | { |
| 4118 | if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4119 | error("Value too large for type"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4120 | (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal); |
| 4121 | ;} |
| 4122 | break; |
| 4123 | |
| 4124 | case 5: |
| 4125 | #line 1830 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4126 | { |
| 4127 | if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4128 | error("Value too large for type"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4129 | (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val); |
| 4130 | ;} |
| 4131 | break; |
| 4132 | |
| 4133 | case 26: |
| 4134 | #line 1852 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4135 | { (yyval.IPred) = ICmpInst::ICMP_EQ; ;} |
| 4136 | break; |
| 4137 | |
| 4138 | case 27: |
| 4139 | #line 1852 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4140 | { (yyval.IPred) = ICmpInst::ICMP_NE; ;} |
| 4141 | break; |
| 4142 | |
| 4143 | case 28: |
| 4144 | #line 1853 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4145 | { (yyval.IPred) = ICmpInst::ICMP_SLT; ;} |
| 4146 | break; |
| 4147 | |
| 4148 | case 29: |
| 4149 | #line 1853 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4150 | { (yyval.IPred) = ICmpInst::ICMP_SGT; ;} |
| 4151 | break; |
| 4152 | |
| 4153 | case 30: |
| 4154 | #line 1854 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4155 | { (yyval.IPred) = ICmpInst::ICMP_SLE; ;} |
| 4156 | break; |
| 4157 | |
| 4158 | case 31: |
| 4159 | #line 1854 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4160 | { (yyval.IPred) = ICmpInst::ICMP_SGE; ;} |
| 4161 | break; |
| 4162 | |
| 4163 | case 32: |
| 4164 | #line 1855 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4165 | { (yyval.IPred) = ICmpInst::ICMP_ULT; ;} |
| 4166 | break; |
| 4167 | |
| 4168 | case 33: |
| 4169 | #line 1855 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4170 | { (yyval.IPred) = ICmpInst::ICMP_UGT; ;} |
| 4171 | break; |
| 4172 | |
| 4173 | case 34: |
| 4174 | #line 1856 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4175 | { (yyval.IPred) = ICmpInst::ICMP_ULE; ;} |
| 4176 | break; |
| 4177 | |
| 4178 | case 35: |
| 4179 | #line 1856 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4180 | { (yyval.IPred) = ICmpInst::ICMP_UGE; ;} |
| 4181 | break; |
| 4182 | |
| 4183 | case 36: |
| 4184 | #line 1860 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4185 | { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;} |
| 4186 | break; |
| 4187 | |
| 4188 | case 37: |
| 4189 | #line 1860 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4190 | { (yyval.FPred) = FCmpInst::FCMP_ONE; ;} |
| 4191 | break; |
| 4192 | |
| 4193 | case 38: |
| 4194 | #line 1861 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4195 | { (yyval.FPred) = FCmpInst::FCMP_OLT; ;} |
| 4196 | break; |
| 4197 | |
| 4198 | case 39: |
| 4199 | #line 1861 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4200 | { (yyval.FPred) = FCmpInst::FCMP_OGT; ;} |
| 4201 | break; |
| 4202 | |
| 4203 | case 40: |
| 4204 | #line 1862 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4205 | { (yyval.FPred) = FCmpInst::FCMP_OLE; ;} |
| 4206 | break; |
| 4207 | |
| 4208 | case 41: |
| 4209 | #line 1862 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4210 | { (yyval.FPred) = FCmpInst::FCMP_OGE; ;} |
| 4211 | break; |
| 4212 | |
| 4213 | case 42: |
| 4214 | #line 1863 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4215 | { (yyval.FPred) = FCmpInst::FCMP_ORD; ;} |
| 4216 | break; |
| 4217 | |
| 4218 | case 43: |
| 4219 | #line 1863 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4220 | { (yyval.FPred) = FCmpInst::FCMP_UNO; ;} |
| 4221 | break; |
| 4222 | |
| 4223 | case 44: |
| 4224 | #line 1864 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4225 | { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;} |
| 4226 | break; |
| 4227 | |
| 4228 | case 45: |
| 4229 | #line 1864 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4230 | { (yyval.FPred) = FCmpInst::FCMP_UNE; ;} |
| 4231 | break; |
| 4232 | |
| 4233 | case 46: |
| 4234 | #line 1865 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4235 | { (yyval.FPred) = FCmpInst::FCMP_ULT; ;} |
| 4236 | break; |
| 4237 | |
| 4238 | case 47: |
| 4239 | #line 1865 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4240 | { (yyval.FPred) = FCmpInst::FCMP_UGT; ;} |
| 4241 | break; |
| 4242 | |
| 4243 | case 48: |
| 4244 | #line 1866 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4245 | { (yyval.FPred) = FCmpInst::FCMP_ULE; ;} |
| 4246 | break; |
| 4247 | |
| 4248 | case 49: |
| 4249 | #line 1866 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4250 | { (yyval.FPred) = FCmpInst::FCMP_UGE; ;} |
| 4251 | break; |
| 4252 | |
| 4253 | case 50: |
| 4254 | #line 1867 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4255 | { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;} |
| 4256 | break; |
| 4257 | |
| 4258 | case 51: |
| 4259 | #line 1868 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4260 | { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;} |
| 4261 | break; |
| 4262 | |
| 4263 | case 81: |
| 4264 | #line 1899 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4265 | { |
| 4266 | (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal); |
| 4267 | ;} |
| 4268 | break; |
| 4269 | |
| 4270 | case 82: |
| 4271 | #line 1902 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4272 | { |
| 4273 | (yyval.StrVal) = 0; |
| 4274 | ;} |
| 4275 | break; |
| 4276 | |
| 4277 | case 83: |
| 4278 | #line 1907 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4279 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 4280 | break; |
| 4281 | |
| 4282 | case 84: |
| 4283 | #line 1908 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4284 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 4285 | break; |
| 4286 | |
| 4287 | case 85: |
| 4288 | #line 1909 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4289 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 4290 | break; |
| 4291 | |
| 4292 | case 86: |
| 4293 | #line 1910 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4294 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 4295 | break; |
| 4296 | |
| 4297 | case 87: |
| 4298 | #line 1911 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4299 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 4300 | break; |
| 4301 | |
| 4302 | case 88: |
| 4303 | #line 1912 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4304 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 4305 | break; |
| 4306 | |
| 4307 | case 89: |
| 4308 | #line 1913 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4309 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 4310 | break; |
| 4311 | |
| 4312 | case 90: |
| 4313 | #line 1914 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4314 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 4315 | break; |
| 4316 | |
| 4317 | case 91: |
| 4318 | #line 1918 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4319 | { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;} |
| 4320 | break; |
| 4321 | |
| 4322 | case 92: |
| 4323 | #line 1919 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4324 | { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;} |
| 4325 | break; |
| 4326 | |
| 4327 | case 93: |
| 4328 | #line 1920 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4329 | { (yyval.UIntVal) = lastCallingConv = OldCallingConv::CSRet; ;} |
| 4330 | break; |
| 4331 | |
| 4332 | case 94: |
| 4333 | #line 1921 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4334 | { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Fast; ;} |
| 4335 | break; |
| 4336 | |
| 4337 | case 95: |
| 4338 | #line 1922 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4339 | { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Cold; ;} |
| 4340 | break; |
| 4341 | |
| 4342 | case 96: |
| 4343 | #line 1923 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4344 | { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_StdCall; ;} |
| 4345 | break; |
| 4346 | |
| 4347 | case 97: |
| 4348 | #line 1924 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4349 | { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_FastCall; ;} |
| 4350 | break; |
| 4351 | |
| 4352 | case 98: |
| 4353 | #line 1925 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4354 | { |
| 4355 | if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4356 | error("Calling conv too large"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4357 | (yyval.UIntVal) = lastCallingConv = (yyvsp[(2) - (2)].UInt64Val); |
| 4358 | ;} |
| 4359 | break; |
| 4360 | |
| 4361 | case 99: |
| 4362 | #line 1935 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4363 | { (yyval.UIntVal) = 0; ;} |
| 4364 | break; |
| 4365 | |
| 4366 | case 100: |
| 4367 | #line 1936 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4368 | { |
| 4369 | (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val); |
| 4370 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4371 | error("Alignment must be a power of two"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4372 | ;} |
| 4373 | break; |
| 4374 | |
| 4375 | case 101: |
| 4376 | #line 1944 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4377 | { (yyval.UIntVal) = 0; ;} |
| 4378 | break; |
| 4379 | |
| 4380 | case 102: |
| 4381 | #line 1945 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4382 | { |
| 4383 | (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val); |
| 4384 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4385 | error("Alignment must be a power of two"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4386 | ;} |
| 4387 | break; |
| 4388 | |
| 4389 | case 103: |
| 4390 | #line 1953 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4391 | { |
| 4392 | for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i) |
| 4393 | if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\') |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4394 | error("Invalid character in section name"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4395 | (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal); |
| 4396 | ;} |
| 4397 | break; |
| 4398 | |
| 4399 | case 104: |
| 4400 | #line 1962 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4401 | { (yyval.StrVal) = 0; ;} |
| 4402 | break; |
| 4403 | |
| 4404 | case 105: |
| 4405 | #line 1963 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4406 | { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;} |
| 4407 | break; |
| 4408 | |
| 4409 | case 106: |
| 4410 | #line 1970 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4411 | {;} |
| 4412 | break; |
| 4413 | |
| 4414 | case 107: |
| 4415 | #line 1971 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4416 | {;} |
| 4417 | break; |
| 4418 | |
| 4419 | case 108: |
| 4420 | #line 1975 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4421 | { |
| 4422 | CurGV->setSection((yyvsp[(1) - (1)].StrVal)); |
| 4423 | free((yyvsp[(1) - (1)].StrVal)); |
| 4424 | ;} |
| 4425 | break; |
| 4426 | |
| 4427 | case 109: |
| 4428 | #line 1979 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4429 | { |
| 4430 | if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4431 | error("Alignment must be a power of two"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4432 | CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4433 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4434 | ;} |
| 4435 | break; |
| 4436 | |
| 4437 | case 111: |
| 4438 | #line 1996 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4439 | { |
| 4440 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T); |
| 4441 | (yyval.TypeVal).S.makeSignless(); |
| 4442 | ;} |
| 4443 | break; |
| 4444 | |
| 4445 | case 113: |
| 4446 | #line 2004 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4447 | { |
| 4448 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T); |
| 4449 | (yyval.TypeVal).S.makeSignless(); |
| 4450 | ;} |
| 4451 | break; |
| 4452 | |
| 4453 | case 114: |
| 4454 | #line 2011 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4455 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4456 | if (!UpRefs.empty()) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4457 | error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).PAT)->getDescription()); |
| 4458 | (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal); |
| 4459 | ;} |
| 4460 | break; |
| 4461 | |
| 4462 | case 127: |
| 4463 | #line 2025 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4464 | { |
| 4465 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T); |
| 4466 | (yyval.TypeVal).S.copy((yyvsp[(1) - (1)].PrimType).S); |
| 4467 | ;} |
| 4468 | break; |
| 4469 | |
| 4470 | case 128: |
| 4471 | #line 2029 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4472 | { |
| 4473 | (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get()); |
| 4474 | (yyval.TypeVal).S.makeSignless(); |
| 4475 | ;} |
| 4476 | break; |
| 4477 | |
| 4478 | case 129: |
| 4479 | #line 2033 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4480 | { // Named types are also simple types... |
| 4481 | (yyval.TypeVal).S.copy(getTypeSign((yyvsp[(1) - (1)].ValIDVal))); |
| 4482 | const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal)); |
| 4483 | (yyval.TypeVal).PAT = new PATypeHolder(tmp); |
| 4484 | ;} |
| 4485 | break; |
| 4486 | |
| 4487 | case 130: |
| 4488 | #line 2038 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4489 | { // Type UpReference |
| 4490 | if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4491 | error("Value out of range"); |
| 4492 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4493 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector... |
| 4494 | (yyval.TypeVal).PAT = new PATypeHolder(OT); |
| 4495 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4496 | UR_OUT("New Upreference!\n"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4497 | ;} |
| 4498 | break; |
| 4499 | |
| 4500 | case 131: |
| 4501 | #line 2047 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4502 | { // Function derived type? |
| 4503 | (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (4)].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4504 | std::vector<const Type*> Params; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4505 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(), |
| 4506 | E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4507 | Params.push_back(I->PAT->get()); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4508 | (yyval.TypeVal).S.add(I->S); |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4509 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4510 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 4511 | if (isVarArg) Params.pop_back(); |
| 4512 | |
Duncan Sands | afa3b6d | 2007-11-28 17:07:01 +0000 | [diff] [blame] | 4513 | const ParamAttrsList *PAL = 0; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 4514 | if (lastCallingConv == OldCallingConv::CSRet) { |
| 4515 | ParamAttrsVector Attrs; |
| 4516 | ParamAttrsWithIndex PAWI; |
| 4517 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 4518 | Attrs.push_back(PAWI); |
| 4519 | PAL = ParamAttrsList::get(Attrs); |
| 4520 | } |
| 4521 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4522 | const FunctionType *FTy = |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4523 | FunctionType::get((yyvsp[(1) - (4)].TypeVal).PAT->get(), Params, isVarArg); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4524 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4525 | (yyval.TypeVal).PAT = new PATypeHolder( HandleUpRefs(FTy, (yyval.TypeVal).S) ); |
| 4526 | delete (yyvsp[(1) - (4)].TypeVal).PAT; // Delete the return type handle |
| 4527 | delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list |
| 4528 | ;} |
| 4529 | break; |
| 4530 | |
| 4531 | case 132: |
| 4532 | #line 2074 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4533 | { // Sized array type? |
| 4534 | (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S); |
| 4535 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).PAT->get(), |
| 4536 | (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S)); |
| 4537 | delete (yyvsp[(4) - (5)].TypeVal).PAT; |
| 4538 | ;} |
| 4539 | break; |
| 4540 | |
| 4541 | case 133: |
| 4542 | #line 2080 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4543 | { // Vector type? |
| 4544 | const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).PAT->get(); |
| 4545 | if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4546 | error("Unsigned result not equal to signed result"); |
| 4547 | if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint())) |
| 4548 | error("Elements of a VectorType must be integer or floating point"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4549 | if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val))) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4550 | error("VectorType length should be a power of 2"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4551 | (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S); |
| 4552 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, |
| 4553 | (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S)); |
| 4554 | delete (yyvsp[(4) - (5)].TypeVal).PAT; |
| 4555 | ;} |
| 4556 | break; |
| 4557 | |
| 4558 | case 134: |
| 4559 | #line 2093 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4560 | { // Structure type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4561 | std::vector<const Type*> Elements; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4562 | (yyval.TypeVal).S.makeComposite(); |
| 4563 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(), |
| 4564 | E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4565 | Elements.push_back(I->PAT->get()); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4566 | (yyval.TypeVal).S.add(I->S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4567 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4568 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S)); |
| 4569 | delete (yyvsp[(2) - (3)].TypeList); |
| 4570 | ;} |
| 4571 | break; |
| 4572 | |
| 4573 | case 135: |
| 4574 | #line 2104 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4575 | { // Empty structure type? |
| 4576 | (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
| 4577 | (yyval.TypeVal).S.makeComposite(); |
| 4578 | ;} |
| 4579 | break; |
| 4580 | |
| 4581 | case 136: |
| 4582 | #line 2108 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4583 | { // Packed Structure type? |
| 4584 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4585 | std::vector<const Type*> Elements; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4586 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(), |
| 4587 | E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4588 | Elements.push_back(I->PAT->get()); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4589 | (yyval.TypeVal).S.add(I->S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4590 | delete I->PAT; |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4591 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4592 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true), |
| 4593 | (yyval.TypeVal).S)); |
| 4594 | delete (yyvsp[(3) - (5)].TypeList); |
| 4595 | ;} |
| 4596 | break; |
| 4597 | |
| 4598 | case 137: |
| 4599 | #line 2121 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4600 | { // Empty packed structure type? |
| 4601 | (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true)); |
| 4602 | (yyval.TypeVal).S.makeComposite(); |
| 4603 | ;} |
| 4604 | break; |
| 4605 | |
| 4606 | case 138: |
| 4607 | #line 2125 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4608 | { // Pointer type? |
| 4609 | if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::LabelTy) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4610 | error("Cannot form a pointer to a basic block"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4611 | (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (2)].TypeVal).S); |
| 4612 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[(1) - (2)].TypeVal).PAT->get()), |
| 4613 | (yyval.TypeVal).S)); |
| 4614 | delete (yyvsp[(1) - (2)].TypeVal).PAT; |
| 4615 | ;} |
| 4616 | break; |
| 4617 | |
| 4618 | case 139: |
| 4619 | #line 2139 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4620 | { |
| 4621 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
| 4622 | (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal)); |
| 4623 | ;} |
| 4624 | break; |
| 4625 | |
| 4626 | case 140: |
| 4627 | #line 2143 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4628 | { |
| 4629 | ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal)); |
| 4630 | ;} |
| 4631 | break; |
| 4632 | |
| 4633 | case 142: |
| 4634 | #line 2151 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4635 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4636 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4637 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4638 | VoidTI.S.makeSignless(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4639 | ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI); |
| 4640 | ;} |
| 4641 | break; |
| 4642 | |
| 4643 | case 143: |
| 4644 | #line 2157 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4645 | { |
| 4646 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4647 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4648 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4649 | VoidTI.S.makeSignless(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4650 | (yyval.TypeList)->push_back(VoidTI); |
| 4651 | ;} |
| 4652 | break; |
| 4653 | |
| 4654 | case 144: |
| 4655 | #line 2164 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4656 | { |
| 4657 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
| 4658 | ;} |
| 4659 | break; |
| 4660 | |
| 4661 | case 145: |
| 4662 | #line 2176 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4663 | { // Nonempty unsized arr |
| 4664 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4665 | if (ATy == 0) |
| 4666 | error("Cannot make array constant with type: '" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4667 | (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4668 | const Type *ETy = ATy->getElementType(); |
| 4669 | int NumElements = ATy->getNumElements(); |
| 4670 | |
| 4671 | // Verify that we have the correct size... |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4672 | if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4673 | error("Type mismatch: constant sized array initialized with " + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4674 | utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4675 | itostr(NumElements) + ""); |
| 4676 | |
| 4677 | // Verify all elements are correct type! |
| 4678 | std::vector<Constant*> Elems; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4679 | for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) { |
| 4680 | Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4681 | const Type* ValTy = C->getType(); |
| 4682 | if (ETy != ValTy) |
| 4683 | error("Element #" + utostr(i) + " is not of type '" + |
| 4684 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4685 | ValTy->getDescription() + "'"); |
| 4686 | Elems.push_back(C); |
| 4687 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4688 | (yyval.ConstVal).C = ConstantArray::get(ATy, Elems); |
| 4689 | (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S); |
| 4690 | delete (yyvsp[(1) - (4)].TypeVal).PAT; |
| 4691 | delete (yyvsp[(3) - (4)].ConstVector); |
| 4692 | ;} |
| 4693 | break; |
| 4694 | |
| 4695 | case 146: |
| 4696 | #line 2206 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4697 | { |
| 4698 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4699 | if (ATy == 0) |
| 4700 | error("Cannot make array constant with type: '" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4701 | (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4702 | int NumElements = ATy->getNumElements(); |
| 4703 | if (NumElements != -1 && NumElements != 0) |
| 4704 | error("Type mismatch: constant sized array initialized with 0" |
| 4705 | " arguments, but has size of " + itostr(NumElements) +""); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4706 | (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 4707 | (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S); |
| 4708 | delete (yyvsp[(1) - (3)].TypeVal).PAT; |
| 4709 | ;} |
| 4710 | break; |
| 4711 | |
| 4712 | case 147: |
| 4713 | #line 2219 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4714 | { |
| 4715 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4716 | if (ATy == 0) |
| 4717 | error("Cannot make array constant with type: '" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4718 | (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4719 | int NumElements = ATy->getNumElements(); |
| 4720 | const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType()); |
| 4721 | if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8) |
| 4722 | error("String arrays require type i8, not '" + ETy->getDescription() + |
| 4723 | "'"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4724 | char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true); |
| 4725 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4726 | error("Can't build string constant of size " + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4727 | itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4728 | itostr(NumElements) + ""); |
| 4729 | std::vector<Constant*> Vals; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4730 | for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4731 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4732 | free((yyvsp[(3) - (3)].StrVal)); |
| 4733 | (yyval.ConstVal).C = ConstantArray::get(ATy, Vals); |
| 4734 | (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S); |
| 4735 | delete (yyvsp[(1) - (3)].TypeVal).PAT; |
| 4736 | ;} |
| 4737 | break; |
| 4738 | |
| 4739 | case 148: |
| 4740 | #line 2242 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4741 | { // Nonempty unsized arr |
| 4742 | const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4743 | if (PTy == 0) |
| 4744 | error("Cannot make packed constant with type: '" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4745 | (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4746 | const Type *ETy = PTy->getElementType(); |
| 4747 | int NumElements = PTy->getNumElements(); |
| 4748 | // Verify that we have the correct size... |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4749 | if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4750 | error("Type mismatch: constant sized packed initialized with " + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4751 | utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4752 | itostr(NumElements) + ""); |
| 4753 | // Verify all elements are correct type! |
| 4754 | std::vector<Constant*> Elems; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4755 | for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) { |
| 4756 | Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4757 | const Type* ValTy = C->getType(); |
| 4758 | if (ETy != ValTy) |
| 4759 | error("Element #" + utostr(i) + " is not of type '" + |
| 4760 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4761 | ValTy->getDescription() + "'"); |
| 4762 | Elems.push_back(C); |
| 4763 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4764 | (yyval.ConstVal).C = ConstantVector::get(PTy, Elems); |
| 4765 | (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S); |
| 4766 | delete (yyvsp[(1) - (4)].TypeVal).PAT; |
| 4767 | delete (yyvsp[(3) - (4)].ConstVector); |
| 4768 | ;} |
| 4769 | break; |
| 4770 | |
| 4771 | case 149: |
| 4772 | #line 2270 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4773 | { |
| 4774 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4775 | if (STy == 0) |
| 4776 | error("Cannot make struct constant with type: '" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4777 | (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'"); |
| 4778 | if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4779 | error("Illegal number of initializers for structure type"); |
| 4780 | |
| 4781 | // Check to ensure that constants are compatible with the type initializer! |
| 4782 | std::vector<Constant*> Fields; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4783 | for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) { |
| 4784 | Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4785 | if (C->getType() != STy->getElementType(i)) |
| 4786 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4787 | "' for element #" + utostr(i) + " of structure initializer"); |
| 4788 | Fields.push_back(C); |
| 4789 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4790 | (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); |
| 4791 | (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S); |
| 4792 | delete (yyvsp[(1) - (4)].TypeVal).PAT; |
| 4793 | delete (yyvsp[(3) - (4)].ConstVector); |
| 4794 | ;} |
| 4795 | break; |
| 4796 | |
| 4797 | case 150: |
| 4798 | #line 2292 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4799 | { |
| 4800 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4801 | if (STy == 0) |
| 4802 | error("Cannot make struct constant with type: '" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4803 | (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4804 | if (STy->getNumContainedTypes() != 0) |
| 4805 | error("Illegal number of initializers for structure type"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4806 | (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4807 | (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S); |
| 4808 | delete (yyvsp[(1) - (3)].TypeVal).PAT; |
| 4809 | ;} |
| 4810 | break; |
| 4811 | |
| 4812 | case 151: |
| 4813 | #line 2303 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4814 | { |
| 4815 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4816 | if (STy == 0) |
| 4817 | error("Cannot make packed struct constant with type: '" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4818 | (yyvsp[(1) - (6)].TypeVal).PAT->get()->getDescription() + "'"); |
| 4819 | if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4820 | error("Illegal number of initializers for packed structure type"); |
| 4821 | |
| 4822 | // Check to ensure that constants are compatible with the type initializer! |
| 4823 | std::vector<Constant*> Fields; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4824 | for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) { |
| 4825 | Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4826 | if (C->getType() != STy->getElementType(i)) |
| 4827 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4828 | "' for element #" + utostr(i) + " of packed struct initializer"); |
| 4829 | Fields.push_back(C); |
| 4830 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4831 | (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); |
| 4832 | (yyval.ConstVal).S.copy((yyvsp[(1) - (6)].TypeVal).S); |
| 4833 | delete (yyvsp[(1) - (6)].TypeVal).PAT; |
| 4834 | delete (yyvsp[(4) - (6)].ConstVector); |
| 4835 | ;} |
| 4836 | break; |
| 4837 | |
| 4838 | case 152: |
| 4839 | #line 2325 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4840 | { |
| 4841 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4842 | if (STy == 0) |
| 4843 | error("Cannot make packed struct constant with type: '" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4844 | (yyvsp[(1) - (5)].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4845 | if (STy->getNumContainedTypes() != 0) |
| 4846 | error("Illegal number of initializers for packed structure type"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4847 | (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4848 | (yyval.ConstVal).S.copy((yyvsp[(1) - (5)].TypeVal).S); |
| 4849 | delete (yyvsp[(1) - (5)].TypeVal).PAT; |
| 4850 | ;} |
| 4851 | break; |
| 4852 | |
| 4853 | case 153: |
| 4854 | #line 2336 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4855 | { |
| 4856 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4857 | if (PTy == 0) |
| 4858 | error("Cannot make null pointer constant with type: '" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4859 | (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription() + "'"); |
| 4860 | (yyval.ConstVal).C = ConstantPointerNull::get(PTy); |
| 4861 | (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S); |
| 4862 | delete (yyvsp[(1) - (2)].TypeVal).PAT; |
| 4863 | ;} |
| 4864 | break; |
| 4865 | |
| 4866 | case 154: |
| 4867 | #line 2345 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4868 | { |
| 4869 | (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).PAT->get()); |
| 4870 | (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S); |
| 4871 | delete (yyvsp[(1) - (2)].TypeVal).PAT; |
| 4872 | ;} |
| 4873 | break; |
| 4874 | |
| 4875 | case 155: |
| 4876 | #line 2350 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4877 | { |
| 4878 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4879 | if (Ty == 0) |
| 4880 | error("Global const reference must be a pointer type, not" + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4881 | (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4882 | |
| 4883 | // ConstExprs can exist in the body of a function, thus creating |
| 4884 | // GlobalValues whenever they refer to a variable. Because we are in |
| 4885 | // the context of a function, getExistingValue will search the functions |
| 4886 | // symbol table instead of the module symbol table for the global symbol, |
| 4887 | // which throws things all off. To get around this, we just tell |
| 4888 | // getExistingValue that we are at global scope here. |
| 4889 | // |
| 4890 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 4891 | CurFun.CurrentFunction = 0; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4892 | (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S); |
| 4893 | Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4894 | CurFun.CurrentFunction = SavedCurFn; |
| 4895 | |
| 4896 | // If this is an initializer for a constant pointer, which is referencing a |
| 4897 | // (currently) undefined variable, create a stub now that shall be replaced |
| 4898 | // in the future with the right type of variable. |
| 4899 | // |
| 4900 | if (V == 0) { |
| 4901 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers"); |
| 4902 | const PointerType *PT = cast<PointerType>(Ty); |
| 4903 | |
| 4904 | // First check to see if the forward references value is already created! |
| 4905 | PerModuleInfo::GlobalRefsType::iterator I = |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4906 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4907 | |
| 4908 | if (I != CurModule.GlobalRefs.end()) { |
| 4909 | V = I->second; // Placeholder already exists, use it... |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4910 | (yyvsp[(2) - (2)].ValIDVal).destroy(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4911 | } else { |
| 4912 | std::string Name; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4913 | if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4914 | |
| 4915 | // Create the forward referenced global. |
| 4916 | GlobalValue *GV; |
| 4917 | if (const FunctionType *FTy = |
| 4918 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 4919 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 4920 | CurModule.CurrentModule); |
| 4921 | } else { |
| 4922 | GV = new GlobalVariable(PT->getElementType(), false, |
| 4923 | GlobalValue::ExternalLinkage, 0, |
| 4924 | Name, CurModule.CurrentModule); |
| 4925 | } |
| 4926 | |
| 4927 | // Keep track of the fact that we have a forward ref to recycle it |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4928 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4929 | V = GV; |
| 4930 | } |
| 4931 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4932 | (yyval.ConstVal).C = cast<GlobalValue>(V); |
| 4933 | (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S); |
| 4934 | delete (yyvsp[(1) - (2)].TypeVal).PAT; // Free the type handle |
| 4935 | ;} |
| 4936 | break; |
| 4937 | |
| 4938 | case 156: |
| 4939 | #line 2409 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4940 | { |
| 4941 | if ((yyvsp[(1) - (2)].TypeVal).PAT->get() != (yyvsp[(2) - (2)].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4942 | error("Mismatched types for constant expression"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4943 | (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal); |
| 4944 | (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S); |
| 4945 | delete (yyvsp[(1) - (2)].TypeVal).PAT; |
| 4946 | ;} |
| 4947 | break; |
| 4948 | |
| 4949 | case 157: |
| 4950 | #line 2416 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4951 | { |
| 4952 | const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4953 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 4954 | error("Cannot create a null initialized value of this type"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4955 | (yyval.ConstVal).C = Constant::getNullValue(Ty); |
| 4956 | (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S); |
| 4957 | delete (yyvsp[(1) - (2)].TypeVal).PAT; |
| 4958 | ;} |
| 4959 | break; |
| 4960 | |
| 4961 | case 158: |
| 4962 | #line 2424 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4963 | { // integral constants |
| 4964 | const Type *Ty = (yyvsp[(1) - (2)].PrimType).T; |
| 4965 | if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4966 | error("Constant value doesn't fit in type"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4967 | (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val)); |
| 4968 | (yyval.ConstVal).S.makeSigned(); |
| 4969 | ;} |
| 4970 | break; |
| 4971 | |
| 4972 | case 159: |
| 4973 | #line 2431 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4974 | { // integral constants |
| 4975 | const Type *Ty = (yyvsp[(1) - (2)].PrimType).T; |
| 4976 | if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4977 | error("Constant value doesn't fit in type"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4978 | (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val)); |
| 4979 | (yyval.ConstVal).S.makeUnsigned(); |
| 4980 | ;} |
| 4981 | break; |
| 4982 | |
| 4983 | case 160: |
| 4984 | #line 2438 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4985 | { // Boolean constants |
| 4986 | (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true); |
| 4987 | (yyval.ConstVal).S.makeUnsigned(); |
| 4988 | ;} |
| 4989 | break; |
| 4990 | |
| 4991 | case 161: |
| 4992 | #line 2442 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4993 | { // Boolean constants |
| 4994 | (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false); |
| 4995 | (yyval.ConstVal).S.makeUnsigned(); |
| 4996 | ;} |
| 4997 | break; |
| 4998 | |
| 4999 | case 162: |
| 5000 | #line 2446 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5001 | { // Float & Double constants |
| 5002 | if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, *(yyvsp[(2) - (2)].FPVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5003 | error("Floating point constant invalid for type"); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 5004 | // Lexer has no type info, so builds all FP constants as double. |
| 5005 | // Fix this here. |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5006 | if ((yyvsp[(1) - (2)].PrimType).T==Type::FloatTy) |
| 5007 | (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); |
| 5008 | (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, *(yyvsp[(2) - (2)].FPVal)); |
| 5009 | delete (yyvsp[(2) - (2)].FPVal); |
| 5010 | (yyval.ConstVal).S.makeSignless(); |
| 5011 | ;} |
| 5012 | break; |
| 5013 | |
| 5014 | case 163: |
| 5015 | #line 2460 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5016 | { |
| 5017 | const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType(); |
| 5018 | const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).PAT->get(); |
| 5019 | Signedness SrcSign((yyvsp[(3) - (6)].ConstVal).S); |
| 5020 | Signedness DstSign((yyvsp[(5) - (6)].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5021 | if (!SrcTy->isFirstClassType()) |
| 5022 | error("cast constant expression from a non-primitive type: '" + |
| 5023 | SrcTy->getDescription() + "'"); |
| 5024 | if (!DstTy->isFirstClassType()) |
| 5025 | error("cast constant expression to a non-primitive type: '" + |
| 5026 | DstTy->getDescription() + "'"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5027 | (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal).C, SrcSign, DstTy, DstSign)); |
| 5028 | (yyval.ConstVal).S.copy(DstSign); |
| 5029 | delete (yyvsp[(5) - (6)].TypeVal).PAT; |
| 5030 | ;} |
| 5031 | break; |
| 5032 | |
| 5033 | case 164: |
| 5034 | #line 2475 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5035 | { |
| 5036 | const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5037 | if (!isa<PointerType>(Ty)) |
| 5038 | error("GetElementPtr requires a pointer operand"); |
| 5039 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5040 | std::vector<Constant*> CIndices; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5041 | upgradeGEPCEIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), CIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5042 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5043 | delete (yyvsp[(4) - (5)].ValueList); |
| 5044 | (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, &CIndices[0], CIndices.size()); |
| 5045 | (yyval.ConstVal).S.copy(getElementSign((yyvsp[(3) - (5)].ConstVal), CIndices)); |
| 5046 | ;} |
| 5047 | break; |
| 5048 | |
| 5049 | case 165: |
| 5050 | #line 2487 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5051 | { |
| 5052 | if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() || |
| 5053 | cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5054 | error("Select condition must be bool type"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5055 | if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5056 | error("Select operand types must match"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5057 | (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C); |
| 5058 | (yyval.ConstVal).S.copy((yyvsp[(5) - (8)].ConstVal).S); |
| 5059 | ;} |
| 5060 | break; |
| 5061 | |
| 5062 | case 166: |
| 5063 | #line 2496 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5064 | { |
| 5065 | const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType(); |
| 5066 | if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5067 | error("Binary operator types must match"); |
| 5068 | // First, make sure we're dealing with the right opcode by upgrading from |
| 5069 | // obsolete versions. |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5070 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5071 | |
| 5072 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 5073 | // To retain backward compatibility with these early compilers, we emit a |
| 5074 | // cast to the appropriate integer type automatically if we are in the |
| 5075 | // broken case. See PR424 for more information. |
| 5076 | if (!isa<PointerType>(Ty)) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5077 | (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5078 | } else { |
| 5079 | const Type *IntPtrTy = 0; |
| 5080 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 5081 | case Module::Pointer32: IntPtrTy = Type::Int32Ty; break; |
| 5082 | case Module::Pointer64: IntPtrTy = Type::Int64Ty; break; |
| 5083 | default: error("invalid pointer binary constant expr"); |
| 5084 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5085 | (yyval.ConstVal).C = ConstantExpr::get(Opcode, |
| 5086 | ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy), |
| 5087 | ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy)); |
| 5088 | (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5089 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5090 | (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S); |
| 5091 | ;} |
| 5092 | break; |
| 5093 | |
| 5094 | case 167: |
| 5095 | #line 2524 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5096 | { |
| 5097 | const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType(); |
| 5098 | if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5099 | error("Logical operator types must match"); |
| 5100 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5101 | if (!isa<VectorType>(Ty) || |
| 5102 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5103 | error("Logical operator requires integer operands"); |
| 5104 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5105 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S); |
| 5106 | (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C); |
| 5107 | (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S); |
| 5108 | ;} |
| 5109 | break; |
| 5110 | |
| 5111 | case 168: |
| 5112 | #line 2537 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5113 | { |
| 5114 | const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType(); |
| 5115 | if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5116 | error("setcc operand types must match"); |
| 5117 | unsigned short pred; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5118 | Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S); |
| 5119 | (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C); |
| 5120 | (yyval.ConstVal).S.makeUnsigned(); |
| 5121 | ;} |
| 5122 | break; |
| 5123 | |
| 5124 | case 169: |
| 5125 | #line 2546 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5126 | { |
| 5127 | if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5128 | error("icmp operand types must match"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5129 | (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].IPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C); |
| 5130 | (yyval.ConstVal).S.makeUnsigned(); |
| 5131 | ;} |
| 5132 | break; |
| 5133 | |
| 5134 | case 170: |
| 5135 | #line 2552 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5136 | { |
| 5137 | if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5138 | error("fcmp operand types must match"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5139 | (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].FPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C); |
| 5140 | (yyval.ConstVal).S.makeUnsigned(); |
| 5141 | ;} |
| 5142 | break; |
| 5143 | |
| 5144 | case 171: |
| 5145 | #line 2558 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5146 | { |
| 5147 | if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() || |
| 5148 | cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5149 | error("Shift count for shift constant must be unsigned byte"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5150 | const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType(); |
| 5151 | if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5152 | error("Shift constant expression requires integer operand"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5153 | Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[(5) - (6)].ConstVal).C, Ty); |
| 5154 | (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S), (yyvsp[(3) - (6)].ConstVal).C, ShiftAmt); |
| 5155 | (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S); |
| 5156 | ;} |
| 5157 | break; |
| 5158 | |
| 5159 | case 172: |
| 5160 | #line 2569 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5161 | { |
| 5162 | if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5163 | error("Invalid extractelement operands"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5164 | (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C); |
| 5165 | (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S.get(0)); |
| 5166 | ;} |
| 5167 | break; |
| 5168 | |
| 5169 | case 173: |
| 5170 | #line 2575 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5171 | { |
| 5172 | if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5173 | error("Invalid insertelement operands"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5174 | (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C); |
| 5175 | (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S); |
| 5176 | ;} |
| 5177 | break; |
| 5178 | |
| 5179 | case 174: |
| 5180 | #line 2581 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5181 | { |
| 5182 | if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5183 | error("Invalid shufflevector operands"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5184 | (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C); |
| 5185 | (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S); |
| 5186 | ;} |
| 5187 | break; |
| 5188 | |
| 5189 | case 175: |
| 5190 | #line 2592 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5191 | { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;} |
| 5192 | break; |
| 5193 | |
| 5194 | case 176: |
| 5195 | #line 2593 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5196 | { |
| 5197 | (yyval.ConstVector) = new std::vector<ConstInfo>(); |
| 5198 | (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal)); |
| 5199 | ;} |
| 5200 | break; |
| 5201 | |
| 5202 | case 177: |
| 5203 | #line 2602 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5204 | { (yyval.BoolVal) = false; ;} |
| 5205 | break; |
| 5206 | |
| 5207 | case 178: |
| 5208 | #line 2603 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5209 | { (yyval.BoolVal) = true; ;} |
| 5210 | break; |
| 5211 | |
| 5212 | case 179: |
| 5213 | #line 2615 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5214 | { |
| 5215 | (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5216 | CurModule.ModuleDone(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5217 | ;} |
| 5218 | break; |
| 5219 | |
| 5220 | case 180: |
| 5221 | #line 2624 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5222 | { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;} |
| 5223 | break; |
| 5224 | |
| 5225 | case 181: |
| 5226 | #line 2625 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5227 | { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;} |
| 5228 | break; |
| 5229 | |
| 5230 | case 182: |
| 5231 | #line 2626 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5232 | { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;} |
| 5233 | break; |
| 5234 | |
| 5235 | case 183: |
| 5236 | #line 2627 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5237 | { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;} |
| 5238 | break; |
| 5239 | |
| 5240 | case 184: |
| 5241 | #line 2628 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5242 | { |
| 5243 | (yyval.ModuleVal) = CurModule.CurrentModule; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5244 | // Emit an error if there are any unresolved types left. |
| 5245 | if (!CurModule.LateResolveTypes.empty()) { |
| 5246 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 5247 | if (DID.Type == ValID::NameVal) { |
| 5248 | error("Reference to an undefined type: '"+DID.getName() + "'"); |
| 5249 | } else { |
| 5250 | error("Reference to an undefined type: #" + itostr(DID.Num)); |
| 5251 | } |
| 5252 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5253 | ;} |
| 5254 | break; |
| 5255 | |
| 5256 | case 185: |
| 5257 | #line 2644 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5258 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5259 | // Eagerly resolve types. This is not an optimization, this is a |
| 5260 | // requirement that is due to the fact that we could have this: |
| 5261 | // |
| 5262 | // %list = type { %list * } |
| 5263 | // %list = type { %list * } ; repeated type decl |
| 5264 | // |
| 5265 | // If types are not resolved eagerly, then the two types will not be |
| 5266 | // determined to be the same type! |
| 5267 | // |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5268 | ResolveTypeTo((yyvsp[(2) - (4)].StrVal), (yyvsp[(4) - (4)].TypeVal).PAT->get(), (yyvsp[(4) - (4)].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5269 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5270 | if (!setTypeName((yyvsp[(4) - (4)].TypeVal), (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5271 | // If this is a numbered type that is not a redefinition, add it to the |
| 5272 | // slot table. |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5273 | CurModule.Types.push_back((yyvsp[(4) - (4)].TypeVal).PAT->get()); |
| 5274 | CurModule.TypeSigns.push_back((yyvsp[(4) - (4)].TypeVal).S); |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 5275 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5276 | delete (yyvsp[(4) - (4)].TypeVal).PAT; |
| 5277 | ;} |
| 5278 | break; |
| 5279 | |
| 5280 | case 186: |
| 5281 | #line 2664 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5282 | { // Function prototypes can be in const pool |
| 5283 | ;} |
| 5284 | break; |
| 5285 | |
| 5286 | case 187: |
| 5287 | #line 2666 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5288 | { // Asm blocks can be in the const pool |
| 5289 | ;} |
| 5290 | break; |
| 5291 | |
| 5292 | case 188: |
| 5293 | #line 2668 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5294 | { |
| 5295 | if ((yyvsp[(5) - (5)].ConstVal).C == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5296 | error("Global value initializer is not a constant"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5297 | CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), (yyvsp[(3) - (5)].Linkage), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal).C->getType(), (yyvsp[(5) - (5)].ConstVal).C, (yyvsp[(5) - (5)].ConstVal).S); |
| 5298 | ;} |
| 5299 | break; |
| 5300 | |
| 5301 | case 189: |
| 5302 | #line 2672 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5303 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5304 | CurGV = 0; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5305 | ;} |
| 5306 | break; |
| 5307 | |
| 5308 | case 190: |
| 5309 | #line 2675 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5310 | { |
| 5311 | const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get(); |
| 5312 | CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0, |
| 5313 | (yyvsp[(5) - (5)].TypeVal).S); |
| 5314 | delete (yyvsp[(5) - (5)].TypeVal).PAT; |
| 5315 | ;} |
| 5316 | break; |
| 5317 | |
| 5318 | case 191: |
| 5319 | #line 2680 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5320 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5321 | CurGV = 0; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5322 | ;} |
| 5323 | break; |
| 5324 | |
| 5325 | case 192: |
| 5326 | #line 2683 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5327 | { |
| 5328 | const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get(); |
| 5329 | CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0, |
| 5330 | (yyvsp[(5) - (5)].TypeVal).S); |
| 5331 | delete (yyvsp[(5) - (5)].TypeVal).PAT; |
| 5332 | ;} |
| 5333 | break; |
| 5334 | |
| 5335 | case 193: |
| 5336 | #line 2688 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5337 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5338 | CurGV = 0; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5339 | ;} |
| 5340 | break; |
| 5341 | |
| 5342 | case 194: |
| 5343 | #line 2691 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5344 | { |
| 5345 | const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5346 | CurGV = |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5347 | ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0, |
| 5348 | (yyvsp[(5) - (5)].TypeVal).S); |
| 5349 | delete (yyvsp[(5) - (5)].TypeVal).PAT; |
| 5350 | ;} |
| 5351 | break; |
| 5352 | |
| 5353 | case 195: |
| 5354 | #line 2697 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5355 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5356 | CurGV = 0; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5357 | ;} |
| 5358 | break; |
| 5359 | |
| 5360 | case 196: |
| 5361 | #line 2700 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5362 | { |
| 5363 | ;} |
| 5364 | break; |
| 5365 | |
| 5366 | case 197: |
| 5367 | #line 2702 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5368 | { |
| 5369 | ;} |
| 5370 | break; |
| 5371 | |
| 5372 | case 198: |
| 5373 | #line 2704 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5374 | { |
| 5375 | ;} |
| 5376 | break; |
| 5377 | |
| 5378 | case 199: |
| 5379 | #line 2709 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5380 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5381 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5382 | char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true); |
| 5383 | std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr); |
| 5384 | free((yyvsp[(1) - (1)].StrVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5385 | |
| 5386 | if (AsmSoFar.empty()) |
| 5387 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 5388 | else |
| 5389 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5390 | ;} |
| 5391 | break; |
| 5392 | |
| 5393 | case 200: |
| 5394 | #line 2723 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5395 | { (yyval.Endianness) = Module::BigEndian; ;} |
| 5396 | break; |
| 5397 | |
| 5398 | case 201: |
| 5399 | #line 2724 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5400 | { (yyval.Endianness) = Module::LittleEndian; ;} |
| 5401 | break; |
| 5402 | |
| 5403 | case 202: |
| 5404 | #line 2728 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5405 | { |
| 5406 | CurModule.setEndianness((yyvsp[(3) - (3)].Endianness)); |
| 5407 | ;} |
| 5408 | break; |
| 5409 | |
| 5410 | case 203: |
| 5411 | #line 2731 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5412 | { |
| 5413 | if ((yyvsp[(3) - (3)].UInt64Val) == 32) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5414 | CurModule.setPointerSize(Module::Pointer32); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5415 | else if ((yyvsp[(3) - (3)].UInt64Val) == 64) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5416 | CurModule.setPointerSize(Module::Pointer64); |
| 5417 | else |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5418 | error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'"); |
| 5419 | ;} |
| 5420 | break; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5421 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5422 | case 204: |
| 5423 | #line 2739 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5424 | { |
| 5425 | CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal)); |
| 5426 | free((yyvsp[(3) - (3)].StrVal)); |
| 5427 | ;} |
| 5428 | break; |
| 5429 | |
| 5430 | case 205: |
| 5431 | #line 2743 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5432 | { |
| 5433 | CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal)); |
| 5434 | free((yyvsp[(3) - (3)].StrVal)); |
| 5435 | ;} |
| 5436 | break; |
| 5437 | |
| 5438 | case 207: |
| 5439 | #line 2754 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5440 | { |
| 5441 | CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal)); |
| 5442 | free((yyvsp[(3) - (3)].StrVal)); |
| 5443 | ;} |
| 5444 | break; |
| 5445 | |
| 5446 | case 208: |
| 5447 | #line 2758 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5448 | { |
| 5449 | CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal)); |
| 5450 | free((yyvsp[(1) - (1)].StrVal)); |
| 5451 | ;} |
| 5452 | break; |
| 5453 | |
| 5454 | case 209: |
| 5455 | #line 2762 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5456 | { ;} |
| 5457 | break; |
| 5458 | |
| 5459 | case 213: |
| 5460 | #line 2775 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5461 | { (yyval.StrVal) = 0; ;} |
| 5462 | break; |
| 5463 | |
| 5464 | case 214: |
| 5465 | #line 2779 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5466 | { |
| 5467 | if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::VoidTy) |
| 5468 | error("void typed arguments are invalid"); |
| 5469 | (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal)); |
| 5470 | ;} |
| 5471 | break; |
| 5472 | |
| 5473 | case 215: |
| 5474 | #line 2787 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5475 | { |
| 5476 | (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList); |
| 5477 | (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal)); |
| 5478 | delete (yyvsp[(3) - (3)].ArgVal); |
| 5479 | ;} |
| 5480 | break; |
| 5481 | |
| 5482 | case 216: |
| 5483 | #line 2792 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5484 | { |
| 5485 | (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5486 | (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal)); |
| 5487 | delete (yyvsp[(1) - (1)].ArgVal); |
| 5488 | ;} |
| 5489 | break; |
| 5490 | |
| 5491 | case 217: |
| 5492 | #line 2800 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5493 | { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;} |
| 5494 | break; |
| 5495 | |
| 5496 | case 218: |
| 5497 | #line 2801 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5498 | { |
| 5499 | (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList); |
| 5500 | PATypeInfo VoidTI; |
| 5501 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
| 5502 | VoidTI.S.makeSignless(); |
| 5503 | (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 5504 | ;} |
| 5505 | break; |
| 5506 | |
| 5507 | case 219: |
| 5508 | #line 2808 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5509 | { |
| 5510 | (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5511 | PATypeInfo VoidTI; |
| 5512 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
| 5513 | VoidTI.S.makeSignless(); |
| 5514 | (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 5515 | ;} |
| 5516 | break; |
| 5517 | |
| 5518 | case 220: |
| 5519 | #line 2815 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5520 | { (yyval.ArgList) = 0; ;} |
| 5521 | break; |
| 5522 | |
| 5523 | case 221: |
| 5524 | #line 2819 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5525 | { |
| 5526 | UnEscapeLexed((yyvsp[(3) - (8)].StrVal)); |
| 5527 | std::string FunctionName((yyvsp[(3) - (8)].StrVal)); |
| 5528 | free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory! |
| 5529 | |
| 5530 | const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5531 | |
| 5532 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 5533 | error("LLVM functions cannot return aggregate types"); |
| 5534 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5535 | Signedness FTySign; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5536 | FTySign.makeComposite((yyvsp[(2) - (8)].TypeVal).S); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5537 | std::vector<const Type*> ParamTyList; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5538 | |
| 5539 | // In LLVM 2.0 the signatures of three varargs intrinsics changed to take |
| 5540 | // i8*. We check here for those names and override the parameter list |
| 5541 | // types to ensure the prototype is correct. |
| 5542 | if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5543 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5544 | } else if (FunctionName == "llvm.va_copy") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5545 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
| 5546 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5547 | } else if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5548 | for (std::vector<std::pair<PATypeInfo,char*> >::iterator |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5549 | I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5550 | const Type *Ty = I->first.PAT->get(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5551 | ParamTyList.push_back(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5552 | FTySign.add(I->first.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5553 | } |
| 5554 | } |
| 5555 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5556 | bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy; |
| 5557 | if (isVarArg) |
| 5558 | ParamTyList.pop_back(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5559 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5560 | const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5561 | const PointerType *PFT = PointerType::get(FT); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5562 | delete (yyvsp[(2) - (8)].TypeVal).PAT; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5563 | |
| 5564 | ValID ID; |
| 5565 | if (!FunctionName.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5566 | ID = ValID::create((char*)FunctionName.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5567 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5568 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5569 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5570 | ID.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5571 | |
| 5572 | Function *Fn = 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5573 | Module* M = CurModule.CurrentModule; |
| 5574 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5575 | // See if this function was forward referenced. If so, recycle the object. |
| 5576 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 5577 | // Move the function to the end of the list, from whereever it was |
| 5578 | // previously inserted. |
| 5579 | Fn = cast<Function>(FWRef); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5580 | M->getFunctionList().remove(Fn); |
| 5581 | M->getFunctionList().push_back(Fn); |
| 5582 | } else if (!FunctionName.empty()) { |
| 5583 | GlobalValue *Conflict = M->getFunction(FunctionName); |
| 5584 | if (!Conflict) |
| 5585 | Conflict = M->getNamedGlobal(FunctionName); |
| 5586 | if (Conflict && PFT == Conflict->getType()) { |
| 5587 | if (!CurFun.isDeclare && !Conflict->isDeclaration()) { |
| 5588 | // We have two function definitions that conflict, same type, same |
| 5589 | // name. We should really check to make sure that this is the result |
| 5590 | // of integer type planes collapsing and generate an error if it is |
| 5591 | // not, but we'll just rename on the assumption that it is. However, |
| 5592 | // let's do it intelligently and rename the internal linkage one |
| 5593 | // if there is one. |
| 5594 | std::string NewName(makeNameUnique(FunctionName)); |
| 5595 | if (Conflict->hasInternalLinkage()) { |
| 5596 | Conflict->setName(NewName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5597 | RenameMapKey Key = |
| 5598 | makeRenameMapKey(FunctionName, Conflict->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5599 | CurModule.RenameMap[Key] = NewName; |
| 5600 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5601 | InsertValue(Fn, CurModule.Values); |
| 5602 | } else { |
| 5603 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5604 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5605 | RenameMapKey Key = |
| 5606 | makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5607 | CurModule.RenameMap[Key] = NewName; |
| 5608 | } |
| 5609 | } else { |
| 5610 | // If they are not both definitions, then just use the function we |
| 5611 | // found since the types are the same. |
| 5612 | Fn = cast<Function>(Conflict); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5613 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5614 | // Make sure to strip off any argument names so we can't get |
| 5615 | // conflicts. |
| 5616 | if (Fn->isDeclaration()) |
| 5617 | for (Function::arg_iterator AI = Fn->arg_begin(), |
| 5618 | AE = Fn->arg_end(); AI != AE; ++AI) |
| 5619 | AI->setName(""); |
| 5620 | } |
| 5621 | } else if (Conflict) { |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 5622 | // We have two globals with the same name and different types. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5623 | // Previously, this was permitted because the symbol table had |
| 5624 | // "type planes" and names only needed to be distinct within a |
| 5625 | // type plane. After PR411 was fixed, this is no loner the case. |
| 5626 | // To resolve this we must rename one of the two. |
| 5627 | if (Conflict->hasInternalLinkage()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5628 | // We can safely rename the Conflict. |
| 5629 | RenameMapKey Key = |
| 5630 | makeRenameMapKey(Conflict->getName(), Conflict->getType(), |
| 5631 | CurModule.NamedValueSigns[Conflict->getName()]); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5632 | Conflict->setName(makeNameUnique(Conflict->getName())); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5633 | CurModule.RenameMap[Key] = Conflict->getName(); |
| 5634 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5635 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5636 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5637 | // We can't quietly rename either of these things, but we must |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5638 | // rename one of them. Only if the function's linkage is internal can |
| 5639 | // we forgo a warning message about the renamed function. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5640 | std::string NewName = makeNameUnique(FunctionName); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5641 | if (CurFun.Linkage != GlobalValue::InternalLinkage) { |
| 5642 | warning("Renaming function '" + FunctionName + "' as '" + NewName + |
| 5643 | "' may cause linkage errors"); |
| 5644 | } |
| 5645 | // Elect to rename the thing we're now defining. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5646 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5647 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5648 | RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5649 | CurModule.RenameMap[Key] = NewName; |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5650 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5651 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5652 | // There's no conflict, just define the function |
| 5653 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5654 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5655 | } |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 5656 | } else { |
| 5657 | // There's no conflict, just define the function |
| 5658 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5659 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5660 | } |
| 5661 | |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 5662 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5663 | CurFun.FunctionStart(Fn); |
| 5664 | |
| 5665 | if (CurFun.isDeclare) { |
| 5666 | // If we have declaration, always overwrite linkage. This will allow us |
| 5667 | // to correctly handle cases, when pointer to function is passed as |
| 5668 | // argument to another function. |
| 5669 | Fn->setLinkage(CurFun.Linkage); |
| 5670 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5671 | Fn->setCallingConv(upgradeCallingConv((yyvsp[(1) - (8)].UIntVal))); |
| 5672 | Fn->setAlignment((yyvsp[(8) - (8)].UIntVal)); |
| 5673 | if ((yyvsp[(7) - (8)].StrVal)) { |
| 5674 | Fn->setSection((yyvsp[(7) - (8)].StrVal)); |
| 5675 | free((yyvsp[(7) - (8)].StrVal)); |
| 5676 | } |
| 5677 | |
| 5678 | // Convert the CSRet calling convention into the corresponding parameter |
| 5679 | // attribute. |
| 5680 | if ((yyvsp[(1) - (8)].UIntVal) == OldCallingConv::CSRet) { |
| 5681 | ParamAttrsVector Attrs; |
| 5682 | ParamAttrsWithIndex PAWI; |
| 5683 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 5684 | Attrs.push_back(PAWI); |
| 5685 | Fn->setParamAttrs(ParamAttrsList::get(Attrs)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5686 | } |
| 5687 | |
| 5688 | // Add all of the arguments we parsed to the function... |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5689 | if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5690 | if (isVarArg) { // Nuke the last entry |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5691 | assert((yyvsp[(5) - (8)].ArgList)->back().first.PAT->get() == Type::VoidTy && |
| 5692 | (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker"); |
| 5693 | delete (yyvsp[(5) - (8)].ArgList)->back().first.PAT; |
| 5694 | (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5695 | } |
| 5696 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5697 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5698 | std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[(5) - (8)].ArgList)->begin(); |
| 5699 | std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[(5) - (8)].ArgList)->end(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5700 | for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5701 | delete I->first.PAT; // Delete the typeholder... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5702 | ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S); |
| 5703 | setValueName(VI, I->second); // Insert arg into symtab... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5704 | InsertValue(ArgIt); |
| 5705 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5706 | delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5707 | } |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5708 | lastCallingConv = OldCallingConv::C; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5709 | ;} |
| 5710 | break; |
| 5711 | |
| 5712 | case 224: |
| 5713 | #line 3011 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5714 | { CurFun.Linkage = (yyvsp[(1) - (1)].Linkage); ;} |
| 5715 | break; |
| 5716 | |
| 5717 | case 225: |
| 5718 | #line 3011 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5719 | { |
| 5720 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5721 | |
| 5722 | // Make sure that we keep track of the linkage type even if there was a |
| 5723 | // previous "declare". |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5724 | (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage)); |
| 5725 | ;} |
| 5726 | break; |
| 5727 | |
| 5728 | case 228: |
| 5729 | #line 3025 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5730 | { |
| 5731 | (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); |
| 5732 | ;} |
| 5733 | break; |
| 5734 | |
| 5735 | case 229: |
| 5736 | #line 3030 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5737 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 5738 | break; |
| 5739 | |
| 5740 | case 230: |
| 5741 | #line 3031 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5742 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 5743 | break; |
| 5744 | |
| 5745 | case 231: |
| 5746 | #line 3032 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5747 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 5748 | break; |
| 5749 | |
| 5750 | case 232: |
| 5751 | #line 3036 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5752 | { CurFun.isDeclare = true; ;} |
| 5753 | break; |
| 5754 | |
| 5755 | case 233: |
| 5756 | #line 3037 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5757 | { CurFun.Linkage = (yyvsp[(3) - (3)].Linkage); ;} |
| 5758 | break; |
| 5759 | |
| 5760 | case 234: |
| 5761 | #line 3037 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5762 | { |
| 5763 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5764 | CurFun.FunctionDone(); |
| 5765 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5766 | ;} |
| 5767 | break; |
| 5768 | |
| 5769 | case 235: |
| 5770 | #line 3049 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5771 | { (yyval.BoolVal) = false; ;} |
| 5772 | break; |
| 5773 | |
| 5774 | case 236: |
| 5775 | #line 3050 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5776 | { (yyval.BoolVal) = true; ;} |
| 5777 | break; |
| 5778 | |
| 5779 | case 237: |
| 5780 | #line 3055 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5781 | { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;} |
| 5782 | break; |
| 5783 | |
| 5784 | case 238: |
| 5785 | #line 3056 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5786 | { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;} |
| 5787 | break; |
| 5788 | |
| 5789 | case 239: |
| 5790 | #line 3057 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5791 | { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;} |
| 5792 | break; |
| 5793 | |
| 5794 | case 240: |
| 5795 | #line 3058 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5796 | { |
| 5797 | (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); |
| 5798 | (yyval.ValIDVal).S.makeUnsigned(); |
| 5799 | ;} |
| 5800 | break; |
| 5801 | |
| 5802 | case 241: |
| 5803 | #line 3062 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5804 | { |
| 5805 | (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); |
| 5806 | (yyval.ValIDVal).S.makeUnsigned(); |
| 5807 | ;} |
| 5808 | break; |
| 5809 | |
| 5810 | case 242: |
| 5811 | #line 3066 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5812 | { (yyval.ValIDVal) = ValID::createNull(); ;} |
| 5813 | break; |
| 5814 | |
| 5815 | case 243: |
| 5816 | #line 3067 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5817 | { (yyval.ValIDVal) = ValID::createUndef(); ;} |
| 5818 | break; |
| 5819 | |
| 5820 | case 244: |
| 5821 | #line 3068 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5822 | { (yyval.ValIDVal) = ValID::createZeroInit(); ;} |
| 5823 | break; |
| 5824 | |
| 5825 | case 245: |
| 5826 | #line 3069 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5827 | { // Nonempty unsized packed vector |
| 5828 | const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType(); |
| 5829 | int NumElements = (yyvsp[(2) - (3)].ConstVector)->size(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5830 | VectorType* pt = VectorType::get(ETy, NumElements); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5831 | (yyval.ValIDVal).S.makeComposite((*(yyvsp[(2) - (3)].ConstVector))[0].S); |
| 5832 | PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5833 | |
| 5834 | // Verify all elements are correct type! |
| 5835 | std::vector<Constant*> Elems; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5836 | for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) { |
| 5837 | Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5838 | const Type *CTy = C->getType(); |
| 5839 | if (ETy != CTy) |
| 5840 | error("Element #" + utostr(i) + " is not of type '" + |
| 5841 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 5842 | CTy->getDescription() + "'"); |
| 5843 | Elems.push_back(C); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 5844 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5845 | (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems)); |
| 5846 | delete PTy; delete (yyvsp[(2) - (3)].ConstVector); |
| 5847 | ;} |
| 5848 | break; |
| 5849 | |
| 5850 | case 246: |
| 5851 | #line 3090 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5852 | { |
| 5853 | (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C); |
| 5854 | (yyval.ValIDVal).S.copy((yyvsp[(1) - (1)].ConstVal).S); |
| 5855 | ;} |
| 5856 | break; |
| 5857 | |
| 5858 | case 247: |
| 5859 | #line 3094 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5860 | { |
| 5861 | char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true); |
| 5862 | std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End); |
| 5863 | End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true); |
| 5864 | std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End); |
| 5865 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal)); |
| 5866 | free((yyvsp[(3) - (5)].StrVal)); |
| 5867 | free((yyvsp[(5) - (5)].StrVal)); |
| 5868 | ;} |
| 5869 | break; |
| 5870 | |
| 5871 | case 248: |
| 5872 | #line 3108 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5873 | { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;} |
| 5874 | break; |
| 5875 | |
| 5876 | case 249: |
| 5877 | #line 3109 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5878 | { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;} |
| 5879 | break; |
| 5880 | |
| 5881 | case 252: |
| 5882 | #line 3122 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5883 | { |
| 5884 | const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get(); |
| 5885 | (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S); |
| 5886 | (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal)); |
| 5887 | (yyval.ValueVal).S.copy((yyvsp[(1) - (2)].TypeVal).S); |
| 5888 | delete (yyvsp[(1) - (2)].TypeVal).PAT; |
| 5889 | ;} |
| 5890 | break; |
| 5891 | |
| 5892 | case 253: |
| 5893 | #line 3132 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5894 | { |
| 5895 | (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); |
| 5896 | ;} |
| 5897 | break; |
| 5898 | |
| 5899 | case 254: |
| 5900 | #line 3135 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5901 | { // Do not allow functions with 0 basic blocks |
| 5902 | (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); |
| 5903 | ;} |
| 5904 | break; |
| 5905 | |
| 5906 | case 255: |
| 5907 | #line 3144 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5908 | { |
| 5909 | ValueInfo VI; VI.V = (yyvsp[(3) - (3)].TermInstVal).TI; VI.S.copy((yyvsp[(3) - (3)].TermInstVal).S); |
| 5910 | setValueName(VI, (yyvsp[(2) - (3)].StrVal)); |
| 5911 | InsertValue((yyvsp[(3) - (3)].TermInstVal).TI); |
| 5912 | (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal).TI); |
| 5913 | InsertValue((yyvsp[(1) - (3)].BasicBlockVal)); |
| 5914 | (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal); |
| 5915 | ;} |
| 5916 | break; |
| 5917 | |
| 5918 | case 256: |
| 5919 | #line 3155 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5920 | { |
| 5921 | if ((yyvsp[(2) - (2)].InstVal).I) |
| 5922 | (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I); |
| 5923 | (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal); |
| 5924 | ;} |
| 5925 | break; |
| 5926 | |
| 5927 | case 257: |
| 5928 | #line 3160 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5929 | { |
| 5930 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5931 | // Make sure to move the basic block to the correct location in the |
| 5932 | // function, instead of leaving it inserted wherever it was first |
| 5933 | // referenced. |
| 5934 | Function::BasicBlockListType &BBL = |
| 5935 | CurFun.CurrentFunction->getBasicBlockList(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5936 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
| 5937 | ;} |
| 5938 | break; |
| 5939 | |
| 5940 | case 258: |
| 5941 | #line 3169 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5942 | { |
| 5943 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5944 | // Make sure to move the basic block to the correct location in the |
| 5945 | // function, instead of leaving it inserted wherever it was first |
| 5946 | // referenced. |
| 5947 | Function::BasicBlockListType &BBL = |
| 5948 | CurFun.CurrentFunction->getBasicBlockList(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5949 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
| 5950 | ;} |
| 5951 | break; |
| 5952 | |
| 5953 | case 261: |
| 5954 | #line 3183 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5955 | { // Return with a result... |
| 5956 | (yyval.TermInstVal).TI = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V); |
| 5957 | (yyval.TermInstVal).S.makeSignless(); |
| 5958 | ;} |
| 5959 | break; |
| 5960 | |
| 5961 | case 262: |
| 5962 | #line 3187 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5963 | { // Return with no result... |
| 5964 | (yyval.TermInstVal).TI = new ReturnInst(); |
| 5965 | (yyval.TermInstVal).S.makeSignless(); |
| 5966 | ;} |
| 5967 | break; |
| 5968 | |
| 5969 | case 263: |
| 5970 | #line 3191 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5971 | { // Unconditional Branch... |
| 5972 | BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal)); |
| 5973 | (yyval.TermInstVal).TI = new BranchInst(tmpBB); |
| 5974 | (yyval.TermInstVal).S.makeSignless(); |
| 5975 | ;} |
| 5976 | break; |
| 5977 | |
| 5978 | case 264: |
| 5979 | #line 3196 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5980 | { |
| 5981 | (yyvsp[(6) - (9)].ValIDVal).S.makeSignless(); |
| 5982 | (yyvsp[(9) - (9)].ValIDVal).S.makeSignless(); |
| 5983 | BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal)); |
| 5984 | BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal)); |
| 5985 | (yyvsp[(3) - (9)].ValIDVal).S.makeUnsigned(); |
| 5986 | Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal)); |
| 5987 | (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 5988 | (yyval.TermInstVal).S.makeSignless(); |
| 5989 | ;} |
| 5990 | break; |
| 5991 | |
| 5992 | case 265: |
| 5993 | #line 3206 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5994 | { |
| 5995 | (yyvsp[(3) - (9)].ValIDVal).S.copy((yyvsp[(2) - (9)].PrimType).S); |
| 5996 | Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal)); |
| 5997 | (yyvsp[(6) - (9)].ValIDVal).S.makeSignless(); |
| 5998 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal)); |
| 5999 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size()); |
| 6000 | (yyval.TermInstVal).TI = S; |
| 6001 | (yyval.TermInstVal).S.makeSignless(); |
| 6002 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(), |
| 6003 | E = (yyvsp[(8) - (9)].JumpTable)->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6004 | for (; I != E; ++I) { |
| 6005 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 6006 | S->addCase(CI, I->second); |
| 6007 | else |
| 6008 | error("Switch case is constant, but not a simple integer"); |
| 6009 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6010 | delete (yyvsp[(8) - (9)].JumpTable); |
| 6011 | ;} |
| 6012 | break; |
| 6013 | |
| 6014 | case 266: |
| 6015 | #line 3224 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6016 | { |
| 6017 | (yyvsp[(3) - (8)].ValIDVal).S.copy((yyvsp[(2) - (8)].PrimType).S); |
| 6018 | Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal)); |
| 6019 | (yyvsp[(6) - (8)].ValIDVal).S.makeSignless(); |
| 6020 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6021 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6022 | (yyval.TermInstVal).TI = S; |
| 6023 | (yyval.TermInstVal).S.makeSignless(); |
| 6024 | ;} |
| 6025 | break; |
| 6026 | |
| 6027 | case 267: |
| 6028 | #line 3234 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6029 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6030 | const PointerType *PFTy; |
| 6031 | const FunctionType *Ty; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6032 | Signedness FTySign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6033 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6034 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6035 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 6036 | // Pull out the types of all of the arguments... |
| 6037 | std::vector<const Type*> ParamTypes; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6038 | FTySign.makeComposite((yyvsp[(3) - (13)].TypeVal).S); |
| 6039 | if ((yyvsp[(6) - (13)].ValueList)) { |
| 6040 | for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6041 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6042 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6043 | FTySign.add(I->S); |
| 6044 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6045 | } |
| 6046 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 6047 | if (isVarArg) ParamTypes.pop_back(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6048 | Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).PAT->get(), ParamTypes, isVarArg); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6049 | PFTy = PointerType::get(Ty); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6050 | (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6051 | } else { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6052 | FTySign = (yyvsp[(3) - (13)].TypeVal).S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 6053 | // Get the signedness of the result type. $3 is the pointer to the |
| 6054 | // function type so we get the 0th element to extract the function type, |
| 6055 | // and then the 0th element again to get the result type. |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6056 | (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6057 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 6058 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6059 | (yyvsp[(4) - (13)].ValIDVal).S.makeComposite(FTySign); |
| 6060 | Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling... |
| 6061 | BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal)); |
| 6062 | BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6063 | |
| 6064 | // Create the call node... |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6065 | if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments? |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 6066 | std::vector<Value*> Args; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6067 | (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6068 | } else { // Has arguments? |
| 6069 | // Loop through FunctionType's arguments and ensure they are specified |
| 6070 | // correctly! |
| 6071 | // |
| 6072 | FunctionType::param_iterator I = Ty->param_begin(); |
| 6073 | FunctionType::param_iterator E = Ty->param_end(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6074 | std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6075 | |
| 6076 | std::vector<Value*> Args; |
| 6077 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 6078 | if ((*ArgI).V->getType() != *I) |
| 6079 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 6080 | (*I)->getDescription() + "'"); |
| 6081 | Args.push_back((*ArgI).V); |
| 6082 | } |
| 6083 | |
| 6084 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 6085 | error("Invalid number of parameters detected"); |
| 6086 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6087 | (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6088 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6089 | cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[(2) - (13)].UIntVal))); |
| 6090 | if ((yyvsp[(2) - (13)].UIntVal) == OldCallingConv::CSRet) { |
| 6091 | ParamAttrsVector Attrs; |
| 6092 | ParamAttrsWithIndex PAWI; |
| 6093 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 6094 | Attrs.push_back(PAWI); |
| 6095 | cast<InvokeInst>((yyval.TermInstVal).TI)->setParamAttrs(ParamAttrsList::get(Attrs)); |
| 6096 | } |
| 6097 | delete (yyvsp[(3) - (13)].TypeVal).PAT; |
| 6098 | delete (yyvsp[(6) - (13)].ValueList); |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6099 | lastCallingConv = OldCallingConv::C; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6100 | ;} |
| 6101 | break; |
| 6102 | |
| 6103 | case 268: |
| 6104 | #line 3306 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6105 | { |
| 6106 | (yyval.TermInstVal).TI = new UnwindInst(); |
| 6107 | (yyval.TermInstVal).S.makeSignless(); |
| 6108 | ;} |
| 6109 | break; |
| 6110 | |
| 6111 | case 269: |
| 6112 | #line 3310 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6113 | { |
| 6114 | (yyval.TermInstVal).TI = new UnreachableInst(); |
| 6115 | (yyval.TermInstVal).S.makeSignless(); |
| 6116 | ;} |
| 6117 | break; |
| 6118 | |
| 6119 | case 270: |
| 6120 | #line 3317 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6121 | { |
| 6122 | (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable); |
| 6123 | (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(2) - (6)].PrimType).S); |
| 6124 | Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6125 | |
| 6126 | if (V == 0) |
| 6127 | error("May only switch on a constant pool value"); |
| 6128 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6129 | (yyvsp[(6) - (6)].ValIDVal).S.makeSignless(); |
| 6130 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal)); |
| 6131 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 6132 | ;} |
| 6133 | break; |
| 6134 | |
| 6135 | case 271: |
| 6136 | #line 3329 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6137 | { |
| 6138 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 6139 | (yyvsp[(2) - (5)].ValIDVal).S.copy((yyvsp[(1) - (5)].PrimType).S); |
| 6140 | Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6141 | |
| 6142 | if (V == 0) |
| 6143 | error("May only switch on a constant pool value"); |
| 6144 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6145 | (yyvsp[(5) - (5)].ValIDVal).S.makeSignless(); |
| 6146 | BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal)); |
| 6147 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 6148 | ;} |
| 6149 | break; |
| 6150 | |
| 6151 | case 272: |
| 6152 | #line 3344 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6153 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6154 | bool omit = false; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6155 | if ((yyvsp[(1) - (2)].StrVal)) |
| 6156 | if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6157 | if (BCI->getSrcTy() == BCI->getDestTy() && |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6158 | BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6159 | // This is a useless bit cast causing a name redefinition. It is |
| 6160 | // a bit cast from a type to the same type of an operand with the |
| 6161 | // same name as the name we would give this instruction. Since this |
| 6162 | // instruction results in no code generation, it is safe to omit |
| 6163 | // the instruction. This situation can occur because of collapsed |
| 6164 | // type planes. For example: |
| 6165 | // %X = add int %Y, %Z |
| 6166 | // %X = cast int %Y to uint |
| 6167 | // After upgrade, this looks like: |
| 6168 | // %X = add i32 %Y, %Z |
| 6169 | // %X = bitcast i32 to i32 |
| 6170 | // The bitcast is clearly useless so we omit it. |
| 6171 | omit = true; |
| 6172 | if (omit) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6173 | (yyval.InstVal).I = 0; |
| 6174 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6175 | } else { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6176 | ValueInfo VI; VI.V = (yyvsp[(2) - (2)].InstVal).I; VI.S.copy((yyvsp[(2) - (2)].InstVal).S); |
| 6177 | setValueName(VI, (yyvsp[(1) - (2)].StrVal)); |
| 6178 | InsertValue((yyvsp[(2) - (2)].InstVal).I); |
| 6179 | (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6180 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6181 | ;} |
| 6182 | break; |
| 6183 | |
| 6184 | case 273: |
| 6185 | #line 3374 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6186 | { // Used for PHI nodes |
| 6187 | (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 6188 | (yyval.PHIList).S.copy((yyvsp[(1) - (6)].TypeVal).S); |
| 6189 | (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(1) - (6)].TypeVal).S); |
| 6190 | Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).PAT->get(), (yyvsp[(3) - (6)].ValIDVal)); |
| 6191 | (yyvsp[(5) - (6)].ValIDVal).S.makeSignless(); |
| 6192 | BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal)); |
| 6193 | (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 6194 | delete (yyvsp[(1) - (6)].TypeVal).PAT; |
| 6195 | ;} |
| 6196 | break; |
| 6197 | |
| 6198 | case 274: |
| 6199 | #line 3384 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6200 | { |
| 6201 | (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList); |
| 6202 | (yyvsp[(4) - (7)].ValIDVal).S.copy((yyvsp[(1) - (7)].PHIList).S); |
| 6203 | Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal)); |
| 6204 | (yyvsp[(6) - (7)].ValIDVal).S.makeSignless(); |
| 6205 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal)); |
| 6206 | (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 6207 | ;} |
| 6208 | break; |
| 6209 | |
| 6210 | case 275: |
| 6211 | #line 3394 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6212 | { // Used for call statements, and memory insts... |
| 6213 | (yyval.ValueList) = new std::vector<ValueInfo>(); |
| 6214 | (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal)); |
| 6215 | ;} |
| 6216 | break; |
| 6217 | |
| 6218 | case 276: |
| 6219 | #line 3398 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6220 | { |
| 6221 | (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList); |
| 6222 | (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal)); |
| 6223 | ;} |
| 6224 | break; |
| 6225 | |
| 6226 | case 278: |
| 6227 | #line 3406 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6228 | { (yyval.ValueList) = 0; ;} |
| 6229 | break; |
| 6230 | |
| 6231 | case 279: |
| 6232 | #line 3410 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6233 | { |
| 6234 | (yyval.BoolVal) = true; |
| 6235 | ;} |
| 6236 | break; |
| 6237 | |
| 6238 | case 280: |
| 6239 | #line 3413 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6240 | { |
| 6241 | (yyval.BoolVal) = false; |
| 6242 | ;} |
| 6243 | break; |
| 6244 | |
| 6245 | case 281: |
| 6246 | #line 3419 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6247 | { |
| 6248 | (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S); |
| 6249 | (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S); |
| 6250 | const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6251 | if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6252 | error("Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6253 | if (isa<VectorType>(Ty) && |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6254 | ((yyvsp[(1) - (5)].BinaryOpVal) == URemOp || (yyvsp[(1) - (5)].BinaryOpVal) == SRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == FRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == RemOp)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6255 | error("Remainder not supported on vector types"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6256 | // Upgrade the opcode from obsolete versions before we do anything with it. |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6257 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S); |
| 6258 | Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal)); |
| 6259 | Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal)); |
| 6260 | (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2); |
| 6261 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6262 | error("binary operator returned null"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6263 | (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S); |
| 6264 | delete (yyvsp[(2) - (5)].TypeVal).PAT; |
| 6265 | ;} |
| 6266 | break; |
| 6267 | |
| 6268 | case 282: |
| 6269 | #line 3438 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6270 | { |
| 6271 | (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S); |
| 6272 | (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S); |
| 6273 | const Type *Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6274 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6275 | if (!isa<VectorType>(Ty) || |
| 6276 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6277 | error("Logical operator requires integral operands"); |
| 6278 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6279 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S); |
| 6280 | Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal)); |
| 6281 | Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal)); |
| 6282 | (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); |
| 6283 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6284 | error("binary operator returned null"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6285 | (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S); |
| 6286 | delete (yyvsp[(2) - (5)].TypeVal).PAT; |
| 6287 | ;} |
| 6288 | break; |
| 6289 | |
| 6290 | case 283: |
| 6291 | #line 3456 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6292 | { |
| 6293 | (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S); |
| 6294 | (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S); |
| 6295 | const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6296 | if(isa<VectorType>(Ty)) |
| 6297 | error("VectorTypes currently not supported in setcc instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6298 | unsigned short pred; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6299 | Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S); |
| 6300 | Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal)); |
| 6301 | Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal)); |
| 6302 | (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); |
| 6303 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6304 | error("binary operator returned null"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6305 | (yyval.InstVal).S.makeUnsigned(); |
| 6306 | delete (yyvsp[(2) - (5)].TypeVal).PAT; |
| 6307 | ;} |
| 6308 | break; |
| 6309 | |
| 6310 | case 284: |
| 6311 | #line 3472 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6312 | { |
| 6313 | (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S); |
| 6314 | (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S); |
| 6315 | const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6316 | if (isa<VectorType>(Ty)) |
| 6317 | error("VectorTypes currently not supported in icmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6318 | else if (!Ty->isInteger() && !isa<PointerType>(Ty)) |
| 6319 | error("icmp requires integer or pointer typed operands"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6320 | Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal)); |
| 6321 | Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal)); |
| 6322 | (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2); |
| 6323 | (yyval.InstVal).S.makeUnsigned(); |
| 6324 | delete (yyvsp[(3) - (6)].TypeVal).PAT; |
| 6325 | ;} |
| 6326 | break; |
| 6327 | |
| 6328 | case 285: |
| 6329 | #line 3486 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6330 | { |
| 6331 | (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S); |
| 6332 | (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S); |
| 6333 | const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6334 | if (isa<VectorType>(Ty)) |
| 6335 | error("VectorTypes currently not supported in fcmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6336 | else if (!Ty->isFloatingPoint()) |
| 6337 | error("fcmp instruction requires floating point operands"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6338 | Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal)); |
| 6339 | Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal)); |
| 6340 | (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2); |
| 6341 | (yyval.InstVal).S.makeUnsigned(); |
| 6342 | delete (yyvsp[(3) - (6)].TypeVal).PAT; |
| 6343 | ;} |
| 6344 | break; |
| 6345 | |
| 6346 | case 286: |
| 6347 | #line 3500 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6348 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6349 | warning("Use of obsolete 'not' instruction: Replacing with 'xor"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6350 | const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6351 | Value *Ones = ConstantInt::getAllOnesValue(Ty); |
| 6352 | if (Ones == 0) |
| 6353 | error("Expected integral type for not instruction"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6354 | (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones); |
| 6355 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6356 | error("Could not create a xor instruction"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6357 | (yyval.InstVal).S.copy((yyvsp[(2) - (2)].ValueVal).S); |
| 6358 | ;} |
| 6359 | break; |
| 6360 | |
| 6361 | case 287: |
| 6362 | #line 3511 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6363 | { |
| 6364 | if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() || |
| 6365 | cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6366 | error("Shift amount must be int8"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6367 | const Type* Ty = (yyvsp[(2) - (4)].ValueVal).V->getType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6368 | if (!Ty->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6369 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6370 | Value* ShiftAmt = 0; |
| 6371 | if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth()) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6372 | if (Constant *C = dyn_cast<Constant>((yyvsp[(4) - (4)].ValueVal).V)) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6373 | ShiftAmt = ConstantExpr::getZExt(C, Ty); |
| 6374 | else |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6375 | ShiftAmt = new ZExtInst((yyvsp[(4) - (4)].ValueVal).V, Ty, makeNameUnique("shift"), CurBB); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6376 | else |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6377 | ShiftAmt = (yyvsp[(4) - (4)].ValueVal).V; |
| 6378 | (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[(1) - (4)].BinaryOpVal), Ty, (yyvsp[(2) - (4)].ValueVal).S), (yyvsp[(2) - (4)].ValueVal).V, ShiftAmt); |
| 6379 | (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S); |
| 6380 | ;} |
| 6381 | break; |
| 6382 | |
| 6383 | case 288: |
| 6384 | #line 3529 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6385 | { |
| 6386 | const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6387 | if (!DstTy->isFirstClassType()) |
| 6388 | error("cast instruction to a non-primitive type: '" + |
| 6389 | DstTy->getDescription() + "'"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6390 | (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[(1) - (4)].CastOpVal), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(2) - (4)].ValueVal).S, DstTy, (yyvsp[(4) - (4)].TypeVal).S, true)); |
| 6391 | (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S); |
| 6392 | delete (yyvsp[(4) - (4)].TypeVal).PAT; |
| 6393 | ;} |
| 6394 | break; |
| 6395 | |
| 6396 | case 289: |
| 6397 | #line 3538 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6398 | { |
| 6399 | if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() || |
| 6400 | cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6401 | error("select condition must be bool"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6402 | if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6403 | error("select value types should match"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6404 | (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V); |
| 6405 | (yyval.InstVal).S.copy((yyvsp[(4) - (6)].ValueVal).S); |
| 6406 | ;} |
| 6407 | break; |
| 6408 | |
| 6409 | case 290: |
| 6410 | #line 3547 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6411 | { |
| 6412 | const Type *Ty = (yyvsp[(4) - (4)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6413 | NewVarArgs = true; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6414 | (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty); |
| 6415 | (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S); |
| 6416 | delete (yyvsp[(4) - (4)].TypeVal).PAT; |
| 6417 | ;} |
| 6418 | break; |
| 6419 | |
| 6420 | case 291: |
| 6421 | #line 3554 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6422 | { |
| 6423 | const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType(); |
| 6424 | const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6425 | ObsoleteVarArgs = true; |
| 6426 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6427 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6428 | |
| 6429 | //b = vaarg a, t -> |
| 6430 | //foo = alloca 1 of t |
| 6431 | //bar = vacopy a |
| 6432 | //store bar -> foo |
| 6433 | //b = vaarg foo, t |
| 6434 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 6435 | CurBB->getInstList().push_back(foo); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6436 | CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6437 | CurBB->getInstList().push_back(bar); |
| 6438 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6439 | (yyval.InstVal).I = new VAArgInst(foo, DstTy); |
| 6440 | (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S); |
| 6441 | delete (yyvsp[(4) - (4)].TypeVal).PAT; |
| 6442 | ;} |
| 6443 | break; |
| 6444 | |
| 6445 | case 292: |
| 6446 | #line 3575 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6447 | { |
| 6448 | const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType(); |
| 6449 | const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6450 | ObsoleteVarArgs = true; |
| 6451 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6452 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6453 | |
| 6454 | //b = vanext a, t -> |
| 6455 | //foo = alloca 1 of t |
| 6456 | //bar = vacopy a |
| 6457 | //store bar -> foo |
| 6458 | //tmp = vaarg foo, t |
| 6459 | //b = load foo |
| 6460 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 6461 | CurBB->getInstList().push_back(foo); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6462 | CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6463 | CurBB->getInstList().push_back(bar); |
| 6464 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 6465 | Instruction* tmp = new VAArgInst(foo, DstTy); |
| 6466 | CurBB->getInstList().push_back(tmp); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6467 | (yyval.InstVal).I = new LoadInst(foo); |
| 6468 | (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S); |
| 6469 | delete (yyvsp[(4) - (4)].TypeVal).PAT; |
| 6470 | ;} |
| 6471 | break; |
| 6472 | |
| 6473 | case 293: |
| 6474 | #line 3599 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6475 | { |
| 6476 | if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6477 | error("Invalid extractelement operands"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6478 | (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V); |
| 6479 | (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S.get(0)); |
| 6480 | ;} |
| 6481 | break; |
| 6482 | |
| 6483 | case 294: |
| 6484 | #line 3605 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6485 | { |
| 6486 | if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6487 | error("Invalid insertelement operands"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6488 | (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V); |
| 6489 | (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S); |
| 6490 | ;} |
| 6491 | break; |
| 6492 | |
| 6493 | case 295: |
| 6494 | #line 3611 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6495 | { |
| 6496 | if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6497 | error("Invalid shufflevector operands"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6498 | (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V); |
| 6499 | (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S); |
| 6500 | ;} |
| 6501 | break; |
| 6502 | |
| 6503 | case 296: |
| 6504 | #line 3617 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6505 | { |
| 6506 | const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6507 | if (!Ty->isFirstClassType()) |
| 6508 | error("PHI node operands must be of first class type"); |
| 6509 | PHINode *PHI = new PHINode(Ty); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6510 | PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size()); |
| 6511 | while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) { |
| 6512 | if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6513 | error("All elements of a PHI node must be of the same type"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6514 | PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second); |
| 6515 | (yyvsp[(2) - (2)].PHIList).P->pop_front(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6516 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6517 | (yyval.InstVal).I = PHI; |
| 6518 | (yyval.InstVal).S.copy((yyvsp[(2) - (2)].PHIList).S); |
| 6519 | delete (yyvsp[(2) - (2)].PHIList).P; // Free the list... |
| 6520 | ;} |
| 6521 | break; |
| 6522 | |
| 6523 | case 297: |
| 6524 | #line 3633 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6525 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6526 | // Handle the short call syntax |
| 6527 | const PointerType *PFTy; |
| 6528 | const FunctionType *FTy; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6529 | Signedness FTySign; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6530 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6531 | !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 6532 | // Pull out the types of all of the arguments... |
| 6533 | std::vector<const Type*> ParamTypes; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6534 | FTySign.makeComposite((yyvsp[(3) - (7)].TypeVal).S); |
| 6535 | if ((yyvsp[(6) - (7)].ValueList)) { |
| 6536 | for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6537 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6538 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6539 | FTySign.add(I->S); |
| 6540 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6541 | } |
| 6542 | |
| 6543 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 6544 | if (isVarArg) ParamTypes.pop_back(); |
| 6545 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6546 | const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6547 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 6548 | error("Functions cannot return aggregate types"); |
| 6549 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6550 | FTy = FunctionType::get(RetTy, ParamTypes, isVarArg); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6551 | PFTy = PointerType::get(FTy); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6552 | (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6553 | } else { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6554 | FTySign = (yyvsp[(3) - (7)].TypeVal).S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 6555 | // Get the signedness of the result type. $3 is the pointer to the |
| 6556 | // function type so we get the 0th element to extract the function type, |
| 6557 | // and then the 0th element again to get the result type. |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6558 | (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6559 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6560 | (yyvsp[(4) - (7)].ValIDVal).S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6561 | |
| 6562 | // First upgrade any intrinsic calls. |
| 6563 | std::vector<Value*> Args; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6564 | if ((yyvsp[(6) - (7)].ValueList)) |
| 6565 | for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i) |
| 6566 | Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V); |
| 6567 | Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[(4) - (7)].ValIDVal), Args); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6568 | |
| 6569 | // If we got an upgraded intrinsic |
| 6570 | if (Inst) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6571 | (yyval.InstVal).I = Inst; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6572 | } else { |
| 6573 | // Get the function we're calling |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6574 | Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6575 | |
| 6576 | // Check the argument values match |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6577 | if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6578 | // Make sure no arguments is a good thing! |
| 6579 | if (FTy->getNumParams() != 0) |
| 6580 | error("No arguments passed to a function that expects arguments"); |
| 6581 | } else { // Has arguments? |
| 6582 | // Loop through FunctionType's arguments and ensure they are specified |
| 6583 | // correctly! |
| 6584 | // |
| 6585 | FunctionType::param_iterator I = FTy->param_begin(); |
| 6586 | FunctionType::param_iterator E = FTy->param_end(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6587 | std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6588 | |
| 6589 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 6590 | if ((*ArgI).V->getType() != *I) |
| 6591 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 6592 | (*I)->getDescription() + "'"); |
| 6593 | |
| 6594 | if (I != E || (ArgI != ArgE && !FTy->isVarArg())) |
| 6595 | error("Invalid number of parameters detected"); |
| 6596 | } |
| 6597 | |
| 6598 | // Create the call instruction |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 6599 | CallInst *CI = new CallInst(V, Args.begin(), Args.end()); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6600 | CI->setTailCall((yyvsp[(1) - (7)].BoolVal)); |
| 6601 | CI->setCallingConv(upgradeCallingConv((yyvsp[(2) - (7)].UIntVal))); |
| 6602 | |
| 6603 | (yyval.InstVal).I = CI; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6604 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6605 | // Deal with CSRetCC |
| 6606 | if ((yyvsp[(2) - (7)].UIntVal) == OldCallingConv::CSRet) { |
| 6607 | ParamAttrsVector Attrs; |
| 6608 | ParamAttrsWithIndex PAWI; |
| 6609 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 6610 | Attrs.push_back(PAWI); |
| 6611 | cast<CallInst>((yyval.InstVal).I)->setParamAttrs(ParamAttrsList::get(Attrs)); |
| 6612 | } |
| 6613 | delete (yyvsp[(3) - (7)].TypeVal).PAT; |
| 6614 | delete (yyvsp[(6) - (7)].ValueList); |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6615 | lastCallingConv = OldCallingConv::C; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6616 | ;} |
| 6617 | break; |
| 6618 | |
| 6619 | case 298: |
| 6620 | #line 3725 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6621 | { |
| 6622 | (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal); |
| 6623 | ;} |
| 6624 | break; |
| 6625 | |
| 6626 | case 299: |
| 6627 | #line 3733 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6628 | { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;} |
| 6629 | break; |
| 6630 | |
| 6631 | case 300: |
| 6632 | #line 3734 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6633 | { (yyval.ValueList) = new std::vector<ValueInfo>(); ;} |
| 6634 | break; |
| 6635 | |
| 6636 | case 301: |
| 6637 | #line 3738 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6638 | { (yyval.BoolVal) = true; ;} |
| 6639 | break; |
| 6640 | |
| 6641 | case 302: |
| 6642 | #line 3739 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6643 | { (yyval.BoolVal) = false; ;} |
| 6644 | break; |
| 6645 | |
| 6646 | case 303: |
| 6647 | #line 3743 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6648 | { |
| 6649 | const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get(); |
| 6650 | (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S); |
| 6651 | (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal)); |
| 6652 | delete (yyvsp[(2) - (3)].TypeVal).PAT; |
| 6653 | ;} |
| 6654 | break; |
| 6655 | |
| 6656 | case 304: |
| 6657 | #line 3749 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6658 | { |
| 6659 | const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get(); |
| 6660 | (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned(); |
| 6661 | (yyval.InstVal).S.makeComposite((yyvsp[(2) - (6)].TypeVal).S); |
| 6662 | (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal)); |
| 6663 | delete (yyvsp[(2) - (6)].TypeVal).PAT; |
| 6664 | ;} |
| 6665 | break; |
| 6666 | |
| 6667 | case 305: |
| 6668 | #line 3756 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6669 | { |
| 6670 | const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get(); |
| 6671 | (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S); |
| 6672 | (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal)); |
| 6673 | delete (yyvsp[(2) - (3)].TypeVal).PAT; |
| 6674 | ;} |
| 6675 | break; |
| 6676 | |
| 6677 | case 306: |
| 6678 | #line 3762 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6679 | { |
| 6680 | const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get(); |
| 6681 | (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned(); |
| 6682 | (yyval.InstVal).S.makeComposite((yyvsp[(4) - (6)].PrimType).S); |
| 6683 | (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal)); |
| 6684 | delete (yyvsp[(2) - (6)].TypeVal).PAT; |
| 6685 | ;} |
| 6686 | break; |
| 6687 | |
| 6688 | case 307: |
| 6689 | #line 3769 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6690 | { |
| 6691 | const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6692 | if (!isa<PointerType>(PTy)) |
| 6693 | error("Trying to free nonpointer type '" + PTy->getDescription() + "'"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6694 | (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V); |
| 6695 | (yyval.InstVal).S.makeSignless(); |
| 6696 | ;} |
| 6697 | break; |
| 6698 | |
| 6699 | case 308: |
| 6700 | #line 3776 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6701 | { |
| 6702 | const Type* Ty = (yyvsp[(3) - (4)].TypeVal).PAT->get(); |
| 6703 | (yyvsp[(4) - (4)].ValIDVal).S.copy((yyvsp[(3) - (4)].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6704 | if (!isa<PointerType>(Ty)) |
| 6705 | error("Can't load from nonpointer type: " + Ty->getDescription()); |
| 6706 | if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType()) |
| 6707 | error("Can't load from pointer of non-first-class type: " + |
| 6708 | Ty->getDescription()); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6709 | Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal)); |
| 6710 | (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal)); |
| 6711 | (yyval.InstVal).S.copy((yyvsp[(3) - (4)].TypeVal).S.get(0)); |
| 6712 | delete (yyvsp[(3) - (4)].TypeVal).PAT; |
| 6713 | ;} |
| 6714 | break; |
| 6715 | |
| 6716 | case 309: |
| 6717 | #line 3789 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6718 | { |
| 6719 | (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(5) - (6)].TypeVal).S); |
| 6720 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).PAT->get()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6721 | if (!PTy) |
| 6722 | error("Can't store to a nonpointer type: " + |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6723 | (yyvsp[(5) - (6)].TypeVal).PAT->get()->getDescription()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6724 | const Type *ElTy = PTy->getElementType(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6725 | Value *StoreVal = (yyvsp[(3) - (6)].ValueVal).V; |
| 6726 | Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal)); |
| 6727 | if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType()) { |
| 6728 | PTy = PointerType::get(StoreVal->getType()); |
| 6729 | if (Constant *C = dyn_cast<Constant>(tmpVal)) |
| 6730 | tmpVal = ConstantExpr::getBitCast(C, PTy); |
| 6731 | else |
| 6732 | tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6733 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6734 | (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[(1) - (6)].BoolVal)); |
| 6735 | (yyval.InstVal).S.makeSignless(); |
| 6736 | delete (yyvsp[(5) - (6)].TypeVal).PAT; |
| 6737 | ;} |
| 6738 | break; |
| 6739 | |
| 6740 | case 310: |
| 6741 | #line 3809 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 6742 | { |
| 6743 | (yyvsp[(3) - (4)].ValIDVal).S.copy((yyvsp[(2) - (4)].TypeVal).S); |
| 6744 | const Type* Ty = (yyvsp[(2) - (4)].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6745 | if (!isa<PointerType>(Ty)) |
| 6746 | error("getelementptr insn requires pointer operand"); |
| 6747 | |
| 6748 | std::vector<Value*> VIndices; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6749 | upgradeGEPInstIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6750 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6751 | Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal)); |
| 6752 | (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices.begin(), VIndices.end()); |
| 6753 | ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[(2) - (4)].TypeVal).S); |
| 6754 | (yyval.InstVal).S.copy(getElementSign(VI, VIndices)); |
| 6755 | delete (yyvsp[(2) - (4)].TypeVal).PAT; |
| 6756 | delete (yyvsp[(4) - (4)].ValueList); |
| 6757 | ;} |
| 6758 | break; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 6759 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6760 | |
| 6761 | /* Line 1267 of yacc.c. */ |
| 6762 | #line 6763 "UpgradeParser.tab.c" |
| 6763 | default: break; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 6764 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6765 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); |
| 6766 | |
| 6767 | YYPOPSTACK (yylen); |
| 6768 | yylen = 0; |
| 6769 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6770 | |
| 6771 | *++yyvsp = yyval; |
| 6772 | |
| 6773 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6774 | /* Now `shift' the result of the reduction. Determine what state |
| 6775 | that goes to, based on the state we popped back to and the rule |
| 6776 | number reduced by. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6777 | |
| 6778 | yyn = yyr1[yyn]; |
| 6779 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6780 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 6781 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6782 | yystate = yytable[yystate]; |
| 6783 | else |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6784 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6785 | |
| 6786 | goto yynewstate; |
| 6787 | |
| 6788 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6789 | /*------------------------------------. |
| 6790 | | yyerrlab -- here on detecting error | |
| 6791 | `------------------------------------*/ |
| 6792 | yyerrlab: |
| 6793 | /* If not already recovering from an error, report this error. */ |
| 6794 | if (!yyerrstatus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6795 | { |
| 6796 | ++yynerrs; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6797 | #if ! YYERROR_VERBOSE |
| 6798 | yyerror (YY_("syntax error")); |
| 6799 | #else |
| 6800 | { |
| 6801 | YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); |
| 6802 | if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) |
| 6803 | { |
| 6804 | YYSIZE_T yyalloc = 2 * yysize; |
| 6805 | if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) |
| 6806 | yyalloc = YYSTACK_ALLOC_MAXIMUM; |
| 6807 | if (yymsg != yymsgbuf) |
| 6808 | YYSTACK_FREE (yymsg); |
| 6809 | yymsg = (char *) YYSTACK_ALLOC (yyalloc); |
| 6810 | if (yymsg) |
| 6811 | yymsg_alloc = yyalloc; |
| 6812 | else |
| 6813 | { |
| 6814 | yymsg = yymsgbuf; |
| 6815 | yymsg_alloc = sizeof yymsgbuf; |
| 6816 | } |
| 6817 | } |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 6818 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6819 | if (0 < yysize && yysize <= yymsg_alloc) |
| 6820 | { |
| 6821 | (void) yysyntax_error (yymsg, yystate, yychar); |
| 6822 | yyerror (yymsg); |
| 6823 | } |
| 6824 | else |
| 6825 | { |
| 6826 | yyerror (YY_("syntax error")); |
| 6827 | if (yysize != 0) |
| 6828 | goto yyexhaustedlab; |
| 6829 | } |
| 6830 | } |
| 6831 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6832 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6833 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6834 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6835 | |
| 6836 | if (yyerrstatus == 3) |
| 6837 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6838 | /* If just tried and failed to reuse look-ahead token after an |
| 6839 | error, discard it. */ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6840 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6841 | if (yychar <= YYEOF) |
| 6842 | { |
| 6843 | /* Return failure if at end of input. */ |
| 6844 | if (yychar == YYEOF) |
| 6845 | YYABORT; |
| 6846 | } |
| 6847 | else |
| 6848 | { |
| 6849 | yydestruct ("Error: discarding", |
| 6850 | yytoken, &yylval); |
| 6851 | yychar = YYEMPTY; |
| 6852 | } |
| 6853 | } |
| 6854 | |
| 6855 | /* Else will try to reuse look-ahead token after shifting the error |
| 6856 | token. */ |
| 6857 | goto yyerrlab1; |
| 6858 | |
| 6859 | |
| 6860 | /*---------------------------------------------------. |
| 6861 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 6862 | `---------------------------------------------------*/ |
| 6863 | yyerrorlab: |
| 6864 | |
| 6865 | /* Pacify compilers like GCC when the user code never invokes |
| 6866 | YYERROR and the label yyerrorlab therefore never appears in user |
| 6867 | code. */ |
| 6868 | if (/*CONSTCOND*/ 0) |
| 6869 | goto yyerrorlab; |
| 6870 | |
| 6871 | /* Do not reclaim the symbols of the rule which action triggered |
| 6872 | this YYERROR. */ |
| 6873 | YYPOPSTACK (yylen); |
| 6874 | yylen = 0; |
| 6875 | YY_STACK_PRINT (yyss, yyssp); |
| 6876 | yystate = *yyssp; |
| 6877 | goto yyerrlab1; |
| 6878 | |
| 6879 | |
| 6880 | /*-------------------------------------------------------------. |
| 6881 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 6882 | `-------------------------------------------------------------*/ |
| 6883 | yyerrlab1: |
| 6884 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 6885 | |
| 6886 | for (;;) |
| 6887 | { |
| 6888 | yyn = yypact[yystate]; |
| 6889 | if (yyn != YYPACT_NINF) |
| 6890 | { |
| 6891 | yyn += YYTERROR; |
| 6892 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 6893 | { |
| 6894 | yyn = yytable[yyn]; |
| 6895 | if (0 < yyn) |
| 6896 | break; |
| 6897 | } |
| 6898 | } |
| 6899 | |
| 6900 | /* Pop the current state because it cannot handle the error token. */ |
| 6901 | if (yyssp == yyss) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6902 | YYABORT; |
| 6903 | |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 6904 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6905 | yydestruct ("Error: popping", |
| 6906 | yystos[yystate], yyvsp); |
| 6907 | YYPOPSTACK (1); |
| 6908 | yystate = *yyssp; |
| 6909 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6910 | } |
| 6911 | |
| 6912 | if (yyn == YYFINAL) |
| 6913 | YYACCEPT; |
| 6914 | |
| 6915 | *++yyvsp = yylval; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6916 | |
| 6917 | |
| 6918 | /* Shift the error token. */ |
| 6919 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6920 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6921 | yystate = yyn; |
| 6922 | goto yynewstate; |
| 6923 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6924 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6925 | /*-------------------------------------. |
| 6926 | | yyacceptlab -- YYACCEPT comes here. | |
| 6927 | `-------------------------------------*/ |
| 6928 | yyacceptlab: |
| 6929 | yyresult = 0; |
| 6930 | goto yyreturn; |
| 6931 | |
| 6932 | /*-----------------------------------. |
| 6933 | | yyabortlab -- YYABORT comes here. | |
| 6934 | `-----------------------------------*/ |
| 6935 | yyabortlab: |
| 6936 | yyresult = 1; |
| 6937 | goto yyreturn; |
| 6938 | |
| 6939 | #ifndef yyoverflow |
| 6940 | /*-------------------------------------------------. |
| 6941 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 6942 | `-------------------------------------------------*/ |
| 6943 | yyexhaustedlab: |
| 6944 | yyerror (YY_("memory exhausted")); |
| 6945 | yyresult = 2; |
| 6946 | /* Fall through. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6947 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6948 | |
| 6949 | yyreturn: |
| 6950 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 6951 | yydestruct ("Cleanup: discarding lookahead", |
| 6952 | yytoken, &yylval); |
| 6953 | /* Do not reclaim the symbols of the rule which action triggered |
| 6954 | this YYABORT or YYACCEPT. */ |
| 6955 | YYPOPSTACK (yylen); |
| 6956 | YY_STACK_PRINT (yyss, yyssp); |
| 6957 | while (yyssp != yyss) |
| 6958 | { |
| 6959 | yydestruct ("Cleanup: popping", |
| 6960 | yystos[*yyssp], yyvsp); |
| 6961 | YYPOPSTACK (1); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 6962 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6963 | #ifndef yyoverflow |
| 6964 | if (yyss != yyssa) |
| 6965 | YYSTACK_FREE (yyss); |
| 6966 | #endif |
| 6967 | #if YYERROR_VERBOSE |
| 6968 | if (yymsg != yymsgbuf) |
| 6969 | YYSTACK_FREE (yymsg); |
| 6970 | #endif |
| 6971 | /* Make sure YYID is used. */ |
| 6972 | return YYID (yyresult); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6973 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6974 | |
| 6975 | |
| 6976 | #line 3827 "/home/duncan/LLVM/llvm.top/llvm/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6977 | |
| 6978 | |
| 6979 | int yyerror(const char *ErrorMsg) { |
| 6980 | std::string where |
| 6981 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6982 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6983 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 6984 | if (yychar != YYEMPTY && yychar != 0) |
| 6985 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6986 | "'."; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 6987 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6988 | std::cout << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6989 | exit(1); |
| 6990 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6991 | |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 6992 | void warning(const std::string& ErrorMsg) { |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6993 | std::string where |
| 6994 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6995 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6996 | std::string errMsg = where + "warning: " + std::string(ErrorMsg); |
| 6997 | if (yychar != YYEMPTY && yychar != 0) |
| 6998 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6999 | "'."; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 7000 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
| 7001 | } |
| 7002 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 7003 | void error(const std::string& ErrorMsg, int LineNo) { |
| 7004 | if (LineNo == -1) LineNo = Upgradelineno; |
| 7005 | Upgradelineno = LineNo; |
| 7006 | yyerror(ErrorMsg.c_str()); |
| 7007 | } |
| 7008 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 7009 | |