Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 1 | /* A Bison parser, made by GNU Bison 2.1. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3 | /* Skeleton parser for Yacc-like parsing with Bison, |
| 4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2, or (at your option) |
| 9 | any later version. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 10 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | Boston, MA 02110-1301, USA. */ |
| 20 | |
| 21 | /* As a special exception, when this file is copied by Bison into a |
| 22 | Bison output file, you may use that output file without restriction. |
| 23 | This special exception was added by the Free Software Foundation |
| 24 | in version 1.24 of Bison. */ |
| 25 | |
| 26 | /* Written by Richard Stallman by simplifying the original so called |
| 27 | ``semantic'' parser. */ |
| 28 | |
| 29 | /* All symbols defined below should begin with yy or YY, to avoid |
| 30 | infringing on user name space. This should be done even for local |
| 31 | variables, as they might otherwise be expanded by user macros. |
| 32 | There are some unavoidable exceptions within include files to |
| 33 | define necessary library symbols; they are noted "INFRINGES ON |
| 34 | USER NAME SPACE" below. */ |
| 35 | |
| 36 | /* Identify Bison output. */ |
| 37 | #define YYBISON 1 |
| 38 | |
| 39 | /* Bison version. */ |
| 40 | #define YYBISON_VERSION "2.1" |
| 41 | |
| 42 | /* Skeleton name. */ |
| 43 | #define YYSKELETON_NAME "yacc.c" |
| 44 | |
| 45 | /* Pure parsers. */ |
| 46 | #define YYPURE 0 |
| 47 | |
| 48 | /* Using locations. */ |
| 49 | #define YYLSP_NEEDED 0 |
| 50 | |
| 51 | /* Substitute the variable and function names. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 52 | #define yyparse Upgradeparse |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 53 | #define yylex Upgradelex |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 54 | #define yyerror Upgradeerror |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 55 | #define yylval Upgradelval |
| 56 | #define yychar Upgradechar |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 57 | #define yydebug Upgradedebug |
| 58 | #define yynerrs Upgradenerrs |
| 59 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 60 | |
| 61 | /* Tokens. */ |
| 62 | #ifndef YYTOKENTYPE |
| 63 | # define YYTOKENTYPE |
| 64 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 65 | know about them. */ |
| 66 | enum yytokentype { |
| 67 | ESINT64VAL = 258, |
| 68 | EUINT64VAL = 259, |
| 69 | SINTVAL = 260, |
| 70 | UINTVAL = 261, |
| 71 | FPVAL = 262, |
| 72 | VOID = 263, |
| 73 | BOOL = 264, |
| 74 | SBYTE = 265, |
| 75 | UBYTE = 266, |
| 76 | SHORT = 267, |
| 77 | USHORT = 268, |
| 78 | INT = 269, |
| 79 | UINT = 270, |
| 80 | LONG = 271, |
| 81 | ULONG = 272, |
| 82 | FLOAT = 273, |
| 83 | DOUBLE = 274, |
| 84 | TYPE = 275, |
| 85 | LABEL = 276, |
| 86 | VAR_ID = 277, |
| 87 | LABELSTR = 278, |
| 88 | STRINGCONSTANT = 279, |
| 89 | IMPLEMENTATION = 280, |
| 90 | ZEROINITIALIZER = 281, |
| 91 | TRUETOK = 282, |
| 92 | FALSETOK = 283, |
| 93 | BEGINTOK = 284, |
| 94 | ENDTOK = 285, |
| 95 | DECLARE = 286, |
| 96 | GLOBAL = 287, |
| 97 | CONSTANT = 288, |
| 98 | SECTION = 289, |
| 99 | VOLATILE = 290, |
| 100 | TO = 291, |
| 101 | DOTDOTDOT = 292, |
| 102 | NULL_TOK = 293, |
| 103 | UNDEF = 294, |
| 104 | CONST = 295, |
| 105 | INTERNAL = 296, |
| 106 | LINKONCE = 297, |
| 107 | WEAK = 298, |
| 108 | APPENDING = 299, |
| 109 | DLLIMPORT = 300, |
| 110 | DLLEXPORT = 301, |
| 111 | EXTERN_WEAK = 302, |
| 112 | OPAQUE = 303, |
| 113 | NOT = 304, |
| 114 | EXTERNAL = 305, |
| 115 | TARGET = 306, |
| 116 | TRIPLE = 307, |
| 117 | ENDIAN = 308, |
| 118 | POINTERSIZE = 309, |
| 119 | LITTLE = 310, |
| 120 | BIG = 311, |
| 121 | ALIGN = 312, |
| 122 | DEPLIBS = 313, |
| 123 | CALL = 314, |
| 124 | TAIL = 315, |
| 125 | ASM_TOK = 316, |
| 126 | MODULE = 317, |
| 127 | SIDEEFFECT = 318, |
| 128 | CC_TOK = 319, |
| 129 | CCC_TOK = 320, |
| 130 | CSRETCC_TOK = 321, |
| 131 | FASTCC_TOK = 322, |
| 132 | COLDCC_TOK = 323, |
| 133 | X86_STDCALLCC_TOK = 324, |
| 134 | X86_FASTCALLCC_TOK = 325, |
| 135 | DATALAYOUT = 326, |
| 136 | RET = 327, |
| 137 | BR = 328, |
| 138 | SWITCH = 329, |
| 139 | INVOKE = 330, |
| 140 | UNREACHABLE = 331, |
| 141 | UNWIND = 332, |
| 142 | EXCEPT = 333, |
| 143 | ADD = 334, |
| 144 | SUB = 335, |
| 145 | MUL = 336, |
| 146 | DIV = 337, |
| 147 | UDIV = 338, |
| 148 | SDIV = 339, |
| 149 | FDIV = 340, |
| 150 | REM = 341, |
| 151 | UREM = 342, |
| 152 | SREM = 343, |
| 153 | FREM = 344, |
| 154 | AND = 345, |
| 155 | OR = 346, |
| 156 | XOR = 347, |
| 157 | SHL = 348, |
| 158 | SHR = 349, |
| 159 | ASHR = 350, |
| 160 | LSHR = 351, |
| 161 | SETLE = 352, |
| 162 | SETGE = 353, |
| 163 | SETLT = 354, |
| 164 | SETGT = 355, |
| 165 | SETEQ = 356, |
| 166 | SETNE = 357, |
| 167 | ICMP = 358, |
| 168 | FCMP = 359, |
| 169 | MALLOC = 360, |
| 170 | ALLOCA = 361, |
| 171 | FREE = 362, |
| 172 | LOAD = 363, |
| 173 | STORE = 364, |
| 174 | GETELEMENTPTR = 365, |
| 175 | PHI_TOK = 366, |
| 176 | SELECT = 367, |
| 177 | VAARG = 368, |
| 178 | EXTRACTELEMENT = 369, |
| 179 | INSERTELEMENT = 370, |
| 180 | SHUFFLEVECTOR = 371, |
| 181 | VAARG_old = 372, |
| 182 | VANEXT_old = 373, |
| 183 | EQ = 374, |
| 184 | NE = 375, |
| 185 | SLT = 376, |
| 186 | SGT = 377, |
| 187 | SLE = 378, |
| 188 | SGE = 379, |
| 189 | ULT = 380, |
| 190 | UGT = 381, |
| 191 | ULE = 382, |
| 192 | UGE = 383, |
| 193 | OEQ = 384, |
| 194 | ONE = 385, |
| 195 | OLT = 386, |
| 196 | OGT = 387, |
| 197 | OLE = 388, |
| 198 | OGE = 389, |
| 199 | ORD = 390, |
| 200 | UNO = 391, |
| 201 | UEQ = 392, |
| 202 | UNE = 393, |
| 203 | CAST = 394, |
| 204 | TRUNC = 395, |
| 205 | ZEXT = 396, |
| 206 | SEXT = 397, |
| 207 | FPTRUNC = 398, |
| 208 | FPEXT = 399, |
| 209 | FPTOUI = 400, |
| 210 | FPTOSI = 401, |
| 211 | UITOFP = 402, |
| 212 | SITOFP = 403, |
| 213 | PTRTOINT = 404, |
| 214 | INTTOPTR = 405, |
| 215 | BITCAST = 406 |
| 216 | }; |
| 217 | #endif |
| 218 | /* Tokens. */ |
| 219 | #define ESINT64VAL 258 |
| 220 | #define EUINT64VAL 259 |
| 221 | #define SINTVAL 260 |
| 222 | #define UINTVAL 261 |
| 223 | #define FPVAL 262 |
| 224 | #define VOID 263 |
| 225 | #define BOOL 264 |
| 226 | #define SBYTE 265 |
| 227 | #define UBYTE 266 |
| 228 | #define SHORT 267 |
| 229 | #define USHORT 268 |
| 230 | #define INT 269 |
| 231 | #define UINT 270 |
| 232 | #define LONG 271 |
| 233 | #define ULONG 272 |
| 234 | #define FLOAT 273 |
| 235 | #define DOUBLE 274 |
| 236 | #define TYPE 275 |
| 237 | #define LABEL 276 |
| 238 | #define VAR_ID 277 |
| 239 | #define LABELSTR 278 |
| 240 | #define STRINGCONSTANT 279 |
| 241 | #define IMPLEMENTATION 280 |
| 242 | #define ZEROINITIALIZER 281 |
| 243 | #define TRUETOK 282 |
| 244 | #define FALSETOK 283 |
| 245 | #define BEGINTOK 284 |
| 246 | #define ENDTOK 285 |
| 247 | #define DECLARE 286 |
| 248 | #define GLOBAL 287 |
| 249 | #define CONSTANT 288 |
| 250 | #define SECTION 289 |
| 251 | #define VOLATILE 290 |
| 252 | #define TO 291 |
| 253 | #define DOTDOTDOT 292 |
| 254 | #define NULL_TOK 293 |
| 255 | #define UNDEF 294 |
| 256 | #define CONST 295 |
| 257 | #define INTERNAL 296 |
| 258 | #define LINKONCE 297 |
| 259 | #define WEAK 298 |
| 260 | #define APPENDING 299 |
| 261 | #define DLLIMPORT 300 |
| 262 | #define DLLEXPORT 301 |
| 263 | #define EXTERN_WEAK 302 |
| 264 | #define OPAQUE 303 |
| 265 | #define NOT 304 |
| 266 | #define EXTERNAL 305 |
| 267 | #define TARGET 306 |
| 268 | #define TRIPLE 307 |
| 269 | #define ENDIAN 308 |
| 270 | #define POINTERSIZE 309 |
| 271 | #define LITTLE 310 |
| 272 | #define BIG 311 |
| 273 | #define ALIGN 312 |
| 274 | #define DEPLIBS 313 |
| 275 | #define CALL 314 |
| 276 | #define TAIL 315 |
| 277 | #define ASM_TOK 316 |
| 278 | #define MODULE 317 |
| 279 | #define SIDEEFFECT 318 |
| 280 | #define CC_TOK 319 |
| 281 | #define CCC_TOK 320 |
| 282 | #define CSRETCC_TOK 321 |
| 283 | #define FASTCC_TOK 322 |
| 284 | #define COLDCC_TOK 323 |
| 285 | #define X86_STDCALLCC_TOK 324 |
| 286 | #define X86_FASTCALLCC_TOK 325 |
| 287 | #define DATALAYOUT 326 |
| 288 | #define RET 327 |
| 289 | #define BR 328 |
| 290 | #define SWITCH 329 |
| 291 | #define INVOKE 330 |
| 292 | #define UNREACHABLE 331 |
| 293 | #define UNWIND 332 |
| 294 | #define EXCEPT 333 |
| 295 | #define ADD 334 |
| 296 | #define SUB 335 |
| 297 | #define MUL 336 |
| 298 | #define DIV 337 |
| 299 | #define UDIV 338 |
| 300 | #define SDIV 339 |
| 301 | #define FDIV 340 |
| 302 | #define REM 341 |
| 303 | #define UREM 342 |
| 304 | #define SREM 343 |
| 305 | #define FREM 344 |
| 306 | #define AND 345 |
| 307 | #define OR 346 |
| 308 | #define XOR 347 |
| 309 | #define SHL 348 |
| 310 | #define SHR 349 |
| 311 | #define ASHR 350 |
| 312 | #define LSHR 351 |
| 313 | #define SETLE 352 |
| 314 | #define SETGE 353 |
| 315 | #define SETLT 354 |
| 316 | #define SETGT 355 |
| 317 | #define SETEQ 356 |
| 318 | #define SETNE 357 |
| 319 | #define ICMP 358 |
| 320 | #define FCMP 359 |
| 321 | #define MALLOC 360 |
| 322 | #define ALLOCA 361 |
| 323 | #define FREE 362 |
| 324 | #define LOAD 363 |
| 325 | #define STORE 364 |
| 326 | #define GETELEMENTPTR 365 |
| 327 | #define PHI_TOK 366 |
| 328 | #define SELECT 367 |
| 329 | #define VAARG 368 |
| 330 | #define EXTRACTELEMENT 369 |
| 331 | #define INSERTELEMENT 370 |
| 332 | #define SHUFFLEVECTOR 371 |
| 333 | #define VAARG_old 372 |
| 334 | #define VANEXT_old 373 |
| 335 | #define EQ 374 |
| 336 | #define NE 375 |
| 337 | #define SLT 376 |
| 338 | #define SGT 377 |
| 339 | #define SLE 378 |
| 340 | #define SGE 379 |
| 341 | #define ULT 380 |
| 342 | #define UGT 381 |
| 343 | #define ULE 382 |
| 344 | #define UGE 383 |
| 345 | #define OEQ 384 |
| 346 | #define ONE 385 |
| 347 | #define OLT 386 |
| 348 | #define OGT 387 |
| 349 | #define OLE 388 |
| 350 | #define OGE 389 |
| 351 | #define ORD 390 |
| 352 | #define UNO 391 |
| 353 | #define UEQ 392 |
| 354 | #define UNE 393 |
| 355 | #define CAST 394 |
| 356 | #define TRUNC 395 |
| 357 | #define ZEXT 396 |
| 358 | #define SEXT 397 |
| 359 | #define FPTRUNC 398 |
| 360 | #define FPEXT 399 |
| 361 | #define FPTOUI 400 |
| 362 | #define FPTOSI 401 |
| 363 | #define UITOFP 402 |
| 364 | #define SITOFP 403 |
| 365 | #define PTRTOINT 404 |
| 366 | #define INTTOPTR 405 |
| 367 | #define BITCAST 406 |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | /* Copy the first part of user declarations. */ |
Reid Spencer | baba98a | 2007-04-11 12:10:58 +0000 | [diff] [blame] | 373 | #line 14 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 374 | |
| 375 | #include "UpgradeInternals.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 376 | #include "llvm/CallingConv.h" |
| 377 | #include "llvm/InlineAsm.h" |
| 378 | #include "llvm/Instructions.h" |
| 379 | #include "llvm/Module.h" |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 380 | #include "llvm/ParameterAttributes.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 381 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 382 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 383 | #include "llvm/ADT/STLExtras.h" |
| 384 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 385 | #include <algorithm> |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 386 | #include <iostream> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 387 | #include <map> |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 388 | #include <list> |
| 389 | #include <utility> |
| 390 | |
| 391 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 392 | // relating to upreferences in the input stream. |
| 393 | // |
| 394 | //#define DEBUG_UPREFS 1 |
| 395 | #ifdef DEBUG_UPREFS |
| 396 | #define UR_OUT(X) std::cerr << X |
| 397 | #else |
| 398 | #define UR_OUT(X) |
| 399 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 400 | |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 401 | #define YYERROR_VERBOSE 1 |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 402 | #define YYINCLUDED_STDLIB_H |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 403 | #define YYDEBUG 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 404 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 405 | int yylex(); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 406 | int yyparse(); |
| 407 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 408 | int yyerror(const char*); |
| 409 | static void warning(const std::string& WarningMsg); |
| 410 | |
| 411 | namespace llvm { |
| 412 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 413 | std::istream* LexInput; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 414 | static std::string CurFilename; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 415 | |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 416 | // This bool controls whether attributes are ever added to function declarations |
| 417 | // definitions and calls. |
| 418 | static bool AddAttributes = false; |
| 419 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 420 | static Module *ParserResult; |
| 421 | static bool ObsoleteVarArgs; |
| 422 | static bool NewVarArgs; |
| 423 | static BasicBlock *CurBB; |
| 424 | static GlobalVariable *CurGV; |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 425 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 426 | // This contains info used when building the body of a function. It is |
| 427 | // destroyed when the function is completed. |
| 428 | // |
| 429 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 430 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 431 | typedef std::pair<std::string,TypeInfo> RenameMapKey; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 432 | typedef std::map<RenameMapKey,std::string> RenameMapType; |
| 433 | |
| 434 | static void |
| 435 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 436 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 437 | |
| 438 | static struct PerModuleInfo { |
| 439 | Module *CurrentModule; |
| 440 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 441 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 442 | std::vector<PATypeHolder> Types; |
| 443 | std::vector<Signedness> TypeSigns; |
| 444 | std::map<std::string,Signedness> NamedTypeSigns; |
| 445 | std::map<std::string,Signedness> NamedValueSigns; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 446 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 447 | static Module::Endianness Endian; |
| 448 | static Module::PointerSize PointerSize; |
| 449 | RenameMapType RenameMap; |
| 450 | |
| 451 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
| 452 | /// how they were referenced and on which line of the input they came from so |
| 453 | /// that we can resolve them later and print error messages as appropriate. |
| 454 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 455 | |
| 456 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 457 | // references to global values. Global values may be referenced before they |
| 458 | // are defined, and if so, the temporary object that they represent is held |
| 459 | // here. This is used for forward references of GlobalValues. |
| 460 | // |
| 461 | typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*> |
| 462 | GlobalRefsType; |
| 463 | GlobalRefsType GlobalRefs; |
| 464 | |
| 465 | void ModuleDone() { |
| 466 | // If we could not resolve some functions at function compilation time |
| 467 | // (calls to functions before they are defined), resolve them now... Types |
| 468 | // are resolved when the constant pool has been completely parsed. |
| 469 | // |
| 470 | ResolveDefinitions(LateResolveValues); |
| 471 | |
| 472 | // Check to make sure that all global value forward references have been |
| 473 | // resolved! |
| 474 | // |
| 475 | if (!GlobalRefs.empty()) { |
| 476 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 477 | |
| 478 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 479 | I != E; ++I) { |
| 480 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 481 | I->first.second.getName() + "\n"; |
| 482 | } |
| 483 | error(UndefinedReferences); |
| 484 | return; |
| 485 | } |
| 486 | |
| 487 | if (CurrentModule->getDataLayout().empty()) { |
| 488 | std::string dataLayout; |
| 489 | if (Endian != Module::AnyEndianness) |
| 490 | dataLayout.append(Endian == Module::BigEndian ? "E" : "e"); |
| 491 | if (PointerSize != Module::AnyPointerSize) { |
| 492 | if (!dataLayout.empty()) |
| 493 | dataLayout += "-"; |
| 494 | dataLayout.append(PointerSize == Module::Pointer64 ? |
| 495 | "p:64:64" : "p:32:32"); |
| 496 | } |
| 497 | CurrentModule->setDataLayout(dataLayout); |
| 498 | } |
| 499 | |
| 500 | Values.clear(); // Clear out function local definitions |
| 501 | Types.clear(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 502 | TypeSigns.clear(); |
| 503 | NamedTypeSigns.clear(); |
| 504 | NamedValueSigns.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 505 | CurrentModule = 0; |
| 506 | } |
| 507 | |
| 508 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 509 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 510 | // If not, just return null. |
| 511 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 512 | // Check to see if there is a forward reference to this global variable... |
| 513 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 514 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 515 | GlobalValue *Ret = 0; |
| 516 | if (I != GlobalRefs.end()) { |
| 517 | Ret = I->second; |
| 518 | GlobalRefs.erase(I); |
| 519 | } |
| 520 | return Ret; |
| 521 | } |
| 522 | void setEndianness(Module::Endianness E) { Endian = E; } |
| 523 | void setPointerSize(Module::PointerSize sz) { PointerSize = sz; } |
| 524 | } CurModule; |
| 525 | |
| 526 | Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness; |
| 527 | Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize; |
| 528 | |
| 529 | static struct PerFunctionInfo { |
| 530 | Function *CurrentFunction; // Pointer to current function being created |
| 531 | |
| 532 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
| 533 | std::map<const Type*, ValueList> LateResolveValues; |
| 534 | bool isDeclare; // Is this function a forward declararation? |
| 535 | GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration. |
| 536 | |
| 537 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 538 | /// track of them here. |
| 539 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 540 | std::vector<BasicBlock*> NumberedBlocks; |
| 541 | RenameMapType RenameMap; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 542 | unsigned NextBBNum; |
| 543 | |
| 544 | inline PerFunctionInfo() { |
| 545 | CurrentFunction = 0; |
| 546 | isDeclare = false; |
| 547 | Linkage = GlobalValue::ExternalLinkage; |
| 548 | } |
| 549 | |
| 550 | inline void FunctionStart(Function *M) { |
| 551 | CurrentFunction = M; |
| 552 | NextBBNum = 0; |
| 553 | } |
| 554 | |
| 555 | void FunctionDone() { |
| 556 | NumberedBlocks.clear(); |
| 557 | |
| 558 | // Any forward referenced blocks left? |
| 559 | if (!BBForwardRefs.empty()) { |
| 560 | error("Undefined reference to label " + |
| 561 | BBForwardRefs.begin()->first->getName()); |
| 562 | return; |
| 563 | } |
| 564 | |
| 565 | // Resolve all forward references now. |
| 566 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 567 | |
| 568 | Values.clear(); // Clear out function local definitions |
| 569 | RenameMap.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 570 | CurrentFunction = 0; |
| 571 | isDeclare = false; |
| 572 | Linkage = GlobalValue::ExternalLinkage; |
| 573 | } |
| 574 | } CurFun; // Info for the current function... |
| 575 | |
| 576 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 577 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 578 | /// This function is just a utility to make a Key value for the rename map. |
| 579 | /// The Key is a combination of the name, type, Signedness of the original |
| 580 | /// value (global/function). This just constructs the key and ensures that |
| 581 | /// named Signedness values are resolved to the actual Signedness. |
| 582 | /// @brief Make a key for the RenameMaps |
| 583 | static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty, |
| 584 | const Signedness &Sign) { |
| 585 | TypeInfo TI; |
| 586 | TI.T = Ty; |
| 587 | if (Sign.isNamed()) |
| 588 | // Don't allow Named Signedness nodes because they won't match. The actual |
| 589 | // Signedness must be looked up in the NamedTypeSigns map. |
| 590 | TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]); |
| 591 | else |
| 592 | TI.S.copy(Sign); |
| 593 | return std::make_pair(Name, TI); |
| 594 | } |
| 595 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 596 | |
| 597 | //===----------------------------------------------------------------------===// |
| 598 | // Code to handle definitions of all the types |
| 599 | //===----------------------------------------------------------------------===// |
| 600 | |
| 601 | static int InsertValue(Value *V, |
| 602 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 603 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 604 | |
| 605 | // Yes, insert the value into the value table... |
| 606 | ValueList &List = ValueTab[V->getType()]; |
| 607 | List.push_back(V); |
| 608 | return List.size()-1; |
| 609 | } |
| 610 | |
Reid Spencer | d7c4f8c | 2007-01-26 19:59:25 +0000 | [diff] [blame] | 611 | static const Type *getType(const ValID &D, bool DoNotImprovise = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 612 | switch (D.Type) { |
| 613 | case ValID::NumberVal: // Is it a numbered definition? |
| 614 | // Module constants occupy the lowest numbered slots... |
| 615 | if ((unsigned)D.Num < CurModule.Types.size()) { |
| 616 | return CurModule.Types[(unsigned)D.Num]; |
| 617 | } |
| 618 | break; |
| 619 | case ValID::NameVal: // Is it a named definition? |
| 620 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 621 | return N; |
| 622 | } |
| 623 | break; |
| 624 | default: |
| 625 | error("Internal parser error: Invalid symbol type reference"); |
| 626 | return 0; |
| 627 | } |
| 628 | |
| 629 | // If we reached here, we referenced either a symbol that we don't know about |
| 630 | // or an id number that hasn't been read yet. We may be referencing something |
| 631 | // forward, so just create an entry to be resolved later and get to it... |
| 632 | // |
| 633 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 634 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 635 | if (inFunctionScope()) { |
| 636 | if (D.Type == ValID::NameVal) { |
| 637 | error("Reference to an undefined type: '" + D.getName() + "'"); |
| 638 | return 0; |
| 639 | } else { |
| 640 | error("Reference to an undefined type: #" + itostr(D.Num)); |
| 641 | return 0; |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 646 | if (I != CurModule.LateResolveTypes.end()) |
| 647 | return I->second; |
| 648 | |
| 649 | Type *Typ = OpaqueType::get(); |
| 650 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 651 | return Typ; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | /// This is like the getType method except that instead of looking up the type |
| 655 | /// for a given ID, it looks up that type's sign. |
| 656 | /// @brief Get the signedness of a referenced type |
| 657 | static Signedness getTypeSign(const ValID &D) { |
| 658 | switch (D.Type) { |
| 659 | case ValID::NumberVal: // Is it a numbered definition? |
| 660 | // Module constants occupy the lowest numbered slots... |
| 661 | if ((unsigned)D.Num < CurModule.TypeSigns.size()) { |
| 662 | return CurModule.TypeSigns[(unsigned)D.Num]; |
| 663 | } |
| 664 | break; |
| 665 | case ValID::NameVal: { // Is it a named definition? |
| 666 | std::map<std::string,Signedness>::const_iterator I = |
| 667 | CurModule.NamedTypeSigns.find(D.Name); |
| 668 | if (I != CurModule.NamedTypeSigns.end()) |
| 669 | return I->second; |
| 670 | // Perhaps its a named forward .. just cache the name |
| 671 | Signedness S; |
| 672 | S.makeNamed(D.Name); |
| 673 | return S; |
| 674 | } |
| 675 | default: |
| 676 | break; |
| 677 | } |
| 678 | // If we don't find it, its signless |
| 679 | Signedness S; |
| 680 | S.makeSignless(); |
| 681 | return S; |
| 682 | } |
| 683 | |
| 684 | /// This function is analagous to getElementType in LLVM. It provides the same |
| 685 | /// function except that it looks up the Signedness instead of the type. This is |
| 686 | /// used when processing GEP instructions that need to extract the type of an |
| 687 | /// indexed struct/array/ptr member. |
| 688 | /// @brief Look up an element's sign. |
| 689 | static Signedness getElementSign(const ValueInfo& VI, |
| 690 | const std::vector<Value*> &Indices) { |
| 691 | const Type *Ptr = VI.V->getType(); |
| 692 | assert(isa<PointerType>(Ptr) && "Need pointer type"); |
| 693 | |
| 694 | unsigned CurIdx = 0; |
| 695 | Signedness S(VI.S); |
| 696 | while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) { |
| 697 | if (CurIdx == Indices.size()) |
| 698 | break; |
| 699 | |
| 700 | Value *Index = Indices[CurIdx++]; |
| 701 | assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type"); |
| 702 | Ptr = CT->getTypeAtIndex(Index); |
| 703 | if (const Type* Ty = Ptr->getForwardedType()) |
| 704 | Ptr = Ty; |
| 705 | assert(S.isComposite() && "Bad Signedness type"); |
| 706 | if (isa<StructType>(CT)) { |
| 707 | S = S.get(cast<ConstantInt>(Index)->getZExtValue()); |
| 708 | } else { |
| 709 | S = S.get(0UL); |
| 710 | } |
| 711 | if (S.isNamed()) |
| 712 | S = CurModule.NamedTypeSigns[S.getName()]; |
| 713 | } |
| 714 | Signedness Result; |
| 715 | Result.makeComposite(S); |
| 716 | return Result; |
| 717 | } |
| 718 | |
| 719 | /// This function just translates a ConstantInfo into a ValueInfo and calls |
| 720 | /// getElementSign(ValueInfo,...). Its just a convenience. |
| 721 | /// @brief ConstantInfo version of getElementSign. |
| 722 | static Signedness getElementSign(const ConstInfo& CI, |
| 723 | const std::vector<Constant*> &Indices) { |
| 724 | ValueInfo VI; |
| 725 | VI.V = CI.C; |
| 726 | VI.S.copy(CI.S); |
| 727 | std::vector<Value*> Idx; |
| 728 | for (unsigned i = 0; i < Indices.size(); ++i) |
| 729 | Idx.push_back(Indices[i]); |
| 730 | Signedness result = getElementSign(VI, Idx); |
| 731 | VI.destroy(); |
| 732 | return result; |
| 733 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 734 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 735 | /// This function determines if two function types differ only in their use of |
| 736 | /// the sret parameter attribute in the first argument. If they are identical |
| 737 | /// in all other respects, it returns true. Otherwise, it returns false. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 738 | static bool FuncTysDifferOnlyBySRet(const FunctionType *F1, |
| 739 | const FunctionType *F2) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 740 | if (F1->getReturnType() != F2->getReturnType() || |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 741 | F1->getNumParams() != F2->getNumParams()) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 742 | return false; |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 743 | ParamAttrsList PAL1; |
| 744 | if (F1->getParamAttrs()) |
| 745 | PAL1 = *F1->getParamAttrs(); |
| 746 | ParamAttrsList PAL2; |
| 747 | if (F2->getParamAttrs()) |
| 748 | PAL2 = *F2->getParamAttrs(); |
| 749 | if (PAL1.getParamAttrs(0) != PAL2.getParamAttrs(0)) |
| 750 | return false; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 751 | unsigned SRetMask = ~unsigned(ParamAttr::StructRet); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 752 | for (unsigned i = 0; i < F1->getNumParams(); ++i) { |
| 753 | if (F1->getParamType(i) != F2->getParamType(i) || |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 754 | unsigned(PAL1.getParamAttrs(i+1)) & SRetMask != |
| 755 | unsigned(PAL2.getParamAttrs(i+1)) & SRetMask) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 756 | return false; |
| 757 | } |
| 758 | return true; |
| 759 | } |
| 760 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 761 | /// This function determines if the type of V and Ty differ only by the SRet |
| 762 | /// parameter attribute. This is a more generalized case of |
| 763 | /// FuncTysDIfferOnlyBySRet since it doesn't require FunctionType arguments. |
| 764 | static bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) { |
| 765 | if (V->getType() == Ty) |
| 766 | return true; |
| 767 | const PointerType *PF1 = dyn_cast<PointerType>(Ty); |
| 768 | const PointerType *PF2 = dyn_cast<PointerType>(V->getType()); |
| 769 | if (PF1 && PF2) { |
| 770 | const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType()); |
| 771 | const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType()); |
| 772 | if (FT1 && FT2) |
| 773 | return FuncTysDifferOnlyBySRet(FT1, FT2); |
| 774 | } |
| 775 | return false; |
| 776 | } |
| 777 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 778 | // The upgrade of csretcc to sret param attribute may have caused a function |
| 779 | // to not be found because the param attribute changed the type of the called |
| 780 | // function. This helper function, used in getExistingValue, detects that |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 781 | // situation and bitcasts the function to the correct type. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 782 | static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) { |
| 783 | // Handle degenerate cases |
| 784 | if (!V) |
| 785 | return 0; |
| 786 | if (V->getType() == Ty) |
| 787 | return V; |
| 788 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 789 | const PointerType *PF1 = dyn_cast<PointerType>(Ty); |
| 790 | const PointerType *PF2 = dyn_cast<PointerType>(V->getType()); |
| 791 | if (PF1 && PF2) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 792 | const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType()); |
| 793 | const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType()); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 794 | if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2)) { |
| 795 | const ParamAttrsList *PAL2 = FT2->getParamAttrs(); |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 796 | if (PAL2 && PAL2->paramHasAttr(1, ParamAttr::StructRet)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 797 | return V; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 798 | else if (Constant *C = dyn_cast<Constant>(V)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 799 | return ConstantExpr::getBitCast(C, PF1); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 800 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 801 | return new BitCastInst(V, PF1, "upgrd.cast", CurBB); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 802 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 803 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 804 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 805 | return 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 806 | } |
| 807 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 808 | // getExistingValue - Look up the value specified by the provided type and |
| 809 | // the provided ValID. If the value exists and has already been defined, return |
| 810 | // it. Otherwise return null. |
| 811 | // |
| 812 | static Value *getExistingValue(const Type *Ty, const ValID &D) { |
| 813 | if (isa<FunctionType>(Ty)) { |
| 814 | error("Functions are not values and must be referenced as pointers"); |
| 815 | } |
| 816 | |
| 817 | switch (D.Type) { |
| 818 | case ValID::NumberVal: { // Is it a numbered definition? |
| 819 | unsigned Num = (unsigned)D.Num; |
| 820 | |
| 821 | // Module constants occupy the lowest numbered slots... |
| 822 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 823 | if (VI != CurModule.Values.end()) { |
| 824 | if (Num < VI->second.size()) |
| 825 | return VI->second[Num]; |
| 826 | Num -= VI->second.size(); |
| 827 | } |
| 828 | |
| 829 | // Make sure that our type is within bounds |
| 830 | VI = CurFun.Values.find(Ty); |
| 831 | if (VI == CurFun.Values.end()) return 0; |
| 832 | |
| 833 | // Check that the number is within bounds... |
| 834 | if (VI->second.size() <= Num) return 0; |
| 835 | |
| 836 | return VI->second[Num]; |
| 837 | } |
| 838 | |
| 839 | case ValID::NameVal: { // Is it a named definition? |
| 840 | // Get the name out of the ID |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 841 | RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S); |
| 842 | Value *V = 0; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 843 | if (inFunctionScope()) { |
| 844 | // See if the name was renamed |
| 845 | RenameMapType::const_iterator I = CurFun.RenameMap.find(Key); |
| 846 | std::string LookupName; |
| 847 | if (I != CurFun.RenameMap.end()) |
| 848 | LookupName = I->second; |
| 849 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 850 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 851 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 852 | V = SymTab.lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 853 | if (V && V->getType() != Ty) |
| 854 | V = handleSRetFuncTypeMerge(V, Ty); |
| 855 | assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 856 | } |
| 857 | if (!V) { |
| 858 | RenameMapType::const_iterator I = CurModule.RenameMap.find(Key); |
| 859 | std::string LookupName; |
| 860 | if (I != CurModule.RenameMap.end()) |
| 861 | LookupName = I->second; |
| 862 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 863 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 864 | V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 865 | if (V && V->getType() != Ty) |
| 866 | V = handleSRetFuncTypeMerge(V, Ty); |
| 867 | assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 868 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 869 | if (!V) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 870 | return 0; |
| 871 | |
| 872 | D.destroy(); // Free old strdup'd memory... |
| 873 | return V; |
| 874 | } |
| 875 | |
| 876 | // Check to make sure that "Ty" is an integral type, and that our |
| 877 | // value will fit into the specified type... |
| 878 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
| 879 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
| 880 | error("Signed integral constant '" + itostr(D.ConstPool64) + |
| 881 | "' is invalid for type '" + Ty->getDescription() + "'"); |
| 882 | } |
| 883 | return ConstantInt::get(Ty, D.ConstPool64); |
| 884 | |
| 885 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
| 886 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 887 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) |
| 888 | error("Integral constant '" + utostr(D.UConstPool64) + |
| 889 | "' is invalid or out of range"); |
| 890 | else // This is really a signed reference. Transmogrify. |
| 891 | return ConstantInt::get(Ty, D.ConstPool64); |
| 892 | } else |
| 893 | return ConstantInt::get(Ty, D.UConstPool64); |
| 894 | |
| 895 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
| 896 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) |
| 897 | error("FP constant invalid for type"); |
| 898 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 899 | |
| 900 | case ValID::ConstNullVal: // Is it a null value? |
| 901 | if (!isa<PointerType>(Ty)) |
| 902 | error("Cannot create a a non pointer null"); |
| 903 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 904 | |
| 905 | case ValID::ConstUndefVal: // Is it an undef value? |
| 906 | return UndefValue::get(Ty); |
| 907 | |
| 908 | case ValID::ConstZeroVal: // Is it a zero value? |
| 909 | return Constant::getNullValue(Ty); |
| 910 | |
| 911 | case ValID::ConstantVal: // Fully resolved constant? |
| 912 | if (D.ConstantValue->getType() != Ty) |
| 913 | error("Constant expression type different from required type"); |
| 914 | return D.ConstantValue; |
| 915 | |
| 916 | case ValID::InlineAsmVal: { // Inline asm expression |
| 917 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 918 | const FunctionType *FTy = |
| 919 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
| 920 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) |
| 921 | error("Invalid type for asm constraint string"); |
| 922 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 923 | D.IAD->HasSideEffects); |
| 924 | D.destroy(); // Free InlineAsmDescriptor. |
| 925 | return IA; |
| 926 | } |
| 927 | default: |
| 928 | assert(0 && "Unhandled case"); |
| 929 | return 0; |
| 930 | } // End of switch |
| 931 | |
| 932 | assert(0 && "Unhandled case"); |
| 933 | return 0; |
| 934 | } |
| 935 | |
| 936 | // getVal - This function is identical to getExistingValue, except that if a |
| 937 | // value is not already defined, it "improvises" by creating a placeholder var |
| 938 | // that looks and acts just like the requested variable. When the value is |
| 939 | // defined later, all uses of the placeholder variable are replaced with the |
| 940 | // real thing. |
| 941 | // |
| 942 | static Value *getVal(const Type *Ty, const ValID &ID) { |
| 943 | if (Ty == Type::LabelTy) |
| 944 | error("Cannot use a basic block here"); |
| 945 | |
| 946 | // See if the value has already been defined. |
| 947 | Value *V = getExistingValue(Ty, ID); |
| 948 | if (V) return V; |
| 949 | |
| 950 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) |
| 951 | error("Invalid use of a composite type"); |
| 952 | |
| 953 | // If we reached here, we referenced either a symbol that we don't know about |
| 954 | // or an id number that hasn't been read yet. We may be referencing something |
| 955 | // 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] | 956 | V = new Argument(Ty); |
| 957 | |
| 958 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 959 | // to recycle these things?? |
| 960 | CurModule.PlaceHolderInfo.insert( |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 961 | std::make_pair(V, std::make_pair(ID, Upgradelineno))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 962 | |
| 963 | if (inFunctionScope()) |
| 964 | InsertValue(V, CurFun.LateResolveValues); |
| 965 | else |
| 966 | InsertValue(V, CurModule.LateResolveValues); |
| 967 | return V; |
| 968 | } |
| 969 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 970 | /// @brief This just makes any name given to it unique, up to MAX_UINT times. |
| 971 | static std::string makeNameUnique(const std::string& Name) { |
| 972 | static unsigned UniqueNameCounter = 1; |
| 973 | std::string Result(Name); |
| 974 | Result += ".upgrd." + llvm::utostr(UniqueNameCounter++); |
| 975 | return Result; |
| 976 | } |
| 977 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 978 | /// getBBVal - This is used for two purposes: |
| 979 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 980 | /// defined. |
| 981 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 982 | /// or may not be a forward reference. |
| 983 | /// |
| 984 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 985 | assert(inFunctionScope() && "Can't get basic block at global scope"); |
| 986 | |
| 987 | std::string Name; |
| 988 | BasicBlock *BB = 0; |
| 989 | switch (ID.Type) { |
| 990 | default: |
| 991 | error("Illegal label reference " + ID.getName()); |
| 992 | break; |
| 993 | case ValID::NumberVal: // Is it a numbered definition? |
| 994 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 995 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 996 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 997 | break; |
| 998 | case ValID::NameVal: // Is it a named definition? |
| 999 | Name = ID.Name; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1000 | if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1001 | if (N->getType() != Type::LabelTy) { |
| 1002 | // Register names didn't use to conflict with basic block names |
| 1003 | // because of type planes. Now they all have to be unique. So, we just |
| 1004 | // rename the register and treat this name as if no basic block |
| 1005 | // had been found. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1006 | RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1007 | N->setName(makeNameUnique(N->getName())); |
| 1008 | CurModule.RenameMap[Key] = N->getName(); |
| 1009 | BB = 0; |
| 1010 | } else { |
| 1011 | BB = cast<BasicBlock>(N); |
| 1012 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1013 | } |
| 1014 | break; |
| 1015 | } |
| 1016 | |
| 1017 | // See if the block has already been defined. |
| 1018 | if (BB) { |
| 1019 | // If this is the definition of the block, make sure the existing value was |
| 1020 | // just a forward reference. If it was a forward reference, there will be |
| 1021 | // an entry for it in the PlaceHolderInfo map. |
| 1022 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) |
| 1023 | // The existing value was a definition, not a forward reference. |
| 1024 | error("Redefinition of label " + ID.getName()); |
| 1025 | |
| 1026 | ID.destroy(); // Free strdup'd memory. |
| 1027 | return BB; |
| 1028 | } |
| 1029 | |
| 1030 | // Otherwise this block has not been seen before. |
| 1031 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 1032 | if (ID.Type == ValID::NameVal) { |
| 1033 | BB->setName(ID.Name); |
| 1034 | } else { |
| 1035 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 1036 | } |
| 1037 | |
| 1038 | // If this is not a definition, keep track of it so we can use it as a forward |
| 1039 | // reference. |
| 1040 | if (!isDefinition) { |
| 1041 | // Remember where this forward reference came from. |
| 1042 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno); |
| 1043 | } else { |
| 1044 | // The forward declaration could have been inserted anywhere in the |
| 1045 | // function: insert it into the correct place now. |
| 1046 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 1047 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 1048 | } |
| 1049 | ID.destroy(); |
| 1050 | return BB; |
| 1051 | } |
| 1052 | |
| 1053 | |
| 1054 | //===----------------------------------------------------------------------===// |
| 1055 | // Code to handle forward references in instructions |
| 1056 | //===----------------------------------------------------------------------===// |
| 1057 | // |
| 1058 | // This code handles the late binding needed with statements that reference |
| 1059 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 1060 | // a loop body. |
| 1061 | // |
| 1062 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 1063 | // and back patchs after we are done. |
| 1064 | // |
| 1065 | |
| 1066 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 1067 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 1068 | // defs now... |
| 1069 | // |
| 1070 | static void |
| 1071 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 1072 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1073 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1074 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 1075 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 1076 | E = LateResolvers.end(); LRI != E; ++LRI) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1077 | const Type* Ty = LRI->first; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1078 | ValueList &List = LRI->second; |
| 1079 | while (!List.empty()) { |
| 1080 | Value *V = List.back(); |
| 1081 | List.pop_back(); |
| 1082 | |
| 1083 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 1084 | CurModule.PlaceHolderInfo.find(V); |
| 1085 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error"); |
| 1086 | |
| 1087 | ValID &DID = PHI->second.first; |
| 1088 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1089 | Value *TheRealValue = getExistingValue(Ty, DID); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1090 | if (TheRealValue) { |
| 1091 | V->replaceAllUsesWith(TheRealValue); |
| 1092 | delete V; |
| 1093 | CurModule.PlaceHolderInfo.erase(PHI); |
| 1094 | } else if (FutureLateResolvers) { |
| 1095 | // Functions have their unresolved items forwarded to the module late |
| 1096 | // resolver table |
| 1097 | InsertValue(V, *FutureLateResolvers); |
| 1098 | } else { |
| 1099 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1100 | error("Reference to an invalid definition: '" + DID.getName() + |
| 1101 | "' of type '" + V->getType()->getDescription() + "'", |
| 1102 | PHI->second.second); |
Reid Spencer | 7de2e01 | 2007-01-29 19:08:46 +0000 | [diff] [blame] | 1103 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1104 | } else { |
| 1105 | error("Reference to an invalid definition: #" + |
| 1106 | itostr(DID.Num) + " of type '" + |
| 1107 | V->getType()->getDescription() + "'", PHI->second.second); |
| 1108 | return; |
| 1109 | } |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | LateResolvers.clear(); |
| 1115 | } |
| 1116 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1117 | /// This function is used for type resolution and upref handling. When a type |
| 1118 | /// becomes concrete, this function is called to adjust the signedness for the |
| 1119 | /// concrete type. |
| 1120 | static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) { |
| 1121 | std::string TyName = CurModule.CurrentModule->getTypeName(oldTy); |
| 1122 | if (!TyName.empty()) |
| 1123 | CurModule.NamedTypeSigns[TyName] = Sign; |
| 1124 | } |
| 1125 | |
| 1126 | /// ResolveTypeTo - A brand new type was just declared. This means that (if |
| 1127 | /// name is not null) things referencing Name can be resolved. Otherwise, |
| 1128 | /// things refering to the number can be resolved. Do this now. |
| 1129 | static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1130 | ValID D; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1131 | if (Name) |
| 1132 | D = ValID::create(Name); |
| 1133 | else |
| 1134 | D = ValID::create((int)CurModule.Types.size()); |
| 1135 | D.S.copy(Sign); |
| 1136 | |
Reid Spencer | baba98a | 2007-04-11 12:10:58 +0000 | [diff] [blame] | 1137 | if (Name) |
| 1138 | CurModule.NamedTypeSigns[Name] = Sign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1139 | |
| 1140 | std::map<ValID, PATypeHolder>::iterator I = |
| 1141 | CurModule.LateResolveTypes.find(D); |
| 1142 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1143 | const Type *OldTy = I->second.get(); |
| 1144 | ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1145 | CurModule.LateResolveTypes.erase(I); |
| 1146 | } |
| 1147 | } |
| 1148 | |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1149 | /// This is the implementation portion of TypeHasInteger. It traverses the |
| 1150 | /// type given, avoiding recursive types, and returns true as soon as it finds |
| 1151 | /// an integer type. If no integer type is found, it returns false. |
| 1152 | static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) { |
| 1153 | // Handle some easy cases |
| 1154 | if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID)) |
| 1155 | return false; |
| 1156 | if (Ty->isInteger()) |
| 1157 | return true; |
| 1158 | if (const SequentialType *STy = dyn_cast<SequentialType>(Ty)) |
| 1159 | return STy->getElementType()->isInteger(); |
| 1160 | |
| 1161 | // Avoid type structure recursion |
| 1162 | for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end(); |
| 1163 | I != E; ++I) |
| 1164 | if (Ty == *I) |
| 1165 | return false; |
| 1166 | |
| 1167 | // Push us on the type stack |
| 1168 | Stack.push_back(Ty); |
| 1169 | |
| 1170 | if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) { |
| 1171 | if (TypeHasIntegerI(FTy->getReturnType(), Stack)) |
| 1172 | return true; |
| 1173 | FunctionType::param_iterator I = FTy->param_begin(); |
| 1174 | FunctionType::param_iterator E = FTy->param_end(); |
| 1175 | for (; I != E; ++I) |
| 1176 | if (TypeHasIntegerI(*I, Stack)) |
| 1177 | return true; |
| 1178 | return false; |
| 1179 | } else if (const StructType *STy = dyn_cast<StructType>(Ty)) { |
| 1180 | StructType::element_iterator I = STy->element_begin(); |
| 1181 | StructType::element_iterator E = STy->element_end(); |
| 1182 | for (; I != E; ++I) { |
| 1183 | if (TypeHasIntegerI(*I, Stack)) |
| 1184 | return true; |
| 1185 | } |
| 1186 | return false; |
| 1187 | } |
| 1188 | // There shouldn't be anything else, but its definitely not integer |
| 1189 | assert(0 && "What type is this?"); |
| 1190 | return false; |
| 1191 | } |
| 1192 | |
| 1193 | /// This is the interface to TypeHasIntegerI. It just provides the type stack, |
| 1194 | /// to avoid recursion, and then calls TypeHasIntegerI. |
| 1195 | static inline bool TypeHasInteger(const Type *Ty) { |
| 1196 | std::vector<const Type*> TyStack; |
| 1197 | return TypeHasIntegerI(Ty, TyStack); |
| 1198 | } |
| 1199 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1200 | // setValueName - Set the specified value to the name given. The name may be |
| 1201 | // null potentially, in which case this is a noop. The string passed in is |
| 1202 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 1203 | // |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1204 | static void setValueName(const ValueInfo &V, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1205 | if (NameStr) { |
| 1206 | std::string Name(NameStr); // Copy string |
| 1207 | free(NameStr); // Free old string |
| 1208 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1209 | if (V.V->getType() == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1210 | error("Can't assign name '" + Name + "' to value with void type"); |
| 1211 | return; |
| 1212 | } |
| 1213 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1214 | assert(inFunctionScope() && "Must be in function scope"); |
| 1215 | |
| 1216 | // 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] | 1217 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 1218 | Value* Existing = ST.lookup(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1219 | if (Existing) { |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1220 | // An existing value of the same name was found. This might have happened |
| 1221 | // because of the integer type planes collapsing in LLVM 2.0. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1222 | if (Existing->getType() == V.V->getType() && |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1223 | !TypeHasInteger(Existing->getType())) { |
| 1224 | // If the type does not contain any integers in them then this can't be |
| 1225 | // a type plane collapsing issue. It truly is a redefinition and we |
| 1226 | // should error out as the assembly is invalid. |
| 1227 | error("Redefinition of value named '" + Name + "' of type '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1228 | V.V->getType()->getDescription() + "'"); |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1229 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1230 | } |
| 1231 | // In LLVM 2.0 we don't allow names to be re-used for any values in a |
| 1232 | // function, regardless of Type. Previously re-use of names was okay as |
| 1233 | // long as they were distinct types. With type planes collapsing because |
| 1234 | // of the signedness change and because of PR411, this can no longer be |
| 1235 | // supported. We must search the entire symbol table for a conflicting |
| 1236 | // name and make the name unique. No warning is needed as this can't |
| 1237 | // cause a problem. |
| 1238 | std::string NewName = makeNameUnique(Name); |
| 1239 | // We're changing the name but it will probably be used by other |
| 1240 | // instructions as operands later on. Consequently we have to retain |
| 1241 | // a mapping of the renaming that we're doing. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1242 | RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1243 | CurFun.RenameMap[Key] = NewName; |
| 1244 | Name = NewName; |
| 1245 | } |
| 1246 | |
| 1247 | // Set the name. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1248 | V.V->setName(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 1253 | /// this is a declaration, otherwise it is a definition. |
| 1254 | static GlobalVariable * |
| 1255 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 1256 | bool isConstantGlobal, const Type *Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1257 | Constant *Initializer, |
| 1258 | const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1259 | if (isa<FunctionType>(Ty)) |
| 1260 | error("Cannot declare global vars of function type"); |
| 1261 | |
| 1262 | const PointerType *PTy = PointerType::get(Ty); |
| 1263 | |
| 1264 | std::string Name; |
| 1265 | if (NameStr) { |
| 1266 | Name = NameStr; // Copy string |
| 1267 | free(NameStr); // Free old string |
| 1268 | } |
| 1269 | |
| 1270 | // See if this global value was forward referenced. If so, recycle the |
| 1271 | // object. |
| 1272 | ValID ID; |
| 1273 | if (!Name.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1274 | ID = ValID::create((char*)Name.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1275 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1276 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1277 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1278 | ID.S.makeComposite(Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1279 | |
| 1280 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1281 | // Move the global to the end of the list, from whereever it was |
| 1282 | // previously inserted. |
| 1283 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1284 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1285 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1286 | GV->setInitializer(Initializer); |
| 1287 | GV->setLinkage(Linkage); |
| 1288 | GV->setConstant(isConstantGlobal); |
| 1289 | InsertValue(GV, CurModule.Values); |
| 1290 | return GV; |
| 1291 | } |
| 1292 | |
| 1293 | // If this global has a name, check to see if there is already a definition |
| 1294 | // of this global in the module and emit warnings if there are conflicts. |
| 1295 | if (!Name.empty()) { |
| 1296 | // The global has a name. See if there's an existing one of the same name. |
| 1297 | if (CurModule.CurrentModule->getNamedGlobal(Name)) { |
| 1298 | // We found an existing global ov the same name. This isn't allowed |
| 1299 | // in LLVM 2.0. Consequently, we must alter the name of the global so it |
| 1300 | // can at least compile. This can happen because of type planes |
| 1301 | // There is alread a global of the same name which means there is a |
| 1302 | // conflict. Let's see what we can do about it. |
| 1303 | std::string NewName(makeNameUnique(Name)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1304 | if (Linkage != GlobalValue::InternalLinkage) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1305 | // The linkage of this gval is external so we can't reliably rename |
| 1306 | // it because it could potentially create a linking problem. |
| 1307 | // However, we can't leave the name conflict in the output either or |
| 1308 | // it won't assemble with LLVM 2.0. So, all we can do is rename |
| 1309 | // this one to something unique and emit a warning about the problem. |
| 1310 | warning("Renaming global variable '" + Name + "' to '" + NewName + |
| 1311 | "' may cause linkage errors"); |
| 1312 | } |
| 1313 | |
| 1314 | // Put the renaming in the global rename map |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1315 | RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1316 | CurModule.RenameMap[Key] = NewName; |
| 1317 | |
| 1318 | // Rename it |
| 1319 | Name = NewName; |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | // Otherwise there is no existing GV to use, create one now. |
| 1324 | GlobalVariable *GV = |
| 1325 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 1326 | CurModule.CurrentModule); |
| 1327 | InsertValue(GV, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1328 | // Remember the sign of this global. |
| 1329 | CurModule.NamedValueSigns[Name] = ID.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1330 | return GV; |
| 1331 | } |
| 1332 | |
| 1333 | // setTypeName - Set the specified type to the name given. The name may be |
| 1334 | // null potentially, in which case this is a noop. The string passed in is |
| 1335 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1336 | // |
| 1337 | // This function returns true if the type has already been defined, but is |
| 1338 | // allowed to be redefined in the specified context. If the name is a new name |
| 1339 | // for the type plane, it is inserted and false is returned. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1340 | static bool setTypeName(const PATypeInfo& TI, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1341 | assert(!inFunctionScope() && "Can't give types function-local names"); |
| 1342 | if (NameStr == 0) return false; |
| 1343 | |
| 1344 | std::string Name(NameStr); // Copy string |
| 1345 | free(NameStr); // Free old string |
| 1346 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1347 | const Type* Ty = TI.PAT->get(); |
| 1348 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1349 | // We don't allow assigning names to void type |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1350 | if (Ty == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1351 | error("Can't assign name '" + Name + "' to the void type"); |
| 1352 | return false; |
| 1353 | } |
| 1354 | |
| 1355 | // Set the type name, checking for conflicts as we do so. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1356 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty); |
| 1357 | |
| 1358 | // Save the sign information for later use |
| 1359 | CurModule.NamedTypeSigns[Name] = TI.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1360 | |
| 1361 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1362 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 1363 | assert(Existing && "Conflict but no matching type?"); |
| 1364 | |
| 1365 | // There is only one case where this is allowed: when we are refining an |
| 1366 | // opaque type. In this case, Existing will be an opaque type. |
| 1367 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1368 | // We ARE replacing an opaque type! |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1369 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1370 | return true; |
| 1371 | } |
| 1372 | |
| 1373 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1374 | // the redefinition is identical to the original. This will be so if |
| 1375 | // Existing and T point to the same Type object. In this one case we |
| 1376 | // allow the equivalent redefinition. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1377 | if (Existing == Ty) return true; // Yes, it's equal. |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1378 | |
| 1379 | // Any other kind of (non-equivalent) redefinition is an error. |
| 1380 | error("Redefinition of type named '" + Name + "' in the '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1381 | Ty->getDescription() + "' type plane"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1382 | } |
| 1383 | |
| 1384 | return false; |
| 1385 | } |
| 1386 | |
| 1387 | //===----------------------------------------------------------------------===// |
| 1388 | // Code for handling upreferences in type names... |
| 1389 | // |
| 1390 | |
| 1391 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1392 | // |
| 1393 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1394 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1395 | E) != Ty->subtype_end(); |
| 1396 | } |
| 1397 | |
| 1398 | namespace { |
| 1399 | struct UpRefRecord { |
| 1400 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1401 | // this type is resolved. |
| 1402 | unsigned NestingLevel; |
| 1403 | |
| 1404 | // LastContainedTy - This is the type at the current binding level for the |
| 1405 | // type. Every time we reduce the nesting level, this gets updated. |
| 1406 | const Type *LastContainedTy; |
| 1407 | |
| 1408 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1409 | // represented with. |
| 1410 | OpaqueType *UpRefTy; |
| 1411 | |
| 1412 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1413 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1414 | }; |
| 1415 | } |
| 1416 | |
| 1417 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1418 | static std::vector<UpRefRecord> UpRefs; |
| 1419 | |
| 1420 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1421 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1422 | /// currently active types. For each type, if the up reference is contained in |
| 1423 | /// the newly completed type, we decrement the level count. When the level |
| 1424 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1425 | /// thus we can complete the cycle. |
| 1426 | /// |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1427 | static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1428 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1429 | // nothing to resolve here. |
| 1430 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1431 | |
| 1432 | PATypeHolder Ty(ty); |
| 1433 | UR_OUT("Type '" << Ty->getDescription() << |
| 1434 | "' newly formed. Resolving upreferences.\n" << |
| 1435 | UpRefs.size() << " upreferences active!\n"); |
| 1436 | |
| 1437 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1438 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1439 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1440 | // this variable. |
| 1441 | OpaqueType *TypeToResolve = 0; |
| 1442 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1443 | unsigned i = 0; |
| 1444 | for (; i != UpRefs.size(); ++i) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1445 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1446 | << UpRefs[i].UpRefTy->getDescription() << ") = " |
| 1447 | << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1448 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1449 | // Decrement level of upreference |
| 1450 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1451 | UpRefs[i].LastContainedTy = Ty; |
| 1452 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1453 | if (Level == 0) { // Upreference should be resolved! |
| 1454 | if (!TypeToResolve) { |
| 1455 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1456 | } else { |
| 1457 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1458 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
| 1459 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1460 | ResolveTypeSign(UpRefs[i].UpRefTy, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1461 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1462 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1463 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1464 | } |
| 1465 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1466 | --i; // Do not skip the next element... |
| 1467 | } |
| 1468 | } |
| 1469 | } |
| 1470 | |
| 1471 | if (TypeToResolve) { |
| 1472 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1473 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1474 | std::string OldName = TypeToResolve->getDescription()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1475 | ResolveTypeSign(TypeToResolve, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1476 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1477 | } |
| 1478 | |
| 1479 | return Ty; |
| 1480 | } |
| 1481 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1482 | bool Signedness::operator<(const Signedness &that) const { |
| 1483 | if (isNamed()) { |
| 1484 | if (that.isNamed()) |
| 1485 | return *(this->name) < *(that.name); |
| 1486 | else |
| 1487 | return CurModule.NamedTypeSigns[*name] < that; |
| 1488 | } else if (that.isNamed()) { |
| 1489 | return *this < CurModule.NamedTypeSigns[*that.name]; |
| 1490 | } |
| 1491 | |
| 1492 | if (isComposite() && that.isComposite()) { |
| 1493 | if (sv->size() == that.sv->size()) { |
| 1494 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1495 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1496 | thatE = that.sv->end(); |
| 1497 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1498 | if (*thisI < *thatI) |
| 1499 | return true; |
| 1500 | else if (!(*thisI == *thatI)) |
| 1501 | return false; |
| 1502 | } |
| 1503 | return false; |
| 1504 | } |
| 1505 | return sv->size() < that.sv->size(); |
| 1506 | } |
| 1507 | return kind < that.kind; |
| 1508 | } |
| 1509 | |
| 1510 | bool Signedness::operator==(const Signedness &that) const { |
| 1511 | if (isNamed()) |
| 1512 | if (that.isNamed()) |
| 1513 | return *(this->name) == *(that.name); |
| 1514 | else |
| 1515 | return CurModule.NamedTypeSigns[*(this->name)] == that; |
| 1516 | else if (that.isNamed()) |
| 1517 | return *this == CurModule.NamedTypeSigns[*(that.name)]; |
| 1518 | if (isComposite() && that.isComposite()) { |
| 1519 | if (sv->size() == that.sv->size()) { |
| 1520 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1521 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1522 | thatE = that.sv->end(); |
| 1523 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1524 | if (!(*thisI == *thatI)) |
| 1525 | return false; |
| 1526 | } |
| 1527 | return true; |
| 1528 | } |
| 1529 | return false; |
| 1530 | } |
| 1531 | return kind == that.kind; |
| 1532 | } |
| 1533 | |
| 1534 | void Signedness::copy(const Signedness &that) { |
| 1535 | if (that.isNamed()) { |
| 1536 | kind = Named; |
| 1537 | name = new std::string(*that.name); |
| 1538 | } else if (that.isComposite()) { |
| 1539 | kind = Composite; |
| 1540 | sv = new SignVector(); |
| 1541 | *sv = *that.sv; |
| 1542 | } else { |
| 1543 | kind = that.kind; |
| 1544 | sv = 0; |
| 1545 | } |
| 1546 | } |
| 1547 | |
| 1548 | void Signedness::destroy() { |
| 1549 | if (isNamed()) { |
| 1550 | delete name; |
| 1551 | } else if (isComposite()) { |
| 1552 | delete sv; |
| 1553 | } |
| 1554 | } |
| 1555 | |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1556 | #ifndef NDEBUG |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1557 | void Signedness::dump() const { |
| 1558 | if (isComposite()) { |
| 1559 | if (sv->size() == 1) { |
| 1560 | (*sv)[0].dump(); |
| 1561 | std::cerr << "*"; |
| 1562 | } else { |
| 1563 | std::cerr << "{ " ; |
| 1564 | for (unsigned i = 0; i < sv->size(); ++i) { |
| 1565 | if (i != 0) |
| 1566 | std::cerr << ", "; |
| 1567 | (*sv)[i].dump(); |
| 1568 | } |
| 1569 | std::cerr << "} " ; |
| 1570 | } |
| 1571 | } else if (isNamed()) { |
| 1572 | std::cerr << *name; |
| 1573 | } else if (isSigned()) { |
| 1574 | std::cerr << "S"; |
| 1575 | } else if (isUnsigned()) { |
| 1576 | std::cerr << "U"; |
| 1577 | } else |
| 1578 | std::cerr << "."; |
| 1579 | } |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1580 | #endif |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1581 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1582 | static inline Instruction::TermOps |
| 1583 | getTermOp(TermOps op) { |
| 1584 | switch (op) { |
| 1585 | default : assert(0 && "Invalid OldTermOp"); |
| 1586 | case RetOp : return Instruction::Ret; |
| 1587 | case BrOp : return Instruction::Br; |
| 1588 | case SwitchOp : return Instruction::Switch; |
| 1589 | case InvokeOp : return Instruction::Invoke; |
| 1590 | case UnwindOp : return Instruction::Unwind; |
| 1591 | case UnreachableOp: return Instruction::Unreachable; |
| 1592 | } |
| 1593 | } |
| 1594 | |
| 1595 | static inline Instruction::BinaryOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1596 | getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1597 | switch (op) { |
| 1598 | default : assert(0 && "Invalid OldBinaryOps"); |
| 1599 | case SetEQ : |
| 1600 | case SetNE : |
| 1601 | case SetLE : |
| 1602 | case SetGE : |
| 1603 | case SetLT : |
| 1604 | case SetGT : assert(0 && "Should use getCompareOp"); |
| 1605 | case AddOp : return Instruction::Add; |
| 1606 | case SubOp : return Instruction::Sub; |
| 1607 | case MulOp : return Instruction::Mul; |
| 1608 | case DivOp : { |
| 1609 | // This is an obsolete instruction so we must upgrade it based on the |
| 1610 | // types of its operands. |
| 1611 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1612 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1613 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1614 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1615 | if (isFP) |
| 1616 | return Instruction::FDiv; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1617 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1618 | return Instruction::SDiv; |
| 1619 | return Instruction::UDiv; |
| 1620 | } |
| 1621 | case UDivOp : return Instruction::UDiv; |
| 1622 | case SDivOp : return Instruction::SDiv; |
| 1623 | case FDivOp : return Instruction::FDiv; |
| 1624 | case RemOp : { |
| 1625 | // This is an obsolete instruction so we must upgrade it based on the |
| 1626 | // types of its operands. |
| 1627 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1628 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1629 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1630 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1631 | // Select correct opcode |
| 1632 | if (isFP) |
| 1633 | return Instruction::FRem; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1634 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1635 | return Instruction::SRem; |
| 1636 | return Instruction::URem; |
| 1637 | } |
| 1638 | case URemOp : return Instruction::URem; |
| 1639 | case SRemOp : return Instruction::SRem; |
| 1640 | case FRemOp : return Instruction::FRem; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1641 | case LShrOp : return Instruction::LShr; |
| 1642 | case AShrOp : return Instruction::AShr; |
| 1643 | case ShlOp : return Instruction::Shl; |
| 1644 | case ShrOp : |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1645 | if (Sign.isSigned()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1646 | return Instruction::AShr; |
| 1647 | return Instruction::LShr; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1648 | case AndOp : return Instruction::And; |
| 1649 | case OrOp : return Instruction::Or; |
| 1650 | case XorOp : return Instruction::Xor; |
| 1651 | } |
| 1652 | } |
| 1653 | |
| 1654 | static inline Instruction::OtherOps |
| 1655 | getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1656 | const Signedness &Sign) { |
| 1657 | bool isSigned = Sign.isSigned(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1658 | bool isFP = Ty->isFloatingPoint(); |
| 1659 | switch (op) { |
| 1660 | default : assert(0 && "Invalid OldSetCC"); |
| 1661 | case SetEQ : |
| 1662 | if (isFP) { |
| 1663 | predicate = FCmpInst::FCMP_OEQ; |
| 1664 | return Instruction::FCmp; |
| 1665 | } else { |
| 1666 | predicate = ICmpInst::ICMP_EQ; |
| 1667 | return Instruction::ICmp; |
| 1668 | } |
| 1669 | case SetNE : |
| 1670 | if (isFP) { |
| 1671 | predicate = FCmpInst::FCMP_UNE; |
| 1672 | return Instruction::FCmp; |
| 1673 | } else { |
| 1674 | predicate = ICmpInst::ICMP_NE; |
| 1675 | return Instruction::ICmp; |
| 1676 | } |
| 1677 | case SetLE : |
| 1678 | if (isFP) { |
| 1679 | predicate = FCmpInst::FCMP_OLE; |
| 1680 | return Instruction::FCmp; |
| 1681 | } else { |
| 1682 | if (isSigned) |
| 1683 | predicate = ICmpInst::ICMP_SLE; |
| 1684 | else |
| 1685 | predicate = ICmpInst::ICMP_ULE; |
| 1686 | return Instruction::ICmp; |
| 1687 | } |
| 1688 | case SetGE : |
| 1689 | if (isFP) { |
| 1690 | predicate = FCmpInst::FCMP_OGE; |
| 1691 | return Instruction::FCmp; |
| 1692 | } else { |
| 1693 | if (isSigned) |
| 1694 | predicate = ICmpInst::ICMP_SGE; |
| 1695 | else |
| 1696 | predicate = ICmpInst::ICMP_UGE; |
| 1697 | return Instruction::ICmp; |
| 1698 | } |
| 1699 | case SetLT : |
| 1700 | if (isFP) { |
| 1701 | predicate = FCmpInst::FCMP_OLT; |
| 1702 | return Instruction::FCmp; |
| 1703 | } else { |
| 1704 | if (isSigned) |
| 1705 | predicate = ICmpInst::ICMP_SLT; |
| 1706 | else |
| 1707 | predicate = ICmpInst::ICMP_ULT; |
| 1708 | return Instruction::ICmp; |
| 1709 | } |
| 1710 | case SetGT : |
| 1711 | if (isFP) { |
| 1712 | predicate = FCmpInst::FCMP_OGT; |
| 1713 | return Instruction::FCmp; |
| 1714 | } else { |
| 1715 | if (isSigned) |
| 1716 | predicate = ICmpInst::ICMP_SGT; |
| 1717 | else |
| 1718 | predicate = ICmpInst::ICMP_UGT; |
| 1719 | return Instruction::ICmp; |
| 1720 | } |
| 1721 | } |
| 1722 | } |
| 1723 | |
| 1724 | static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) { |
| 1725 | switch (op) { |
| 1726 | default : assert(0 && "Invalid OldMemoryOps"); |
| 1727 | case MallocOp : return Instruction::Malloc; |
| 1728 | case FreeOp : return Instruction::Free; |
| 1729 | case AllocaOp : return Instruction::Alloca; |
| 1730 | case LoadOp : return Instruction::Load; |
| 1731 | case StoreOp : return Instruction::Store; |
| 1732 | case GetElementPtrOp : return Instruction::GetElementPtr; |
| 1733 | } |
| 1734 | } |
| 1735 | |
| 1736 | static inline Instruction::OtherOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1737 | getOtherOp(OtherOps op, const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1738 | switch (op) { |
| 1739 | default : assert(0 && "Invalid OldOtherOps"); |
| 1740 | case PHIOp : return Instruction::PHI; |
| 1741 | case CallOp : return Instruction::Call; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1742 | case SelectOp : return Instruction::Select; |
| 1743 | case UserOp1 : return Instruction::UserOp1; |
| 1744 | case UserOp2 : return Instruction::UserOp2; |
| 1745 | case VAArg : return Instruction::VAArg; |
| 1746 | case ExtractElementOp : return Instruction::ExtractElement; |
| 1747 | case InsertElementOp : return Instruction::InsertElement; |
| 1748 | case ShuffleVectorOp : return Instruction::ShuffleVector; |
| 1749 | case ICmpOp : return Instruction::ICmp; |
| 1750 | case FCmpOp : return Instruction::FCmp; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1751 | }; |
| 1752 | } |
| 1753 | |
| 1754 | static inline Value* |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1755 | getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy, |
| 1756 | const Signedness &DstSign, bool ForceInstruction = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1757 | Instruction::CastOps Opcode; |
| 1758 | const Type* SrcTy = Src->getType(); |
| 1759 | if (op == CastOp) { |
| 1760 | if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) { |
| 1761 | // fp -> ptr cast is no longer supported but we must upgrade this |
| 1762 | // by doing a double cast: fp -> int -> ptr |
| 1763 | SrcTy = Type::Int64Ty; |
| 1764 | Opcode = Instruction::IntToPtr; |
| 1765 | if (isa<Constant>(Src)) { |
| 1766 | Src = ConstantExpr::getCast(Instruction::FPToUI, |
| 1767 | cast<Constant>(Src), SrcTy); |
| 1768 | } else { |
| 1769 | std::string NewName(makeNameUnique(Src->getName())); |
| 1770 | Src = new FPToUIInst(Src, SrcTy, NewName, CurBB); |
| 1771 | } |
| 1772 | } else if (isa<IntegerType>(DstTy) && |
| 1773 | cast<IntegerType>(DstTy)->getBitWidth() == 1) { |
| 1774 | // cast type %x to bool was previously defined as setne type %x, null |
| 1775 | // The cast semantic is now to truncate, not compare so we must retain |
| 1776 | // the original intent by replacing the cast with a setne |
| 1777 | Constant* Null = Constant::getNullValue(SrcTy); |
| 1778 | Instruction::OtherOps Opcode = Instruction::ICmp; |
| 1779 | unsigned short predicate = ICmpInst::ICMP_NE; |
| 1780 | if (SrcTy->isFloatingPoint()) { |
| 1781 | Opcode = Instruction::FCmp; |
| 1782 | predicate = FCmpInst::FCMP_ONE; |
| 1783 | } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) { |
| 1784 | error("Invalid cast to bool"); |
| 1785 | } |
| 1786 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1787 | return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null); |
| 1788 | else |
| 1789 | return CmpInst::create(Opcode, predicate, Src, Null); |
| 1790 | } |
| 1791 | // Determine the opcode to use by calling CastInst::getCastOpcode |
| 1792 | Opcode = |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1793 | CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy, |
| 1794 | DstSign.isSigned()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1795 | |
| 1796 | } else switch (op) { |
| 1797 | default: assert(0 && "Invalid cast token"); |
| 1798 | case TruncOp: Opcode = Instruction::Trunc; break; |
| 1799 | case ZExtOp: Opcode = Instruction::ZExt; break; |
| 1800 | case SExtOp: Opcode = Instruction::SExt; break; |
| 1801 | case FPTruncOp: Opcode = Instruction::FPTrunc; break; |
| 1802 | case FPExtOp: Opcode = Instruction::FPExt; break; |
| 1803 | case FPToUIOp: Opcode = Instruction::FPToUI; break; |
| 1804 | case FPToSIOp: Opcode = Instruction::FPToSI; break; |
| 1805 | case UIToFPOp: Opcode = Instruction::UIToFP; break; |
| 1806 | case SIToFPOp: Opcode = Instruction::SIToFP; break; |
| 1807 | case PtrToIntOp: Opcode = Instruction::PtrToInt; break; |
| 1808 | case IntToPtrOp: Opcode = Instruction::IntToPtr; break; |
| 1809 | case BitCastOp: Opcode = Instruction::BitCast; break; |
| 1810 | } |
| 1811 | |
| 1812 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1813 | return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy); |
| 1814 | return CastInst::create(Opcode, Src, DstTy); |
| 1815 | } |
| 1816 | |
| 1817 | static Instruction * |
| 1818 | upgradeIntrinsicCall(const Type* RetTy, const ValID &ID, |
| 1819 | std::vector<Value*>& Args) { |
| 1820 | |
| 1821 | std::string Name = ID.Type == ValID::NameVal ? ID.Name : ""; |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1822 | switch (Name[5]) { |
| 1823 | case 'i': |
| 1824 | if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") { |
| 1825 | if (Args.size() != 2) |
| 1826 | error("Invalid prototype for " + Name); |
| 1827 | return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]); |
| 1828 | } |
| 1829 | break; |
| 1830 | case 'b': |
| 1831 | if (Name.length() == 14 && !memcmp(&Name[5], "bswap.i", 7)) { |
| 1832 | const Type* ArgTy = Args[0]->getType(); |
| 1833 | Name += ".i" + utostr(cast<IntegerType>(ArgTy)->getBitWidth()); |
| 1834 | Function *F = cast<Function>( |
| 1835 | CurModule.CurrentModule->getOrInsertFunction(Name, RetTy, ArgTy, |
| 1836 | (void*)0)); |
| 1837 | return new CallInst(F, Args[0]); |
| 1838 | } |
| 1839 | break; |
Reid Spencer | 8166a6c | 2007-04-02 02:08:35 +0000 | [diff] [blame] | 1840 | case 'c': |
| 1841 | if ((Name.length() <= 14 && !memcmp(&Name[5], "ctpop.i", 7)) || |
| 1842 | (Name.length() <= 13 && !memcmp(&Name[5], "ctlz.i", 6)) || |
| 1843 | (Name.length() <= 13 && !memcmp(&Name[5], "cttz.i", 6))) { |
| 1844 | // These intrinsics changed their result type. |
| 1845 | const Type* ArgTy = Args[0]->getType(); |
| 1846 | Function *OldF = CurModule.CurrentModule->getFunction(Name); |
| 1847 | if (OldF) |
| 1848 | OldF->setName("upgrd.rm." + Name); |
| 1849 | |
| 1850 | Function *NewF = cast<Function>( |
| 1851 | CurModule.CurrentModule->getOrInsertFunction(Name, Type::Int32Ty, |
| 1852 | ArgTy, (void*)0)); |
| 1853 | |
| 1854 | Instruction *Call = new CallInst(NewF, Args[0], "", CurBB); |
| 1855 | return CastInst::createIntegerCast(Call, RetTy, false); |
| 1856 | } |
| 1857 | break; |
| 1858 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1859 | case 'v' : { |
| 1860 | const Type* PtrTy = PointerType::get(Type::Int8Ty); |
| 1861 | std::vector<const Type*> Params; |
| 1862 | if (Name == "llvm.va_start" || Name == "llvm.va_end") { |
| 1863 | if (Args.size() != 1) |
| 1864 | error("Invalid prototype for " + Name + " prototype"); |
| 1865 | Params.push_back(PtrTy); |
| 1866 | const FunctionType *FTy = |
| 1867 | FunctionType::get(Type::VoidTy, Params, false); |
| 1868 | const PointerType *PFTy = PointerType::get(FTy); |
| 1869 | Value* Func = getVal(PFTy, ID); |
| 1870 | Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB); |
| 1871 | return new CallInst(Func, &Args[0], Args.size()); |
| 1872 | } else if (Name == "llvm.va_copy") { |
| 1873 | if (Args.size() != 2) |
| 1874 | error("Invalid prototype for " + Name + " prototype"); |
| 1875 | Params.push_back(PtrTy); |
| 1876 | Params.push_back(PtrTy); |
| 1877 | const FunctionType *FTy = |
| 1878 | FunctionType::get(Type::VoidTy, Params, false); |
| 1879 | const PointerType *PFTy = PointerType::get(FTy); |
| 1880 | Value* Func = getVal(PFTy, ID); |
| 1881 | std::string InstName0(makeNameUnique("va0")); |
| 1882 | std::string InstName1(makeNameUnique("va1")); |
| 1883 | Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB); |
| 1884 | Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB); |
| 1885 | return new CallInst(Func, &Args[0], Args.size()); |
| 1886 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1887 | } |
| 1888 | } |
| 1889 | return 0; |
| 1890 | } |
| 1891 | |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1892 | const Type* upgradeGEPCEIndices(const Type* PTy, |
| 1893 | std::vector<ValueInfo> *Indices, |
| 1894 | std::vector<Constant*> &Result) { |
| 1895 | const Type *Ty = PTy; |
| 1896 | Result.clear(); |
| 1897 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1898 | Constant *Index = cast<Constant>((*Indices)[i].V); |
| 1899 | |
| 1900 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1901 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1902 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1903 | if (CI->getBitWidth() < 32) |
| 1904 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1905 | } |
| 1906 | |
| 1907 | if (isa<SequentialType>(Ty)) { |
| 1908 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1909 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1910 | // all indices for SequentialType elements. We must retain the same |
| 1911 | // semantic (zext) for unsigned types. |
| 1912 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
| 1913 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
| 1914 | Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty); |
| 1915 | } |
| 1916 | } |
| 1917 | } |
| 1918 | Result.push_back(Index); |
| 1919 | Ty = GetElementPtrInst::getIndexedType(PTy, (Value**)&Result[0], |
| 1920 | Result.size(),true); |
| 1921 | if (!Ty) |
| 1922 | error("Index list invalid for constant getelementptr"); |
| 1923 | } |
| 1924 | return Ty; |
| 1925 | } |
| 1926 | |
| 1927 | const Type* upgradeGEPInstIndices(const Type* PTy, |
| 1928 | std::vector<ValueInfo> *Indices, |
| 1929 | std::vector<Value*> &Result) { |
| 1930 | const Type *Ty = PTy; |
| 1931 | Result.clear(); |
| 1932 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1933 | Value *Index = (*Indices)[i].V; |
| 1934 | |
| 1935 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1936 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1937 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1938 | if (CI->getBitWidth() < 32) |
| 1939 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1940 | } |
| 1941 | |
| 1942 | |
| 1943 | if (isa<StructType>(Ty)) { // Only change struct indices |
| 1944 | if (!isa<Constant>(Index)) { |
| 1945 | error("Invalid non-constant structure index"); |
| 1946 | return 0; |
| 1947 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1948 | } else { |
| 1949 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1950 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1951 | // all indices for SequentialType elements. We must retain the same |
| 1952 | // semantic (zext) for unsigned types. |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1953 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1954 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1955 | if (isa<Constant>(Index)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1956 | Index = ConstantExpr::getCast(Instruction::ZExt, |
| 1957 | cast<Constant>(Index), Type::Int64Ty); |
| 1958 | else |
| 1959 | Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty, |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1960 | makeNameUnique("gep"), CurBB); |
Reid Spencer | 38f682b | 2007-01-26 20:31:18 +0000 | [diff] [blame] | 1961 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1962 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1963 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1964 | Result.push_back(Index); |
| 1965 | Ty = GetElementPtrInst::getIndexedType(PTy, &Result[0], Result.size(),true); |
| 1966 | if (!Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1967 | error("Index list invalid for constant getelementptr"); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1968 | } |
| 1969 | return Ty; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1970 | } |
| 1971 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 1972 | unsigned upgradeCallingConv(unsigned CC) { |
| 1973 | switch (CC) { |
| 1974 | case OldCallingConv::C : return CallingConv::C; |
| 1975 | case OldCallingConv::CSRet : return CallingConv::C; |
| 1976 | case OldCallingConv::Fast : return CallingConv::Fast; |
| 1977 | case OldCallingConv::Cold : return CallingConv::Cold; |
| 1978 | case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall; |
| 1979 | case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall; |
| 1980 | default: |
| 1981 | return CC; |
| 1982 | } |
| 1983 | } |
| 1984 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1985 | Module* UpgradeAssembly(const std::string &infile, std::istream& in, |
| 1986 | bool debug, bool addAttrs) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1987 | { |
| 1988 | Upgradelineno = 1; |
| 1989 | CurFilename = infile; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 1990 | LexInput = ∈ |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1991 | yydebug = debug; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 1992 | AddAttributes = addAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1993 | ObsoleteVarArgs = false; |
| 1994 | NewVarArgs = false; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1995 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1996 | CurModule.CurrentModule = new Module(CurFilename); |
| 1997 | |
| 1998 | // Check to make sure the parser succeeded |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1999 | if (yyparse()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2000 | if (ParserResult) |
| 2001 | delete ParserResult; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2002 | std::cerr << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2003 | return 0; |
| 2004 | } |
| 2005 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2006 | // Check to make sure that parsing produced a result |
| 2007 | if (!ParserResult) { |
| 2008 | std::cerr << "llvm-upgrade: no parse result.\n"; |
| 2009 | return 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2010 | } |
| 2011 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2012 | // Reset ParserResult variable while saving its value for the result. |
| 2013 | Module *Result = ParserResult; |
| 2014 | ParserResult = 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2015 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2016 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2017 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2018 | Function* F; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2019 | if ((F = Result->getFunction("llvm.va_start")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2020 | && F->getFunctionType()->getNumParams() == 0) |
| 2021 | ObsoleteVarArgs = true; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2022 | if((F = Result->getFunction("llvm.va_copy")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2023 | && F->getFunctionType()->getNumParams() == 1) |
| 2024 | ObsoleteVarArgs = true; |
Reid Spencer | 280d801 | 2006-12-01 23:40:53 +0000 | [diff] [blame] | 2025 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2026 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2027 | if (ObsoleteVarArgs && NewVarArgs) { |
| 2028 | error("This file is corrupt: it uses both new and old style varargs"); |
| 2029 | return 0; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2030 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2031 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2032 | if(ObsoleteVarArgs) { |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2033 | if(Function* F = Result->getFunction("llvm.va_start")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2034 | if (F->arg_size() != 0) { |
| 2035 | error("Obsolete va_start takes 0 argument"); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2036 | return 0; |
| 2037 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2038 | |
| 2039 | //foo = va_start() |
| 2040 | // -> |
| 2041 | //bar = alloca typeof(foo) |
| 2042 | //va_start(bar) |
| 2043 | //foo = load bar |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2044 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2045 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2046 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2047 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2048 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2049 | "llvm.va_start", RetTy, ArgTyPtr, (Type *)0)); |
| 2050 | |
| 2051 | while (!F->use_empty()) { |
| 2052 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2053 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 2054 | new CallInst(NF, bar, "", CI); |
| 2055 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 2056 | CI->replaceAllUsesWith(foo); |
| 2057 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2058 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2059 | Result->getFunctionList().erase(F); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2060 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2061 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2062 | if(Function* F = Result->getFunction("llvm.va_end")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2063 | if(F->arg_size() != 1) { |
| 2064 | error("Obsolete va_end takes 1 argument"); |
| 2065 | return 0; |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2066 | } |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2067 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2068 | //vaend foo |
| 2069 | // -> |
| 2070 | //bar = alloca 1 of typeof(foo) |
| 2071 | //vaend bar |
| 2072 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2073 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 2074 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2075 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2076 | "llvm.va_end", RetTy, ArgTyPtr, (Type *)0)); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2077 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2078 | while (!F->use_empty()) { |
| 2079 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2080 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 2081 | new StoreInst(CI->getOperand(1), bar, CI); |
| 2082 | new CallInst(NF, bar, "", CI); |
| 2083 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2084 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2085 | Result->getFunctionList().erase(F); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2086 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2087 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2088 | if(Function* F = Result->getFunction("llvm.va_copy")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2089 | if(F->arg_size() != 1) { |
| 2090 | error("Obsolete va_copy takes 1 argument"); |
| 2091 | return 0; |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2092 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2093 | //foo = vacopy(bar) |
| 2094 | // -> |
| 2095 | //a = alloca 1 of typeof(foo) |
| 2096 | //b = alloca 1 of typeof(foo) |
| 2097 | //store bar -> b |
| 2098 | //vacopy(a, b) |
| 2099 | //foo = load a |
| 2100 | |
| 2101 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2102 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2103 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2104 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2105 | "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0)); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2106 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2107 | while (!F->use_empty()) { |
| 2108 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2109 | AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); |
| 2110 | AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); |
| 2111 | new StoreInst(CI->getOperand(1), b, CI); |
| 2112 | new CallInst(NF, a, b, "", CI); |
| 2113 | Value* foo = new LoadInst(a, "vacopy.fix.3", CI); |
| 2114 | CI->replaceAllUsesWith(foo); |
| 2115 | CI->getParent()->getInstList().erase(CI); |
| 2116 | } |
| 2117 | Result->getFunctionList().erase(F); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2118 | } |
| 2119 | } |
| 2120 | |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 2121 | return Result; |
| 2122 | } |
| 2123 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2124 | } // end llvm namespace |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2125 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2126 | using namespace llvm; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2127 | |
| 2128 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2129 | |
| 2130 | /* Enabling traces. */ |
| 2131 | #ifndef YYDEBUG |
| 2132 | # define YYDEBUG 0 |
| 2133 | #endif |
| 2134 | |
| 2135 | /* Enabling verbose error messages. */ |
| 2136 | #ifdef YYERROR_VERBOSE |
| 2137 | # undef YYERROR_VERBOSE |
| 2138 | # define YYERROR_VERBOSE 1 |
| 2139 | #else |
| 2140 | # define YYERROR_VERBOSE 0 |
| 2141 | #endif |
| 2142 | |
| 2143 | /* Enabling the token table. */ |
| 2144 | #ifndef YYTOKEN_TABLE |
| 2145 | # define YYTOKEN_TABLE 0 |
| 2146 | #endif |
| 2147 | |
| 2148 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 2149 | #line 1770 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2150 | typedef union YYSTYPE { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2151 | llvm::Module *ModuleVal; |
| 2152 | llvm::Function *FunctionVal; |
| 2153 | std::pair<llvm::PATypeInfo, char*> *ArgVal; |
| 2154 | llvm::BasicBlock *BasicBlockVal; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 2155 | llvm::TermInstInfo TermInstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2156 | llvm::InstrInfo InstVal; |
| 2157 | llvm::ConstInfo ConstVal; |
| 2158 | llvm::ValueInfo ValueVal; |
| 2159 | llvm::PATypeInfo TypeVal; |
| 2160 | llvm::TypeInfo PrimType; |
| 2161 | llvm::PHIListInfo PHIList; |
| 2162 | std::list<llvm::PATypeInfo> *TypeList; |
| 2163 | std::vector<llvm::ValueInfo> *ValueList; |
| 2164 | std::vector<llvm::ConstInfo> *ConstVector; |
| 2165 | |
| 2166 | |
| 2167 | std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList; |
| 2168 | // Represent the RHS of PHI node |
| 2169 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 2170 | |
| 2171 | llvm::GlobalValue::LinkageTypes Linkage; |
| 2172 | int64_t SInt64Val; |
| 2173 | uint64_t UInt64Val; |
| 2174 | int SIntVal; |
| 2175 | unsigned UIntVal; |
| 2176 | double FPVal; |
| 2177 | bool BoolVal; |
| 2178 | |
| 2179 | char *StrVal; // This memory is strdup'd! |
| 2180 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 2181 | |
| 2182 | llvm::BinaryOps BinaryOpVal; |
| 2183 | llvm::TermOps TermOpVal; |
| 2184 | llvm::MemoryOps MemOpVal; |
| 2185 | llvm::OtherOps OtherOpVal; |
| 2186 | llvm::CastOps CastOpVal; |
| 2187 | llvm::ICmpInst::Predicate IPred; |
| 2188 | llvm::FCmpInst::Predicate FPred; |
| 2189 | llvm::Module::Endianness Endianness; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2190 | } YYSTYPE; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2191 | /* Line 196 of yacc.c. */ |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 2192 | #line 2193 "UpgradeParser.tab.c" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2193 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 2194 | # define YYSTYPE_IS_DECLARED 1 |
| 2195 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2196 | #endif |
| 2197 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2198 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2199 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2200 | /* Copy the second part of user declarations. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2201 | |
| 2202 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2203 | /* Line 219 of yacc.c. */ |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 2204 | #line 2205 "UpgradeParser.tab.c" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2205 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2206 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 2207 | # define YYSIZE_T __SIZE_TYPE__ |
| 2208 | #endif |
| 2209 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 2210 | # define YYSIZE_T size_t |
| 2211 | #endif |
| 2212 | #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) |
| 2213 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 2214 | # define YYSIZE_T size_t |
| 2215 | #endif |
| 2216 | #if ! defined (YYSIZE_T) |
| 2217 | # define YYSIZE_T unsigned int |
| 2218 | #endif |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2219 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2220 | #ifndef YY_ |
| 2221 | # if YYENABLE_NLS |
| 2222 | # if ENABLE_NLS |
| 2223 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 2224 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 2225 | # endif |
| 2226 | # endif |
| 2227 | # ifndef YY_ |
| 2228 | # define YY_(msgid) msgid |
| 2229 | # endif |
| 2230 | #endif |
| 2231 | |
| 2232 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 2233 | |
| 2234 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 2235 | |
| 2236 | # ifdef YYSTACK_USE_ALLOCA |
| 2237 | # if YYSTACK_USE_ALLOCA |
| 2238 | # ifdef __GNUC__ |
| 2239 | # define YYSTACK_ALLOC __builtin_alloca |
| 2240 | # else |
| 2241 | # define YYSTACK_ALLOC alloca |
| 2242 | # if defined (__STDC__) || defined (__cplusplus) |
| 2243 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 2244 | # define YYINCLUDED_STDLIB_H |
| 2245 | # endif |
| 2246 | # endif |
| 2247 | # endif |
| 2248 | # endif |
| 2249 | |
| 2250 | # ifdef YYSTACK_ALLOC |
| 2251 | /* Pacify GCC's `empty if-body' warning. */ |
| 2252 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 2253 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 2254 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 2255 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 2256 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 2257 | to allow for a few compiler-allocated temporary stack slots. */ |
| 2258 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ |
| 2259 | # endif |
| 2260 | # else |
| 2261 | # define YYSTACK_ALLOC YYMALLOC |
| 2262 | # define YYSTACK_FREE YYFREE |
| 2263 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 2264 | # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) |
| 2265 | # endif |
| 2266 | # ifdef __cplusplus |
| 2267 | extern "C" { |
| 2268 | # endif |
| 2269 | # ifndef YYMALLOC |
| 2270 | # define YYMALLOC malloc |
| 2271 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 2272 | && (defined (__STDC__) || defined (__cplusplus))) |
| 2273 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 2274 | # endif |
| 2275 | # endif |
| 2276 | # ifndef YYFREE |
| 2277 | # define YYFREE free |
| 2278 | # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 2279 | && (defined (__STDC__) || defined (__cplusplus))) |
| 2280 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 2281 | # endif |
| 2282 | # endif |
| 2283 | # ifdef __cplusplus |
| 2284 | } |
| 2285 | # endif |
| 2286 | # endif |
| 2287 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 2288 | |
| 2289 | |
| 2290 | #if (! defined (yyoverflow) \ |
| 2291 | && (! defined (__cplusplus) \ |
| 2292 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 2293 | |
| 2294 | /* A type that is properly aligned for any stack member. */ |
| 2295 | union yyalloc |
| 2296 | { |
| 2297 | short int yyss; |
| 2298 | YYSTYPE yyvs; |
| 2299 | }; |
| 2300 | |
| 2301 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 2302 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 2303 | |
| 2304 | /* The size of an array large to enough to hold all stacks, each with |
| 2305 | N elements. */ |
| 2306 | # define YYSTACK_BYTES(N) \ |
| 2307 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
| 2308 | + YYSTACK_GAP_MAXIMUM) |
| 2309 | |
| 2310 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 2311 | not overlap. */ |
| 2312 | # ifndef YYCOPY |
| 2313 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 2314 | # define YYCOPY(To, From, Count) \ |
| 2315 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 2316 | # else |
| 2317 | # define YYCOPY(To, From, Count) \ |
| 2318 | do \ |
| 2319 | { \ |
| 2320 | YYSIZE_T yyi; \ |
| 2321 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 2322 | (To)[yyi] = (From)[yyi]; \ |
| 2323 | } \ |
| 2324 | while (0) |
| 2325 | # endif |
| 2326 | # endif |
| 2327 | |
| 2328 | /* Relocate STACK from its old location to the new one. The |
| 2329 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 2330 | elements in the stack, and YYPTR gives the new location of the |
| 2331 | stack. Advance YYPTR to a properly aligned location for the next |
| 2332 | stack. */ |
| 2333 | # define YYSTACK_RELOCATE(Stack) \ |
| 2334 | do \ |
| 2335 | { \ |
| 2336 | YYSIZE_T yynewbytes; \ |
| 2337 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 2338 | Stack = &yyptr->Stack; \ |
| 2339 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 2340 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 2341 | } \ |
| 2342 | while (0) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2343 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2344 | #endif |
| 2345 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2346 | #if defined (__STDC__) || defined (__cplusplus) |
| 2347 | typedef signed char yysigned_char; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2348 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2349 | typedef short int yysigned_char; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2350 | #endif |
| 2351 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2352 | /* YYFINAL -- State number of the termination state. */ |
| 2353 | #define YYFINAL 4 |
| 2354 | /* YYLAST -- Last index in YYTABLE. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2355 | #define YYLAST 1630 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2356 | |
| 2357 | /* YYNTOKENS -- Number of terminals. */ |
| 2358 | #define YYNTOKENS 166 |
| 2359 | /* YYNNTS -- Number of nonterminals. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2360 | #define YYNNTS 81 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2361 | /* YYNRULES -- Number of rules. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2362 | #define YYNRULES 310 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2363 | /* YYNRULES -- Number of states. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2364 | #define YYNSTATES 606 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2365 | |
| 2366 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 2367 | #define YYUNDEFTOK 2 |
| 2368 | #define YYMAXUTOK 406 |
| 2369 | |
| 2370 | #define YYTRANSLATE(YYX) \ |
| 2371 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 2372 | |
| 2373 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 2374 | static const unsigned char yytranslate[] = |
| 2375 | { |
| 2376 | 0, 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 | 155, 156, 164, 2, 153, 2, 2, 2, 2, 2, |
| 2381 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2382 | 160, 152, 161, 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, 157, 154, 159, 2, 2, 2, 2, 2, 165, |
| 2386 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2387 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2388 | 158, 2, 2, 162, 2, 163, 2, 2, 2, 2, |
| 2389 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2390 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2391 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2392 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2393 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2394 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2395 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2396 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2397 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2398 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2399 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2400 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2401 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 2402 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 2403 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 2404 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 2405 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 2406 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 2407 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 2408 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 2409 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2410 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2411 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2412 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 2413 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2414 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
| 2415 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 2416 | 145, 146, 147, 148, 149, 150, 151 |
| 2417 | }; |
| 2418 | |
| 2419 | #if YYDEBUG |
| 2420 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 2421 | YYRHS. */ |
| 2422 | static const unsigned short int yyprhs[] = |
| 2423 | { |
| 2424 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 2425 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 2426 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 2427 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 2428 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 2429 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 2430 | 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, |
| 2431 | 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, |
| 2432 | 159, 161, 164, 165, 167, 169, 171, 173, 175, 177, |
| 2433 | 179, 180, 181, 183, 185, 187, 189, 191, 193, 196, |
| 2434 | 197, 200, 201, 205, 208, 209, 211, 212, 216, 218, |
| 2435 | 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, |
| 2436 | 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, |
| 2437 | 261, 264, 269, 275, 281, 285, 288, 294, 299, 302, |
| 2438 | 304, 308, 310, 314, 316, 317, 322, 326, 330, 335, |
| 2439 | 340, 344, 351, 357, 360, 363, 366, 369, 372, 375, |
| 2440 | 378, 381, 384, 387, 394, 400, 409, 416, 423, 430, |
| 2441 | 438, 446, 453, 460, 469, 478, 482, 484, 486, 488, |
| 2442 | 490, 493, 496, 501, 504, 506, 511, 514, 519, 520, |
| 2443 | 528, 529, 537, 538, 546, 547, 555, 559, 564, 565, |
| 2444 | 567, 569, 571, 575, 579, 583, 587, 591, 595, 597, |
| 2445 | 598, 600, 602, 604, 605, 608, 612, 614, 616, 620, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2446 | 622, 623, 632, 634, 636, 637, 642, 644, 646, 649, |
| 2447 | 650, 652, 654, 655, 656, 662, 663, 665, 667, 669, |
| 2448 | 671, 673, 675, 677, 679, 681, 685, 687, 693, 695, |
| 2449 | 697, 699, 701, 704, 707, 710, 714, 717, 718, 720, |
| 2450 | 722, 724, 727, 730, 734, 744, 754, 763, 777, 779, |
| 2451 | 781, 788, 794, 797, 804, 812, 814, 818, 820, 821, |
| 2452 | 824, 826, 832, 838, 844, 851, 858, 861, 866, 871, |
| 2453 | 878, 883, 888, 893, 898, 905, 912, 915, 923, 925, |
| 2454 | 928, 929, 931, 932, 936, 943, 947, 954, 957, 962, |
| 2455 | 969 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2456 | }; |
| 2457 | |
| 2458 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 2459 | static const short int yyrhs[] = |
| 2460 | { |
| 2461 | 200, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
| 2462 | -1, 79, -1, 80, -1, 81, -1, 82, -1, 83, |
| 2463 | -1, 84, -1, 85, -1, 86, -1, 87, -1, 88, |
| 2464 | -1, 89, -1, 90, -1, 91, -1, 92, -1, 97, |
| 2465 | -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, |
| 2466 | -1, 119, -1, 120, -1, 121, -1, 122, -1, 123, |
| 2467 | -1, 124, -1, 125, -1, 126, -1, 127, -1, 128, |
| 2468 | -1, 129, -1, 130, -1, 131, -1, 132, -1, 133, |
| 2469 | -1, 134, -1, 135, -1, 136, -1, 137, -1, 138, |
| 2470 | -1, 125, -1, 126, -1, 127, -1, 128, -1, 27, |
| 2471 | -1, 28, -1, 93, -1, 94, -1, 95, -1, 96, |
| 2472 | -1, 140, -1, 141, -1, 142, -1, 143, -1, 144, |
| 2473 | -1, 145, -1, 146, -1, 147, -1, 148, -1, 149, |
| 2474 | -1, 150, -1, 151, -1, 139, -1, 16, -1, 14, |
| 2475 | -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, |
| 2476 | -1, 11, -1, 176, -1, 177, -1, 18, -1, 19, |
| 2477 | -1, 212, 152, -1, -1, 41, -1, 42, -1, 43, |
| 2478 | -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, |
| 2479 | -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, |
| 2480 | -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, |
| 2481 | -1, 153, 57, 4, -1, 34, 24, -1, -1, 185, |
| 2482 | -1, -1, 153, 188, 187, -1, 185, -1, 57, 4, |
| 2483 | -1, 191, -1, 8, -1, 193, -1, 8, -1, 193, |
| 2484 | -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, |
| 2485 | -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2486 | -1, 19, -1, 21, -1, 192, -1, 48, -1, 229, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2487 | -1, 154, 4, -1, 190, 155, 195, 156, -1, 157, |
| 2488 | 4, 158, 193, 159, -1, 160, 4, 158, 193, 161, |
| 2489 | -1, 162, 194, 163, -1, 162, 163, -1, 160, 162, |
| 2490 | 194, 163, 161, -1, 160, 162, 163, 161, -1, 193, |
| 2491 | 164, -1, 193, -1, 194, 153, 193, -1, 194, -1, |
| 2492 | 194, 153, 37, -1, 37, -1, -1, 191, 157, 198, |
| 2493 | 159, -1, 191, 157, 159, -1, 191, 165, 24, -1, |
| 2494 | 191, 160, 198, 161, -1, 191, 162, 198, 163, -1, |
| 2495 | 191, 162, 163, -1, 191, 160, 162, 198, 163, 161, |
| 2496 | -1, 191, 160, 162, 163, 161, -1, 191, 38, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2497 | 191, 39, -1, 191, 229, -1, 191, 197, -1, 191, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2498 | 26, -1, 176, 168, -1, 177, 4, -1, 9, 27, |
| 2499 | -1, 9, 28, -1, 179, 7, -1, 175, 155, 196, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2500 | 36, 191, 156, -1, 110, 155, 196, 244, 156, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2501 | 112, 155, 196, 153, 196, 153, 196, 156, -1, 169, |
| 2502 | 155, 196, 153, 196, 156, -1, 170, 155, 196, 153, |
| 2503 | 196, 156, -1, 171, 155, 196, 153, 196, 156, -1, |
| 2504 | 103, 172, 155, 196, 153, 196, 156, -1, 104, 173, |
| 2505 | 155, 196, 153, 196, 156, -1, 174, 155, 196, 153, |
| 2506 | 196, 156, -1, 114, 155, 196, 153, 196, 156, -1, |
| 2507 | 115, 155, 196, 153, 196, 153, 196, 156, -1, 116, |
| 2508 | 155, 196, 153, 196, 153, 196, 156, -1, 198, 153, |
| 2509 | 196, -1, 196, -1, 32, -1, 33, -1, 201, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2510 | 201, 222, -1, 201, 224, -1, 201, 62, 61, 207, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2511 | -1, 201, 25, -1, 202, -1, 202, 180, 20, 189, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2512 | -1, 202, 224, -1, 202, 62, 61, 207, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2513 | 202, 180, 181, 199, 196, 203, 187, -1, -1, 202, |
| 2514 | 180, 50, 199, 191, 204, 187, -1, -1, 202, 180, |
| 2515 | 45, 199, 191, 205, 187, -1, -1, 202, 180, 47, |
| 2516 | 199, 191, 206, 187, -1, 202, 51, 209, -1, 202, |
| 2517 | 58, 152, 210, -1, -1, 24, -1, 56, -1, 55, |
| 2518 | -1, 53, 152, 208, -1, 54, 152, 4, -1, 52, |
| 2519 | 152, 24, -1, 71, 152, 24, -1, 157, 211, 159, |
| 2520 | -1, 211, 153, 24, -1, 24, -1, -1, 22, -1, |
| 2521 | 24, -1, 212, -1, -1, 191, 213, -1, 215, 153, |
| 2522 | 214, -1, 214, -1, 215, -1, 215, 153, 37, -1, |
| 2523 | 37, -1, -1, 182, 189, 212, 155, 216, 156, 186, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2524 | 183, -1, 29, -1, 162, -1, -1, 181, 220, 217, |
| 2525 | 218, -1, 30, -1, 163, -1, 232, 221, -1, -1, |
| 2526 | 45, -1, 47, -1, -1, -1, 31, 225, 223, 226, |
| 2527 | 217, -1, -1, 63, -1, 3, -1, 4, -1, 7, |
| 2528 | -1, 27, -1, 28, -1, 38, -1, 39, -1, 26, |
| 2529 | -1, 160, 198, 161, -1, 197, -1, 61, 227, 24, |
| 2530 | 153, 24, -1, 167, -1, 212, -1, 229, -1, 228, |
| 2531 | -1, 191, 230, -1, 232, 233, -1, 219, 233, -1, |
| 2532 | 234, 180, 236, -1, 234, 238, -1, -1, 23, -1, |
| 2533 | 77, -1, 78, -1, 72, 231, -1, 72, 8, -1, |
| 2534 | 73, 21, 230, -1, 73, 9, 230, 153, 21, 230, |
| 2535 | 153, 21, 230, -1, 74, 178, 230, 153, 21, 230, |
| 2536 | 157, 237, 159, -1, 74, 178, 230, 153, 21, 230, |
| 2537 | 157, 159, -1, 75, 182, 189, 230, 155, 241, 156, |
| 2538 | 36, 21, 230, 235, 21, 230, -1, 235, -1, 76, |
| 2539 | -1, 237, 178, 228, 153, 21, 230, -1, 178, 228, |
| 2540 | 153, 21, 230, -1, 180, 243, -1, 191, 157, 230, |
| 2541 | 153, 230, 159, -1, 239, 153, 157, 230, 153, 230, |
| 2542 | 159, -1, 231, -1, 240, 153, 231, -1, 240, -1, |
| 2543 | -1, 60, 59, -1, 59, -1, 169, 191, 230, 153, |
| 2544 | 230, -1, 170, 191, 230, 153, 230, -1, 171, 191, |
| 2545 | 230, 153, 230, -1, 103, 172, 191, 230, 153, 230, |
| 2546 | -1, 104, 173, 191, 230, 153, 230, -1, 49, 231, |
| 2547 | -1, 174, 231, 153, 231, -1, 175, 231, 36, 191, |
| 2548 | -1, 112, 231, 153, 231, 153, 231, -1, 113, 231, |
| 2549 | 153, 191, -1, 117, 231, 153, 191, -1, 118, 231, |
| 2550 | 153, 191, -1, 114, 231, 153, 231, -1, 115, 231, |
| 2551 | 153, 231, 153, 231, -1, 116, 231, 153, 231, 153, |
| 2552 | 231, -1, 111, 239, -1, 242, 182, 189, 230, 155, |
| 2553 | 241, 156, -1, 246, -1, 153, 240, -1, -1, 35, |
| 2554 | -1, -1, 105, 191, 184, -1, 105, 191, 153, 15, |
| 2555 | 230, 184, -1, 106, 191, 184, -1, 106, 191, 153, |
| 2556 | 15, 230, 184, -1, 107, 231, -1, 245, 108, 191, |
| 2557 | 230, -1, 245, 109, 231, 153, 191, 230, -1, 110, |
| 2558 | 191, 230, 244, -1 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2559 | }; |
| 2560 | |
| 2561 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 2562 | static const unsigned short int yyrline[] = |
| 2563 | { |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 2564 | 0, 1910, 1910, 1911, 1919, 1920, 1930, 1930, 1930, 1930, |
| 2565 | 1930, 1930, 1930, 1930, 1930, 1930, 1930, 1934, 1934, 1934, |
| 2566 | 1938, 1938, 1938, 1938, 1938, 1938, 1942, 1942, 1943, 1943, |
| 2567 | 1944, 1944, 1945, 1945, 1946, 1946, 1950, 1950, 1951, 1951, |
| 2568 | 1952, 1952, 1953, 1953, 1954, 1954, 1955, 1955, 1956, 1956, |
| 2569 | 1957, 1958, 1961, 1961, 1961, 1961, 1965, 1965, 1965, 1965, |
| 2570 | 1965, 1965, 1965, 1966, 1966, 1966, 1966, 1966, 1966, 1972, |
| 2571 | 1972, 1972, 1972, 1976, 1976, 1976, 1976, 1980, 1980, 1984, |
| 2572 | 1984, 1989, 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
| 2573 | 2004, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2025, |
| 2574 | 2026, 2034, 2035, 2043, 2052, 2053, 2060, 2061, 2065, 2069, |
| 2575 | 2085, 2086, 2093, 2094, 2101, 2109, 2109, 2109, 2109, 2109, |
| 2576 | 2109, 2109, 2110, 2110, 2110, 2110, 2110, 2115, 2119, 2123, |
| 2577 | 2128, 2137, 2155, 2161, 2174, 2185, 2189, 2202, 2206, 2220, |
| 2578 | 2224, 2231, 2232, 2238, 2245, 2257, 2287, 2300, 2323, 2351, |
| 2579 | 2373, 2384, 2406, 2417, 2426, 2431, 2490, 2497, 2505, 2512, |
| 2580 | 2519, 2523, 2527, 2536, 2551, 2563, 2572, 2600, 2613, 2622, |
| 2581 | 2628, 2634, 2645, 2651, 2657, 2668, 2669, 2678, 2679, 2691, |
| 2582 | 2700, 2701, 2702, 2703, 2704, 2720, 2740, 2742, 2744, 2744, |
| 2583 | 2751, 2751, 2759, 2759, 2767, 2767, 2776, 2778, 2780, 2785, |
| 2584 | 2799, 2800, 2804, 2807, 2815, 2819, 2826, 2830, 2834, 2838, |
| 2585 | 2846, 2846, 2850, 2851, 2855, 2863, 2868, 2876, 2877, 2884, |
| 2586 | 2891, 2895, 3077, 3077, 3081, 3081, 3091, 3091, 3095, 3100, |
| 2587 | 3101, 3102, 3106, 3107, 3106, 3119, 3120, 3125, 3126, 3127, |
| 2588 | 3128, 3132, 3136, 3137, 3138, 3139, 3160, 3164, 3178, 3179, |
| 2589 | 3184, 3184, 3192, 3202, 3205, 3214, 3225, 3230, 3239, 3250, |
| 2590 | 3250, 3253, 3257, 3261, 3266, 3276, 3294, 3303, 3373, 3377, |
| 2591 | 3384, 3396, 3411, 3441, 3451, 3461, 3465, 3472, 3473, 3477, |
| 2592 | 3480, 3486, 3505, 3523, 3539, 3553, 3567, 3578, 3596, 3605, |
| 2593 | 3614, 3621, 3642, 3666, 3672, 3678, 3684, 3700, 3790, 3798, |
| 2594 | 3799, 3803, 3804, 3808, 3814, 3821, 3827, 3834, 3841, 3854, |
| 2595 | 3880 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2596 | }; |
| 2597 | #endif |
| 2598 | |
| 2599 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 2600 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 2601 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 2602 | static const char *const yytname[] = |
| 2603 | { |
| 2604 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 2605 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 2606 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 2607 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 2608 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 2609 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 2610 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 2611 | "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 2612 | "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", |
| 2613 | "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", |
| 2614 | "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", |
| 2615 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 2616 | "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT", |
| 2617 | "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM", |
| 2618 | "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR", |
| 2619 | "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP", |
| 2620 | "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", |
| 2621 | "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", |
| 2622 | "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", |
| 2623 | "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", |
| 2624 | "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", |
| 2625 | "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR", |
| 2626 | "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", |
| 2627 | "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL", |
| 2628 | "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates", |
| 2629 | "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType", |
| 2630 | "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", |
| 2631 | "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes", |
| 2632 | "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", |
| 2633 | "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", |
| 2634 | "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", |
| 2635 | "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition", |
| 2636 | "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal", |
| 2637 | "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2638 | "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7", |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2639 | "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", |
| 2640 | "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", |
| 2641 | "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList", |
| 2642 | "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList", |
| 2643 | "OptVolatile", "MemoryInst", 0 |
| 2644 | }; |
| 2645 | #endif |
| 2646 | |
| 2647 | # ifdef YYPRINT |
| 2648 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 2649 | token YYLEX-NUM. */ |
| 2650 | static const unsigned short int yytoknum[] = |
| 2651 | { |
| 2652 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 2653 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 2654 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 2655 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 2656 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 2657 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 2658 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 2659 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 2660 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 2661 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 2662 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 2663 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 2664 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 2665 | 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, |
| 2666 | 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, |
| 2667 | 405, 406, 61, 44, 92, 40, 41, 91, 120, 93, |
| 2668 | 60, 62, 123, 125, 42, 99 |
| 2669 | }; |
| 2670 | # endif |
| 2671 | |
| 2672 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 2673 | static const unsigned char yyr1[] = |
| 2674 | { |
| 2675 | 0, 166, 167, 167, 168, 168, 169, 169, 169, 169, |
| 2676 | 169, 169, 169, 169, 169, 169, 169, 170, 170, 170, |
| 2677 | 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, |
| 2678 | 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, |
| 2679 | 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, |
| 2680 | 173, 173, 174, 174, 174, 174, 175, 175, 175, 175, |
| 2681 | 175, 175, 175, 175, 175, 175, 175, 175, 175, 176, |
| 2682 | 176, 176, 176, 177, 177, 177, 177, 178, 178, 179, |
| 2683 | 179, 180, 180, 181, 181, 181, 181, 181, 181, 181, |
| 2684 | 181, 182, 182, 182, 182, 182, 182, 182, 182, 183, |
| 2685 | 183, 184, 184, 185, 186, 186, 187, 187, 188, 188, |
| 2686 | 189, 189, 190, 190, 191, 192, 192, 192, 192, 192, |
| 2687 | 192, 192, 192, 192, 192, 192, 192, 193, 193, 193, |
| 2688 | 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, |
| 2689 | 194, 195, 195, 195, 195, 196, 196, 196, 196, 196, |
| 2690 | 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, |
| 2691 | 196, 196, 196, 197, 197, 197, 197, 197, 197, 197, |
| 2692 | 197, 197, 197, 197, 197, 198, 198, 199, 199, 200, |
| 2693 | 201, 201, 201, 201, 201, 202, 202, 202, 203, 202, |
| 2694 | 204, 202, 205, 202, 206, 202, 202, 202, 202, 207, |
| 2695 | 208, 208, 209, 209, 209, 209, 210, 211, 211, 211, |
| 2696 | 212, 212, 213, 213, 214, 215, 215, 216, 216, 216, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2697 | 216, 217, 218, 218, 220, 219, 221, 221, 222, 223, |
| 2698 | 223, 223, 225, 226, 224, 227, 227, 228, 228, 228, |
| 2699 | 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, |
| 2700 | 230, 230, 231, 232, 232, 233, 234, 234, 234, 235, |
| 2701 | 235, 236, 236, 236, 236, 236, 236, 236, 236, 236, |
| 2702 | 237, 237, 238, 239, 239, 240, 240, 241, 241, 242, |
| 2703 | 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, |
| 2704 | 243, 243, 243, 243, 243, 243, 243, 243, 243, 244, |
| 2705 | 244, 245, 245, 246, 246, 246, 246, 246, 246, 246, |
| 2706 | 246 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2707 | }; |
| 2708 | |
| 2709 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 2710 | static const unsigned char yyr2[] = |
| 2711 | { |
| 2712 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2713 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2714 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2715 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2716 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2717 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2718 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2719 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2720 | 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, |
| 2721 | 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, |
| 2722 | 2, 0, 3, 2, 0, 1, 0, 3, 1, 2, |
| 2723 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2724 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2725 | 2, 4, 5, 5, 3, 2, 5, 4, 2, 1, |
| 2726 | 3, 1, 3, 1, 0, 4, 3, 3, 4, 4, |
| 2727 | 3, 6, 5, 2, 2, 2, 2, 2, 2, 2, |
| 2728 | 2, 2, 2, 6, 5, 8, 6, 6, 6, 7, |
| 2729 | 7, 6, 6, 8, 8, 3, 1, 1, 1, 1, |
| 2730 | 2, 2, 4, 2, 1, 4, 2, 4, 0, 7, |
| 2731 | 0, 7, 0, 7, 0, 7, 3, 4, 0, 1, |
| 2732 | 1, 1, 3, 3, 3, 3, 3, 3, 1, 0, |
| 2733 | 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2734 | 0, 8, 1, 1, 0, 4, 1, 1, 2, 0, |
| 2735 | 1, 1, 0, 0, 5, 0, 1, 1, 1, 1, |
| 2736 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 2737 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 1, |
| 2738 | 1, 2, 2, 3, 9, 9, 8, 13, 1, 1, |
| 2739 | 6, 5, 2, 6, 7, 1, 3, 1, 0, 2, |
| 2740 | 1, 5, 5, 5, 6, 6, 2, 4, 4, 6, |
| 2741 | 4, 4, 4, 4, 6, 6, 2, 7, 1, 2, |
| 2742 | 0, 1, 0, 3, 6, 3, 6, 2, 4, 6, |
| 2743 | 4 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2744 | }; |
| 2745 | |
| 2746 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 2747 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 2748 | means the default is an error. */ |
| 2749 | static const unsigned short int yydefact[] = |
| 2750 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2751 | 198, 0, 90, 184, 1, 183, 232, 83, 84, 85, |
| 2752 | 86, 87, 88, 89, 0, 224, 257, 180, 181, 257, |
| 2753 | 210, 211, 0, 0, 0, 90, 0, 186, 229, 0, |
| 2754 | 91, 258, 254, 82, 226, 227, 228, 253, 0, 0, |
| 2755 | 0, 0, 196, 0, 0, 0, 0, 0, 0, 0, |
| 2756 | 81, 230, 231, 233, 199, 182, 0, 92, 93, 94, |
| 2757 | 95, 96, 97, 0, 0, 302, 256, 0, 0, 0, |
| 2758 | 0, 209, 197, 187, 2, 3, 111, 115, 116, 117, |
| 2759 | 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, |
| 2760 | 0, 0, 0, 0, 248, 185, 0, 110, 127, 114, |
| 2761 | 249, 129, 177, 178, 0, 0, 0, 0, 91, 98, |
| 2762 | 0, 222, 223, 225, 301, 0, 280, 0, 0, 0, |
| 2763 | 0, 91, 269, 259, 260, 6, 7, 8, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2764 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 52, |
| 2765 | 53, 54, 55, 20, 21, 22, 23, 24, 25, 0, |
| 2766 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2767 | 0, 0, 0, 68, 56, 57, 58, 59, 60, 61, |
| 2768 | 62, 63, 64, 65, 66, 67, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2769 | 0, 268, 255, 91, 272, 0, 298, 204, 201, 200, |
| 2770 | 202, 203, 205, 208, 0, 130, 0, 0, 0, 113, |
| 2771 | 135, 139, 0, 144, 138, 192, 194, 190, 115, 116, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2772 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2773 | 0, 0, 0, 188, 234, 0, 0, 286, 279, 262, |
| 2774 | 261, 0, 0, 72, 76, 71, 75, 70, 74, 69, |
| 2775 | 73, 77, 78, 0, 0, 26, 27, 28, 29, 30, |
| 2776 | 31, 32, 33, 34, 35, 0, 50, 51, 46, 47, |
| 2777 | 48, 49, 36, 37, 38, 39, 40, 41, 42, 43, |
| 2778 | 44, 45, 0, 101, 101, 307, 0, 0, 296, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2779 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2780 | 0, 0, 0, 0, 0, 206, 0, 0, 0, 0, |
| 2781 | 0, 134, 143, 141, 0, 106, 106, 106, 160, 161, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2782 | 4, 5, 158, 159, 162, 157, 153, 154, 0, 0, |
| 2783 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2784 | 0, 0, 0, 0, 156, 155, 106, 220, 237, 238, |
| 2785 | 239, 244, 240, 241, 242, 243, 235, 0, 246, 251, |
| 2786 | 250, 252, 0, 263, 0, 0, 0, 0, 0, 303, |
| 2787 | 0, 305, 300, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2788 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2789 | 207, 112, 112, 137, 0, 140, 0, 131, 0, 193, |
| 2790 | 195, 191, 0, 0, 0, 0, 0, 0, 0, 146, |
| 2791 | 176, 0, 0, 0, 150, 0, 147, 0, 0, 0, |
| 2792 | 0, 0, 189, 219, 213, 216, 217, 0, 236, 0, |
| 2793 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2794 | 310, 0, 0, 0, 290, 293, 0, 0, 291, 292, |
| 2795 | 0, 0, 0, 287, 288, 0, 308, 0, 132, 133, |
| 2796 | 136, 142, 0, 0, 108, 106, 0, 0, 300, 0, |
| 2797 | 0, 0, 0, 0, 145, 135, 114, 0, 148, 149, |
| 2798 | 0, 0, 0, 0, 0, 212, 214, 0, 104, 0, |
| 2799 | 245, 0, 0, 278, 0, 0, 101, 102, 101, 275, |
| 2800 | 299, 0, 0, 0, 0, 0, 281, 282, 283, 278, |
| 2801 | 0, 103, 109, 107, 0, 0, 0, 0, 0, 0, |
| 2802 | 0, 175, 152, 0, 0, 0, 0, 0, 0, 218, |
| 2803 | 215, 105, 99, 0, 0, 0, 277, 0, 284, 285, |
| 2804 | 0, 304, 306, 0, 0, 0, 289, 294, 295, 0, |
| 2805 | 309, 0, 0, 164, 0, 0, 0, 0, 151, 0, |
| 2806 | 0, 0, 0, 0, 0, 221, 247, 0, 0, 0, |
| 2807 | 276, 273, 0, 297, 0, 0, 0, 172, 0, 0, |
| 2808 | 166, 167, 168, 171, 163, 100, 0, 266, 0, 0, |
| 2809 | 0, 274, 169, 170, 0, 0, 0, 264, 0, 265, |
| 2810 | 0, 0, 165, 173, 174, 0, 0, 0, 0, 0, |
| 2811 | 0, 271, 0, 0, 270, 267 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2812 | }; |
| 2813 | |
| 2814 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 2815 | static const short int yydefgoto[] = |
| 2816 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2817 | -1, 94, 312, 329, 330, 331, 255, 272, 332, 333, |
| 2818 | 219, 220, 243, 221, 25, 15, 63, 555, 359, 454, |
| 2819 | 522, 389, 455, 95, 96, 222, 98, 99, 202, 304, |
| 2820 | 400, 348, 401, 104, 1, 2, 3, 336, 307, 305, |
| 2821 | 306, 55, 190, 42, 72, 194, 100, 476, 415, 416, |
| 2822 | 417, 64, 113, 16, 30, 36, 17, 53, 18, 28, |
| 2823 | 108, 419, 349, 101, 351, 489, 19, 32, 33, 181, |
| 2824 | 182, 579, 66, 278, 526, 527, 183, 184, 430, 185, |
| 2825 | 186 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2826 | }; |
| 2827 | |
| 2828 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 2829 | STATE-NUM. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2830 | #define YYPACT_NINF -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2831 | static const short int yypact[] = |
| 2832 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2833 | -542, 13, 162, 567, -542, -542, -542, -542, -542, -542, |
| 2834 | -542, -542, -542, -542, 83, -542, 19, -542, -542, -14, |
| 2835 | -542, -542, 50, -87, 87, 233, 27, -542, 123, 141, |
| 2836 | 175, -542, -542, 98, -542, -542, -542, -542, 33, 40, |
| 2837 | 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156, |
| 2838 | -542, -542, -542, -542, -542, -542, 221, -542, -542, -542, |
| 2839 | -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226, |
| 2840 | 227, 235, -542, -542, -542, -542, 81, -542, -542, -542, |
| 2841 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2842 | 256, 257, 4, 15, -542, -542, 108, -542, -542, 12, |
| 2843 | -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542, |
| 2844 | 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116, |
| 2845 | 479, 175, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2846 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2847 | -542, -542, -542, -542, -542, -542, -542, -542, -542, 355, |
| 2848 | 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, |
| 2849 | 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542, |
| 2850 | -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306, |
| 2851 | 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542, |
| 2852 | -542, -542, -542, -542, -13, -542, 110, 111, 75, -542, |
| 2853 | -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208, |
| 2854 | 266, 210, 267, 212, 268, 230, 277, 275, 278, 246, |
| 2855 | 280, 279, 566, -542, -542, 136, 766, -542, -542, 81, |
| 2856 | -542, 766, 766, -542, -542, -542, -542, -542, -542, -542, |
| 2857 | -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542, |
| 2858 | -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542, |
| 2859 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2860 | -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147, |
| 2861 | 148, 149, 151, 152, 158, 160, 766, 766, 766, 161, |
| 2862 | 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27, |
| 2863 | 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542, |
| 2864 | -542, -542, -542, -542, -542, -542, -542, -542, 355, 429, |
| 2865 | 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184, |
| 2866 | 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542, |
| 2867 | -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542, |
| 2868 | -542, -542, 193, -542, 194, 766, 766, 766, 7, -542, |
| 2869 | 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306, |
| 2870 | 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207, |
| 2871 | -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542, |
| 2872 | -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542, |
| 2873 | -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326, |
| 2874 | 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337, |
| 2875 | -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306, |
| 2876 | -542, 223, 766, 224, -542, -542, 225, 234, -542, -542, |
| 2877 | 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542, |
| 2878 | -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236, |
| 2879 | 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542, |
| 2880 | 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252, |
| 2881 | -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542, |
| 2882 | 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306, |
| 2883 | 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326, |
| 2884 | 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542, |
| 2885 | -542, -542, 368, 402, 274, 276, 259, 287, -542, -542, |
| 2886 | 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290, |
| 2887 | -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296, |
| 2888 | 297, 299, 302, 303, 430, -542, -542, 414, 41, 425, |
| 2889 | -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326, |
| 2890 | -542, -542, -542, -542, -542, -542, 766, -542, 893, 144, |
| 2891 | 448, -542, -542, -542, 314, 315, 316, -542, 331, -542, |
| 2892 | 893, 766, -542, -542, -542, 464, 334, 180, 766, 481, |
| 2893 | 482, -542, 766, 766, -542, -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2894 | }; |
| 2895 | |
| 2896 | /* YYPGOTO[NTERM-NUM]. */ |
| 2897 | static const short int yypgoto[] = |
| 2898 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2899 | -542, -542, -542, 435, 439, 441, 191, 197, 442, 445, |
| 2900 | -119, -116, -541, -542, 478, 489, -107, -542, -267, 37, |
| 2901 | -542, -238, -542, -60, -542, -45, -542, -74, -51, -542, |
| 2902 | -101, 300, -252, 134, -542, -542, -542, -542, -542, -542, |
| 2903 | -542, 473, -542, -542, -542, -542, 8, -542, 46, -542, |
| 2904 | -542, 410, -542, -542, -542, -542, -542, -542, 518, -542, |
| 2905 | -542, -542, -528, 142, -90, -113, -542, 505, -542, -72, |
| 2906 | -542, -542, -542, -542, 97, 28, -542, -542, 70, -542, |
| 2907 | -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2908 | }; |
| 2909 | |
| 2910 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2911 | positive, shift that token. If negative, reduce the rule which |
| 2912 | number is the opposite. If zero, do what YYDEFACT says. |
| 2913 | If YYTABLE_NINF, syntax error. */ |
| 2914 | #define YYTABLE_NINF -180 |
| 2915 | static const short int yytable[] = |
| 2916 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2917 | 97, 241, 227, 110, 242, 230, 223, 361, 197, 31, |
| 2918 | 111, 26, 449, 4, 244, 204, 34, 578, 97, 201, |
| 2919 | 74, 75, 426, 199, 77, 78, 79, 80, 81, 82, |
| 2920 | 83, 84, 85, 86, 87, 428, 88, 20, 590, 21, |
| 2921 | 275, 26, 31, 279, 280, 281, 282, 283, 284, 285, |
| 2922 | 588, 233, 234, 235, 236, 237, 238, 239, 240, 205, |
| 2923 | 206, 207, 596, 89, 427, 43, 289, 290, 390, 391, |
| 2924 | 226, 463, 300, 226, 403, 405, 291, 427, 452, 468, |
| 2925 | 74, 75, 301, 199, 77, 78, 79, 80, 81, 82, |
| 2926 | 83, 84, 85, 86, 87, 420, 88, 20, 412, 21, |
| 2927 | 448, 453, 38, 39, 40, 204, 273, 274, 226, 276, |
| 2928 | 277, 226, 226, 226, 226, 226, 226, 226, 225, 463, |
| 2929 | 20, 41, 21, 89, 201, 231, 300, 480, -139, 201, |
| 2930 | -112, 286, 287, 288, 226, 226, 384, 232, -139, 204, |
| 2931 | 294, 352, 353, 112, 29, 463, 295, 299, 44, 35, |
| 2932 | 467, 464, 303, 354, 233, 234, 235, 236, 237, 238, |
| 2933 | 239, 240, -179, 463, 463, 54, 198, -112, 51, 90, |
| 2934 | 52, 71, 91, 469, 513, 92, 204, 93, 200, 50, |
| 2935 | 379, 105, 106, 107, 355, 67, 362, 5, 102, 103, |
| 2936 | 188, 189, 68, 6, 292, 293, 372, 373, 374, 97, |
| 2937 | 577, 308, 309, 7, 8, 9, 10, 11, 12, 13, |
| 2938 | 356, -72, -72, -71, -71, -70, -70, 503, 69, 531, |
| 2939 | 70, 532, 381, 382, 14, 109, 385, 357, 187, 90, |
| 2940 | 191, 377, 91, -69, -69, 92, -113, 93, 298, 56, |
| 2941 | 57, 58, 59, 60, 61, 62, 97, 378, 226, 310, |
| 2942 | 311, 192, 433, 45, 435, 436, 437, 123, 124, 193, |
| 2943 | 195, 196, 443, 203, 228, 423, 424, 425, 296, 297, |
| 2944 | -76, -75, -74, 431, 7, 8, 9, 10, 46, 12, |
| 2945 | 47, -73, -79, 48, 313, -80, 314, 445, 446, 363, |
| 2946 | 358, 337, 414, 458, 459, 460, 461, 462, 360, 364, |
| 2947 | 365, 366, 367, 589, 368, 369, 470, 471, 472, 473, |
| 2948 | 474, 370, 385, 371, 375, 380, 383, 376, 386, 387, |
| 2949 | 226, 434, 226, 226, 226, 438, 439, 394, 466, 388, |
| 2950 | 226, 444, 395, 396, 397, 406, 486, 398, 488, 407, |
| 2951 | 408, 409, 492, 410, 411, 418, 421, 422, 429, 432, |
| 2952 | 496, 497, 498, 440, 441, 504, 505, 450, 456, 442, |
| 2953 | 447, 479, 511, 481, 335, 478, 457, 477, 350, 482, |
| 2954 | 483, 484, 485, 350, 350, 487, 491, 493, 494, 502, |
| 2955 | 536, 537, 538, 499, 226, 350, 501, 495, 518, 507, |
| 2956 | 508, 524, 525, 509, 528, 529, 510, 514, 515, 512, |
| 2957 | 516, 534, 500, 517, 452, 523, 544, 545, 546, 547, |
| 2958 | 540, 530, 533, 549, 550, 551, 552, 535, 350, 543, |
| 2959 | 560, 548, 475, 541, 542, 554, 556, 557, 350, 350, |
| 2960 | 350, 427, 414, 558, 575, 576, 566, 568, 226, 241, |
| 2961 | 564, 565, 242, 559, 561, 562, 563, 569, 226, 226, |
| 2962 | 226, 567, 570, 571, 226, 572, 256, 257, 573, 574, |
| 2963 | 241, 580, 582, 242, 581, 584, 583, 585, 586, 591, |
| 2964 | 592, 593, 594, 553, 245, 246, 247, 248, 249, 250, |
| 2965 | 251, 252, 253, 254, 595, 598, 587, 599, 226, 233, |
| 2966 | 234, 235, 236, 237, 238, 239, 240, 350, 350, 350, |
| 2967 | 176, 597, 602, 603, 177, 350, 178, 179, 601, 392, |
| 2968 | 180, 65, 604, 605, 49, 521, 393, 73, 224, 350, |
| 2969 | 350, 27, 334, 520, 37, 600, 490, 539, 506, 0, |
| 2970 | 0, 0, 0, 0, 74, 75, 0, 199, 208, 209, |
| 2971 | 210, 211, 212, 213, 214, 215, 216, 217, 218, 0, |
| 2972 | 88, 20, 0, 21, 258, 259, 260, 261, 262, 263, |
| 2973 | 264, 265, 266, 267, 268, 269, 270, 271, 350, 0, |
| 2974 | 350, 74, 75, 0, 350, 0, 0, 89, 0, 0, |
| 2975 | 0, 0, 350, 350, 350, 0, 0, -82, 20, 20, |
| 2976 | 21, 21, 315, 0, 0, 0, 0, 0, 6, -82, |
| 2977 | -82, 0, 0, 0, 316, 317, 0, 0, -82, -82, |
| 2978 | -82, -82, -82, -82, -82, 0, 0, -82, 22, 0, |
| 2979 | 0, 0, 0, 350, 350, 23, 350, 350, 0, 24, |
| 2980 | 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2981 | 0, 0, 350, 0, 0, 125, 126, 127, 128, 129, |
| 2982 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2983 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
| 2984 | 319, 0, 0, 0, 0, 0, 320, 350, 321, 0, |
| 2985 | 322, 323, 324, 90, 0, 0, 91, 0, 0, 92, |
| 2986 | 0, 93, 404, 0, 0, 0, 0, 0, 0, 0, |
| 2987 | 0, 0, 0, 0, 0, 163, 164, 165, 166, 167, |
| 2988 | 168, 169, 170, 171, 172, 173, 174, 175, 350, 0, |
| 2989 | 0, 0, 0, 325, 0, 0, 326, 0, 327, 0, |
| 2990 | 0, 328, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2991 | 350, 0, 0, 0, 350, 350, 74, 75, 0, 199, |
| 2992 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, |
| 2993 | 218, 0, 88, 20, 0, 21, 0, 0, 0, 338, |
| 2994 | 339, 74, 75, 340, 0, 0, 0, 0, 0, 0, |
| 2995 | 0, 0, 0, 0, 0, 0, 0, 0, 20, 89, |
| 2996 | 21, 0, 341, 342, 343, 0, 0, 0, 0, 0, |
| 2997 | 0, 0, 0, 0, 344, 345, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2998 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2999 | 0, 0, 0, 0, 0, 0, 0, 346, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3000 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3001 | 0, 0, 0, 0, 0, 125, 126, 127, 128, 129, |
| 3002 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 3003 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3004 | 319, 0, 0, 0, 0, 0, 320, 0, 321, 0, |
| 3005 | 322, 323, 324, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3006 | 0, 0, 0, 0, 0, 90, 338, 339, 91, 0, |
| 3007 | 340, 92, 0, 93, 465, 163, 164, 165, 166, 167, |
| 3008 | 168, 169, 170, 171, 172, 173, 174, 175, 0, 341, |
| 3009 | 342, 343, 0, 0, 0, 0, 347, 0, 0, 0, |
| 3010 | 0, 344, 345, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3011 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3012 | 0, 0, 0, 0, 346, 0, 0, 0, 0, 0, |
| 3013 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3014 | 0, 0, 125, 126, 127, 128, 129, 130, 131, 132, |
| 3015 | 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, |
| 3016 | 143, 144, 145, 146, 147, 148, 318, 319, 0, 0, |
| 3017 | 0, 0, 0, 320, 0, 321, 0, 322, 323, 324, |
| 3018 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3019 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3020 | 0, 0, 163, 164, 165, 166, 167, 168, 169, 170, |
| 3021 | 171, 172, 173, 174, 175, 0, 0, 0, 0, 0, |
| 3022 | 0, 74, 75, 347, 199, 77, 78, 79, 80, 81, |
| 3023 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 3024 | 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3025 | 0, 0, 0, 302, 0, 0, 0, 0, 0, 0, |
| 3026 | 0, 0, 74, 75, 89, 199, 208, 209, 210, 211, |
| 3027 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 3028 | 0, 21, 74, 75, 0, 199, 77, 78, 79, 80, |
| 3029 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 3030 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 0, |
| 3031 | 0, 0, 0, 0, 413, 0, 0, 0, 0, 0, |
| 3032 | 0, 0, 0, 74, 75, 89, 199, 77, 78, 79, |
| 3033 | 80, 81, 82, 83, 84, 85, 86, 87, 0, 88, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3034 | 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3035 | 0, 0, 0, 0, 0, 451, 0, 0, 0, 0, |
| 3036 | 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, |
| 3037 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
| 3038 | 74, 75, 0, 199, 77, 78, 79, 80, 81, 82, |
| 3039 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3040 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3041 | 0, 90, 519, 0, 91, 0, 399, 92, 0, 93, |
| 3042 | 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, |
| 3043 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 93, |
| 3044 | 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, |
| 3045 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
| 3046 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3047 | 0, 0, 90, 0, 0, 91, 0, 0, 92, 0, |
| 3048 | 93, 74, 75, 89, 199, 77, 78, 79, 80, 81, |
| 3049 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 3050 | 21, 74, 75, 0, 199, 208, 209, 210, 211, 212, |
| 3051 | 213, 214, 215, 216, 217, 218, 0, 88, 20, 0, |
| 3052 | 21, 0, 0, 0, 89, 0, 0, 0, 0, 90, |
| 3053 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 3054 | 0, 0, 74, 75, 89, 229, 77, 78, 79, 80, |
| 3055 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 3056 | 0, 21, 74, 75, 0, 199, 208, 209, 210, 211, |
| 3057 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 3058 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 90, |
| 3059 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 3060 | 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3061 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3062 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3063 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3064 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3065 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3066 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3067 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3068 | 0, 0, 0, 0, 114, 0, 0, 0, 0, 0, |
| 3069 | 0, 90, 0, 0, 91, 0, 0, 92, 115, 93, |
| 3070 | 0, 0, 0, 0, 0, 0, 0, 0, 116, 117, |
| 3071 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 402, |
| 3072 | 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 3073 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3074 | 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3075 | 147, 148, 149, 150, 151, 152, 153, 0, 0, 154, |
| 3076 | 155, 156, 157, 158, 159, 160, 161, 162, 0, 0, |
| 3077 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3078 | 0, 0, 0, 0, 0, 0, 0, 0, 163, 164, |
| 3079 | 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 3080 | 175 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3081 | }; |
| 3082 | |
| 3083 | static const short int yycheck[] = |
| 3084 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3085 | 45, 120, 115, 63, 120, 118, 107, 274, 4, 23, |
| 3086 | 29, 3, 161, 0, 121, 164, 30, 558, 63, 93, |
| 3087 | 5, 6, 15, 8, 9, 10, 11, 12, 13, 14, |
| 3088 | 15, 16, 17, 18, 19, 15, 21, 22, 579, 24, |
| 3089 | 153, 33, 23, 156, 157, 158, 159, 160, 161, 162, |
| 3090 | 578, 10, 11, 12, 13, 14, 15, 16, 17, 104, |
| 3091 | 105, 106, 590, 48, 57, 152, 179, 180, 306, 307, |
| 3092 | 115, 153, 153, 118, 326, 327, 183, 57, 34, 161, |
| 3093 | 5, 6, 163, 8, 9, 10, 11, 12, 13, 14, |
| 3094 | 15, 16, 17, 18, 19, 347, 21, 22, 336, 24, |
| 3095 | 159, 57, 52, 53, 54, 164, 151, 152, 153, 154, |
| 3096 | 155, 156, 157, 158, 159, 160, 161, 162, 110, 153, |
| 3097 | 22, 71, 24, 48, 198, 9, 153, 161, 153, 203, |
| 3098 | 155, 176, 177, 178, 179, 180, 163, 21, 163, 164, |
| 3099 | 153, 231, 232, 162, 61, 153, 159, 198, 61, 163, |
| 3100 | 402, 159, 203, 243, 10, 11, 12, 13, 14, 15, |
| 3101 | 16, 17, 0, 153, 153, 24, 162, 155, 45, 154, |
| 3102 | 47, 157, 157, 163, 163, 160, 164, 162, 163, 152, |
| 3103 | 293, 47, 48, 49, 244, 152, 276, 25, 32, 33, |
| 3104 | 55, 56, 152, 31, 108, 109, 286, 287, 288, 244, |
| 3105 | 159, 27, 28, 41, 42, 43, 44, 45, 46, 47, |
| 3106 | 255, 3, 4, 3, 4, 3, 4, 455, 152, 486, |
| 3107 | 152, 488, 296, 297, 62, 4, 300, 272, 24, 154, |
| 3108 | 4, 291, 157, 3, 4, 160, 155, 162, 163, 64, |
| 3109 | 65, 66, 67, 68, 69, 70, 291, 292, 293, 3, |
| 3110 | 4, 24, 365, 20, 367, 368, 369, 77, 78, 24, |
| 3111 | 4, 4, 375, 155, 59, 355, 356, 357, 158, 158, |
| 3112 | 4, 4, 4, 363, 41, 42, 43, 44, 45, 46, |
| 3113 | 47, 4, 7, 50, 4, 7, 7, 377, 378, 157, |
| 3114 | 153, 155, 337, 394, 395, 396, 397, 398, 153, 153, |
| 3115 | 153, 153, 153, 159, 153, 153, 407, 408, 409, 410, |
| 3116 | 411, 153, 386, 153, 153, 24, 161, 36, 153, 156, |
| 3117 | 365, 366, 367, 368, 369, 370, 371, 155, 402, 153, |
| 3118 | 375, 376, 155, 155, 155, 24, 426, 155, 428, 155, |
| 3119 | 155, 155, 432, 155, 155, 63, 153, 153, 153, 157, |
| 3120 | 440, 441, 442, 153, 153, 456, 457, 161, 155, 153, |
| 3121 | 153, 24, 463, 21, 222, 156, 155, 153, 226, 21, |
| 3122 | 155, 153, 153, 231, 232, 4, 153, 153, 153, 4, |
| 3123 | 493, 494, 495, 155, 429, 243, 24, 153, 36, 153, |
| 3124 | 153, 481, 482, 153, 484, 485, 153, 153, 153, 161, |
| 3125 | 153, 491, 447, 153, 34, 153, 507, 508, 509, 510, |
| 3126 | 500, 153, 153, 514, 515, 516, 517, 153, 276, 156, |
| 3127 | 533, 161, 414, 153, 153, 57, 24, 153, 286, 287, |
| 3128 | 288, 57, 477, 157, 4, 21, 153, 153, 483, 558, |
| 3129 | 541, 542, 558, 156, 159, 535, 156, 153, 493, 494, |
| 3130 | 495, 156, 156, 156, 499, 156, 27, 28, 156, 156, |
| 3131 | 579, 36, 156, 579, 159, 566, 156, 568, 569, 21, |
| 3132 | 156, 156, 156, 518, 119, 120, 121, 122, 123, 124, |
| 3133 | 125, 126, 127, 128, 153, 21, 576, 153, 533, 10, |
| 3134 | 11, 12, 13, 14, 15, 16, 17, 355, 356, 357, |
| 3135 | 65, 591, 21, 21, 65, 363, 65, 65, 598, 318, |
| 3136 | 65, 33, 602, 603, 25, 478, 319, 44, 108, 377, |
| 3137 | 378, 3, 222, 477, 19, 597, 429, 499, 458, -1, |
| 3138 | -1, -1, -1, -1, 5, 6, -1, 8, 9, 10, |
| 3139 | 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, |
| 3140 | 21, 22, -1, 24, 125, 126, 127, 128, 129, 130, |
| 3141 | 131, 132, 133, 134, 135, 136, 137, 138, 426, -1, |
| 3142 | 428, 5, 6, -1, 432, -1, -1, 48, -1, -1, |
| 3143 | -1, -1, 440, 441, 442, -1, -1, 20, 22, 22, |
| 3144 | 24, 24, 26, -1, -1, -1, -1, -1, 31, 32, |
| 3145 | 33, -1, -1, -1, 38, 39, -1, -1, 41, 42, |
| 3146 | 43, 44, 45, 46, 47, -1, -1, 50, 51, -1, |
| 3147 | -1, -1, -1, 481, 482, 58, 484, 485, -1, 62, |
| 3148 | -1, -1, -1, 491, -1, -1, -1, -1, -1, -1, |
| 3149 | -1, -1, 500, -1, -1, 79, 80, 81, 82, 83, |
| 3150 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3151 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3152 | 104, -1, -1, -1, -1, -1, 110, 535, 112, -1, |
| 3153 | 114, 115, 116, 154, -1, -1, 157, -1, -1, 160, |
| 3154 | -1, 162, 163, -1, -1, -1, -1, -1, -1, -1, |
| 3155 | -1, -1, -1, -1, -1, 139, 140, 141, 142, 143, |
| 3156 | 144, 145, 146, 147, 148, 149, 150, 151, 576, -1, |
| 3157 | -1, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3158 | -1, 165, -1, 591, -1, -1, -1, -1, -1, -1, |
| 3159 | 598, -1, -1, -1, 602, 603, 5, 6, -1, 8, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3160 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3161 | 19, -1, 21, 22, -1, 24, -1, -1, -1, 3, |
| 3162 | 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, |
| 3163 | -1, -1, -1, -1, -1, -1, -1, -1, 22, 48, |
| 3164 | 24, -1, 26, 27, 28, -1, -1, -1, -1, -1, |
| 3165 | -1, -1, -1, -1, 38, 39, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3166 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3167 | -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, |
| 3168 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3169 | -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, |
| 3170 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3171 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3172 | 104, -1, -1, -1, -1, -1, 110, -1, 112, -1, |
| 3173 | 114, 115, 116, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3174 | -1, -1, -1, -1, -1, 154, 3, 4, 157, -1, |
| 3175 | 7, 160, -1, 162, 163, 139, 140, 141, 142, 143, |
| 3176 | 144, 145, 146, 147, 148, 149, 150, 151, -1, 26, |
| 3177 | 27, 28, -1, -1, -1, -1, 160, -1, -1, -1, |
| 3178 | -1, 38, 39, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3179 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3180 | -1, -1, -1, -1, 61, -1, -1, -1, -1, -1, |
| 3181 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3182 | -1, -1, 79, 80, 81, 82, 83, 84, 85, 86, |
| 3183 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 3184 | 97, 98, 99, 100, 101, 102, 103, 104, -1, -1, |
| 3185 | -1, -1, -1, 110, -1, 112, -1, 114, 115, 116, |
| 3186 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3187 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3188 | -1, -1, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3189 | 147, 148, 149, 150, 151, -1, -1, -1, -1, -1, |
| 3190 | -1, 5, 6, 160, 8, 9, 10, 11, 12, 13, |
| 3191 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3192 | 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3193 | -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, |
| 3194 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3195 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3196 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3197 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3198 | -1, 24, -1, -1, -1, 48, -1, -1, -1, -1, |
| 3199 | -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, |
| 3200 | -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3201 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 3202 | 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3203 | -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, |
| 3204 | -1, -1, -1, -1, -1, -1, 48, -1, -1, -1, |
| 3205 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3206 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3207 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 3208 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3209 | -1, 154, 37, -1, 157, -1, 159, 160, -1, 162, |
| 3210 | -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3211 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3212 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3213 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3214 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3215 | -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3216 | 162, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 3217 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3218 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 3219 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3220 | 24, -1, -1, -1, 48, -1, -1, -1, -1, 154, |
| 3221 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3222 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 3223 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3224 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3225 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3226 | -1, 24, -1, -1, -1, 48, -1, -1, -1, 154, |
| 3227 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3228 | -1, -1, -1, -1, -1, 48, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3229 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3230 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3231 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3232 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3233 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3234 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3235 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3236 | -1, -1, -1, -1, 35, -1, -1, -1, -1, -1, |
| 3237 | -1, 154, -1, -1, 157, -1, -1, 160, 49, 162, |
| 3238 | -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, |
| 3239 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 3240 | -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 3241 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 3242 | 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, |
| 3243 | 101, 102, 103, 104, 105, 106, 107, -1, -1, 110, |
| 3244 | 111, 112, 113, 114, 115, 116, 117, 118, -1, -1, |
| 3245 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3246 | -1, -1, -1, -1, -1, -1, -1, -1, 139, 140, |
| 3247 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, |
| 3248 | 151 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3249 | }; |
| 3250 | |
| 3251 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 3252 | symbol of state STATE-NUM. */ |
| 3253 | static const unsigned char yystos[] = |
| 3254 | { |
| 3255 | 0, 200, 201, 202, 0, 25, 31, 41, 42, 43, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3256 | 44, 45, 46, 47, 62, 181, 219, 222, 224, 232, |
| 3257 | 22, 24, 51, 58, 62, 180, 212, 224, 225, 61, |
| 3258 | 220, 23, 233, 234, 30, 163, 221, 233, 52, 53, |
| 3259 | 54, 71, 209, 152, 61, 20, 45, 47, 50, 181, |
| 3260 | 152, 45, 47, 223, 24, 207, 64, 65, 66, 67, |
| 3261 | 68, 69, 70, 182, 217, 180, 238, 152, 152, 152, |
| 3262 | 152, 157, 210, 207, 5, 6, 8, 9, 10, 11, |
| 3263 | 12, 13, 14, 15, 16, 17, 18, 19, 21, 48, |
| 3264 | 154, 157, 160, 162, 167, 189, 190, 191, 192, 193, |
| 3265 | 212, 229, 32, 33, 199, 199, 199, 199, 226, 4, |
| 3266 | 189, 29, 162, 218, 35, 49, 59, 60, 72, 73, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3267 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 3268 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3269 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3270 | 104, 105, 106, 107, 110, 111, 112, 113, 114, 115, |
| 3271 | 116, 117, 118, 139, 140, 141, 142, 143, 144, 145, |
| 3272 | 146, 147, 148, 149, 150, 151, 169, 170, 171, 174, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3273 | 175, 235, 236, 242, 243, 245, 246, 24, 55, 56, |
| 3274 | 208, 4, 24, 24, 211, 4, 4, 4, 162, 8, |
| 3275 | 163, 193, 194, 155, 164, 191, 191, 191, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3276 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 176, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3277 | 177, 179, 191, 196, 217, 212, 191, 231, 59, 8, |
| 3278 | 231, 9, 21, 10, 11, 12, 13, 14, 15, 16, |
| 3279 | 17, 176, 177, 178, 182, 119, 120, 121, 122, 123, |
| 3280 | 124, 125, 126, 127, 128, 172, 27, 28, 125, 126, |
| 3281 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3282 | 137, 138, 173, 191, 191, 231, 191, 191, 239, 231, |
| 3283 | 231, 231, 231, 231, 231, 231, 191, 191, 191, 231, |
| 3284 | 231, 182, 108, 109, 153, 159, 158, 158, 163, 194, |
| 3285 | 153, 163, 37, 194, 195, 205, 206, 204, 27, 28, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3286 | 3, 4, 168, 4, 7, 26, 38, 39, 103, 104, |
| 3287 | 110, 112, 114, 115, 116, 157, 160, 162, 165, 169, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3288 | 170, 171, 174, 175, 197, 229, 203, 155, 3, 4, |
| 3289 | 7, 26, 27, 28, 38, 39, 61, 160, 197, 228, |
| 3290 | 229, 230, 230, 230, 230, 189, 191, 191, 153, 184, |
| 3291 | 153, 184, 230, 157, 153, 153, 153, 153, 153, 153, |
| 3292 | 153, 153, 230, 230, 230, 153, 36, 189, 191, 231, |
| 3293 | 24, 193, 193, 161, 163, 193, 153, 156, 153, 187, |
| 3294 | 187, 187, 172, 173, 155, 155, 155, 155, 155, 159, |
| 3295 | 196, 198, 162, 198, 163, 198, 24, 155, 155, 155, |
| 3296 | 155, 155, 187, 37, 191, 214, 215, 216, 63, 227, |
| 3297 | 198, 153, 153, 230, 230, 230, 15, 57, 15, 153, |
| 3298 | 244, 230, 157, 231, 191, 231, 231, 231, 191, 191, |
| 3299 | 153, 153, 153, 231, 191, 230, 230, 153, 159, 161, |
| 3300 | 161, 37, 34, 57, 185, 188, 155, 155, 196, 196, |
| 3301 | 196, 196, 196, 153, 159, 163, 193, 198, 161, 163, |
| 3302 | 196, 196, 196, 196, 196, 212, 213, 153, 156, 24, |
| 3303 | 161, 21, 21, 155, 153, 153, 230, 4, 230, 231, |
| 3304 | 240, 153, 230, 153, 153, 153, 230, 230, 230, 155, |
| 3305 | 191, 24, 4, 187, 196, 196, 244, 153, 153, 153, |
| 3306 | 153, 196, 161, 163, 153, 153, 153, 153, 36, 37, |
| 3307 | 214, 185, 186, 153, 230, 230, 240, 241, 230, 230, |
| 3308 | 153, 184, 184, 153, 230, 153, 231, 231, 231, 241, |
| 3309 | 230, 153, 153, 156, 196, 196, 196, 196, 161, 196, |
| 3310 | 196, 196, 196, 191, 57, 183, 24, 153, 157, 156, |
| 3311 | 231, 159, 230, 156, 196, 196, 153, 156, 153, 153, |
| 3312 | 156, 156, 156, 156, 156, 4, 21, 159, 178, 237, |
| 3313 | 36, 159, 156, 156, 196, 196, 196, 230, 228, 159, |
| 3314 | 178, 21, 156, 156, 156, 153, 228, 230, 21, 153, |
| 3315 | 235, 230, 21, 21, 230, 230 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3316 | }; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3317 | |
| 3318 | #define yyerrok (yyerrstatus = 0) |
| 3319 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3320 | #define YYEMPTY (-2) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3321 | #define YYEOF 0 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3322 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3323 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3324 | #define YYABORT goto yyabortlab |
| 3325 | #define YYERROR goto yyerrorlab |
| 3326 | |
| 3327 | |
| 3328 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 3329 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3330 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3331 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3332 | #define YYFAIL goto yyerrlab |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3333 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3334 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3335 | |
| 3336 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3337 | do \ |
| 3338 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3339 | { \ |
| 3340 | yychar = (Token); \ |
| 3341 | yylval = (Value); \ |
| 3342 | yytoken = YYTRANSLATE (yychar); \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3343 | YYPOPSTACK; \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3344 | goto yybackup; \ |
| 3345 | } \ |
| 3346 | else \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3347 | { \ |
| 3348 | yyerror (YY_("syntax error: cannot back up")); \ |
| 3349 | YYERROR; \ |
| 3350 | } \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3351 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3352 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3353 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3354 | #define YYTERROR 1 |
| 3355 | #define YYERRCODE 256 |
| 3356 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3357 | |
| 3358 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 3359 | If N is 0, then set CURRENT to the empty location which ends |
| 3360 | the previous symbol: RHS[0] (always defined). */ |
| 3361 | |
| 3362 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 3363 | #ifndef YYLLOC_DEFAULT |
| 3364 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 3365 | do \ |
| 3366 | if (N) \ |
| 3367 | { \ |
| 3368 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 3369 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 3370 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 3371 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 3372 | } \ |
| 3373 | else \ |
| 3374 | { \ |
| 3375 | (Current).first_line = (Current).last_line = \ |
| 3376 | YYRHSLOC (Rhs, 0).last_line; \ |
| 3377 | (Current).first_column = (Current).last_column = \ |
| 3378 | YYRHSLOC (Rhs, 0).last_column; \ |
| 3379 | } \ |
| 3380 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3381 | #endif |
| 3382 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3383 | |
| 3384 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 3385 | This macro was not mandated originally: define only if we know |
| 3386 | we won't break user code: when these are the locations we know. */ |
| 3387 | |
| 3388 | #ifndef YY_LOCATION_PRINT |
| 3389 | # if YYLTYPE_IS_TRIVIAL |
| 3390 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 3391 | fprintf (File, "%d.%d-%d.%d", \ |
| 3392 | (Loc).first_line, (Loc).first_column, \ |
| 3393 | (Loc).last_line, (Loc).last_column) |
| 3394 | # else |
| 3395 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 3396 | # endif |
| 3397 | #endif |
| 3398 | |
| 3399 | |
| 3400 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 3401 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3402 | #ifdef YYLEX_PARAM |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3403 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3404 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3405 | # define YYLEX yylex () |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3406 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3407 | |
| 3408 | /* Enable debugging if requested. */ |
| 3409 | #if YYDEBUG |
| 3410 | |
| 3411 | # ifndef YYFPRINTF |
| 3412 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 3413 | # define YYFPRINTF fprintf |
| 3414 | # endif |
| 3415 | |
| 3416 | # define YYDPRINTF(Args) \ |
| 3417 | do { \ |
| 3418 | if (yydebug) \ |
| 3419 | YYFPRINTF Args; \ |
| 3420 | } while (0) |
| 3421 | |
| 3422 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 3423 | do { \ |
| 3424 | if (yydebug) \ |
| 3425 | { \ |
| 3426 | YYFPRINTF (stderr, "%s ", Title); \ |
| 3427 | yysymprint (stderr, \ |
| 3428 | Type, Value); \ |
| 3429 | YYFPRINTF (stderr, "\n"); \ |
| 3430 | } \ |
| 3431 | } while (0) |
| 3432 | |
| 3433 | /*------------------------------------------------------------------. |
| 3434 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 3435 | | TOP (included). | |
| 3436 | `------------------------------------------------------------------*/ |
| 3437 | |
| 3438 | #if defined (__STDC__) || defined (__cplusplus) |
| 3439 | static void |
| 3440 | yy_stack_print (short int *bottom, short int *top) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3441 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3442 | static void |
| 3443 | yy_stack_print (bottom, top) |
| 3444 | short int *bottom; |
| 3445 | short int *top; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3446 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3447 | { |
| 3448 | YYFPRINTF (stderr, "Stack now"); |
| 3449 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 3450 | YYFPRINTF (stderr, " %d", *bottom); |
| 3451 | YYFPRINTF (stderr, "\n"); |
| 3452 | } |
| 3453 | |
| 3454 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 3455 | do { \ |
| 3456 | if (yydebug) \ |
| 3457 | yy_stack_print ((Bottom), (Top)); \ |
| 3458 | } while (0) |
| 3459 | |
| 3460 | |
| 3461 | /*------------------------------------------------. |
| 3462 | | Report that the YYRULE is going to be reduced. | |
| 3463 | `------------------------------------------------*/ |
| 3464 | |
| 3465 | #if defined (__STDC__) || defined (__cplusplus) |
| 3466 | static void |
| 3467 | yy_reduce_print (int yyrule) |
| 3468 | #else |
| 3469 | static void |
| 3470 | yy_reduce_print (yyrule) |
| 3471 | int yyrule; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3472 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3473 | { |
| 3474 | int yyi; |
| 3475 | unsigned long int yylno = yyrline[yyrule]; |
| 3476 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", |
| 3477 | yyrule - 1, yylno); |
| 3478 | /* Print the symbols being reduced, and their result. */ |
| 3479 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 3480 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
| 3481 | YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); |
| 3482 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3483 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3484 | # define YY_REDUCE_PRINT(Rule) \ |
| 3485 | do { \ |
| 3486 | if (yydebug) \ |
| 3487 | yy_reduce_print (Rule); \ |
| 3488 | } while (0) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3489 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3490 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 3491 | multiple parsers can coexist. */ |
| 3492 | int yydebug; |
| 3493 | #else /* !YYDEBUG */ |
| 3494 | # define YYDPRINTF(Args) |
| 3495 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 3496 | # define YY_STACK_PRINT(Bottom, Top) |
| 3497 | # define YY_REDUCE_PRINT(Rule) |
| 3498 | #endif /* !YYDEBUG */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3499 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3500 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3501 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3502 | #ifndef YYINITDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3503 | # define YYINITDEPTH 200 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3504 | #endif |
| 3505 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3506 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 3507 | if the built-in stack extension method is used). |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3508 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3509 | Do not make this value too large; the results are undefined if |
| 3510 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 3511 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3512 | |
| 3513 | #ifndef YYMAXDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3514 | # define YYMAXDEPTH 10000 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3515 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3516 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3517 | |
| 3518 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3519 | #if YYERROR_VERBOSE |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3520 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3521 | # ifndef yystrlen |
| 3522 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 3523 | # define yystrlen strlen |
| 3524 | # else |
| 3525 | /* Return the length of YYSTR. */ |
| 3526 | static YYSIZE_T |
| 3527 | # if defined (__STDC__) || defined (__cplusplus) |
| 3528 | yystrlen (const char *yystr) |
| 3529 | # else |
| 3530 | yystrlen (yystr) |
| 3531 | const char *yystr; |
| 3532 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3533 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3534 | const char *yys = yystr; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3535 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3536 | while (*yys++ != '\0') |
| 3537 | continue; |
| 3538 | |
| 3539 | return yys - yystr - 1; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3540 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3541 | # endif |
| 3542 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3543 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3544 | # ifndef yystpcpy |
| 3545 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 3546 | # define yystpcpy stpcpy |
| 3547 | # else |
| 3548 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 3549 | YYDEST. */ |
| 3550 | static char * |
| 3551 | # if defined (__STDC__) || defined (__cplusplus) |
| 3552 | yystpcpy (char *yydest, const char *yysrc) |
| 3553 | # else |
| 3554 | yystpcpy (yydest, yysrc) |
| 3555 | char *yydest; |
| 3556 | const char *yysrc; |
| 3557 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3558 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3559 | char *yyd = yydest; |
| 3560 | const char *yys = yysrc; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3561 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3562 | while ((*yyd++ = *yys++) != '\0') |
| 3563 | continue; |
| 3564 | |
| 3565 | return yyd - 1; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3566 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3567 | # endif |
| 3568 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3569 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3570 | # ifndef yytnamerr |
| 3571 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 3572 | quotes and backslashes, so that it's suitable for yyerror. The |
| 3573 | heuristic is that double-quoting is unnecessary unless the string |
| 3574 | contains an apostrophe, a comma, or backslash (other than |
| 3575 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 3576 | null, do not copy; instead, return the length of what the result |
| 3577 | would have been. */ |
| 3578 | static YYSIZE_T |
| 3579 | yytnamerr (char *yyres, const char *yystr) |
| 3580 | { |
| 3581 | if (*yystr == '"') |
| 3582 | { |
| 3583 | size_t yyn = 0; |
| 3584 | char const *yyp = yystr; |
| 3585 | |
| 3586 | for (;;) |
| 3587 | switch (*++yyp) |
| 3588 | { |
| 3589 | case '\'': |
| 3590 | case ',': |
| 3591 | goto do_not_strip_quotes; |
| 3592 | |
| 3593 | case '\\': |
| 3594 | if (*++yyp != '\\') |
| 3595 | goto do_not_strip_quotes; |
| 3596 | /* Fall through. */ |
| 3597 | default: |
| 3598 | if (yyres) |
| 3599 | yyres[yyn] = *yyp; |
| 3600 | yyn++; |
| 3601 | break; |
| 3602 | |
| 3603 | case '"': |
| 3604 | if (yyres) |
| 3605 | yyres[yyn] = '\0'; |
| 3606 | return yyn; |
| 3607 | } |
| 3608 | do_not_strip_quotes: ; |
| 3609 | } |
| 3610 | |
| 3611 | if (! yyres) |
| 3612 | return yystrlen (yystr); |
| 3613 | |
| 3614 | return yystpcpy (yyres, yystr) - yyres; |
| 3615 | } |
| 3616 | # endif |
| 3617 | |
| 3618 | #endif /* YYERROR_VERBOSE */ |
| 3619 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3620 | |
| 3621 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3622 | #if YYDEBUG |
| 3623 | /*--------------------------------. |
| 3624 | | Print this symbol on YYOUTPUT. | |
| 3625 | `--------------------------------*/ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3626 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3627 | #if defined (__STDC__) || defined (__cplusplus) |
| 3628 | static void |
| 3629 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3630 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3631 | static void |
| 3632 | yysymprint (yyoutput, yytype, yyvaluep) |
| 3633 | FILE *yyoutput; |
| 3634 | int yytype; |
| 3635 | YYSTYPE *yyvaluep; |
| 3636 | #endif |
| 3637 | { |
| 3638 | /* Pacify ``unused variable'' warnings. */ |
| 3639 | (void) yyvaluep; |
| 3640 | |
| 3641 | if (yytype < YYNTOKENS) |
| 3642 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 3643 | else |
| 3644 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 3645 | |
| 3646 | |
| 3647 | # ifdef YYPRINT |
| 3648 | if (yytype < YYNTOKENS) |
| 3649 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 3650 | # endif |
| 3651 | switch (yytype) |
| 3652 | { |
| 3653 | default: |
| 3654 | break; |
| 3655 | } |
| 3656 | YYFPRINTF (yyoutput, ")"); |
| 3657 | } |
| 3658 | |
| 3659 | #endif /* ! YYDEBUG */ |
| 3660 | /*-----------------------------------------------. |
| 3661 | | Release the memory associated to this symbol. | |
| 3662 | `-----------------------------------------------*/ |
| 3663 | |
| 3664 | #if defined (__STDC__) || defined (__cplusplus) |
| 3665 | static void |
| 3666 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 3667 | #else |
| 3668 | static void |
| 3669 | yydestruct (yymsg, yytype, yyvaluep) |
| 3670 | const char *yymsg; |
| 3671 | int yytype; |
| 3672 | YYSTYPE *yyvaluep; |
| 3673 | #endif |
| 3674 | { |
| 3675 | /* Pacify ``unused variable'' warnings. */ |
| 3676 | (void) yyvaluep; |
| 3677 | |
| 3678 | if (!yymsg) |
| 3679 | yymsg = "Deleting"; |
| 3680 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 3681 | |
| 3682 | switch (yytype) |
| 3683 | { |
| 3684 | |
| 3685 | default: |
| 3686 | break; |
| 3687 | } |
| 3688 | } |
| 3689 | |
| 3690 | |
| 3691 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 3692 | |
| 3693 | #ifdef YYPARSE_PARAM |
| 3694 | # if defined (__STDC__) || defined (__cplusplus) |
| 3695 | int yyparse (void *YYPARSE_PARAM); |
| 3696 | # else |
| 3697 | int yyparse (); |
| 3698 | # endif |
| 3699 | #else /* ! YYPARSE_PARAM */ |
| 3700 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3701 | int yyparse (void); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3702 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3703 | int yyparse (); |
| 3704 | #endif |
| 3705 | #endif /* ! YYPARSE_PARAM */ |
| 3706 | |
| 3707 | |
| 3708 | |
| 3709 | /* The look-ahead symbol. */ |
| 3710 | int yychar; |
| 3711 | |
| 3712 | /* The semantic value of the look-ahead symbol. */ |
| 3713 | YYSTYPE yylval; |
| 3714 | |
| 3715 | /* Number of syntax errors so far. */ |
| 3716 | int yynerrs; |
| 3717 | |
| 3718 | |
| 3719 | |
| 3720 | /*----------. |
| 3721 | | yyparse. | |
| 3722 | `----------*/ |
| 3723 | |
| 3724 | #ifdef YYPARSE_PARAM |
| 3725 | # if defined (__STDC__) || defined (__cplusplus) |
| 3726 | int yyparse (void *YYPARSE_PARAM) |
| 3727 | # else |
| 3728 | int yyparse (YYPARSE_PARAM) |
| 3729 | void *YYPARSE_PARAM; |
| 3730 | # endif |
| 3731 | #else /* ! YYPARSE_PARAM */ |
| 3732 | #if defined (__STDC__) || defined (__cplusplus) |
| 3733 | int |
| 3734 | yyparse (void) |
| 3735 | #else |
| 3736 | int |
| 3737 | yyparse () |
| 3738 | |
| 3739 | #endif |
| 3740 | #endif |
| 3741 | { |
| 3742 | |
| 3743 | int yystate; |
| 3744 | int yyn; |
| 3745 | int yyresult; |
| 3746 | /* Number of tokens to shift before error messages enabled. */ |
| 3747 | int yyerrstatus; |
| 3748 | /* Look-ahead token as an internal (translated) token number. */ |
| 3749 | int yytoken = 0; |
| 3750 | |
| 3751 | /* Three stacks and their tools: |
| 3752 | `yyss': related to states, |
| 3753 | `yyvs': related to semantic values, |
| 3754 | `yyls': related to locations. |
| 3755 | |
| 3756 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 3757 | to reallocate them elsewhere. */ |
| 3758 | |
| 3759 | /* The state stack. */ |
| 3760 | short int yyssa[YYINITDEPTH]; |
| 3761 | short int *yyss = yyssa; |
| 3762 | short int *yyssp; |
| 3763 | |
| 3764 | /* The semantic value stack. */ |
| 3765 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 3766 | YYSTYPE *yyvs = yyvsa; |
| 3767 | YYSTYPE *yyvsp; |
| 3768 | |
| 3769 | |
| 3770 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3771 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3772 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3773 | YYSIZE_T yystacksize = YYINITDEPTH; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3774 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3775 | /* The variables used to return semantic value and location from the |
| 3776 | action routines. */ |
| 3777 | YYSTYPE yyval; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3778 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3779 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3780 | /* When reducing, the number of symbols on the RHS of the reduced |
| 3781 | rule. */ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3782 | int yylen; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3783 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3784 | YYDPRINTF ((stderr, "Starting parse\n")); |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3785 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3786 | yystate = 0; |
| 3787 | yyerrstatus = 0; |
| 3788 | yynerrs = 0; |
| 3789 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 3790 | |
| 3791 | /* Initialize stack pointers. |
| 3792 | Waste one element of value and location stack |
| 3793 | so that they stay on the same level as the state stack. |
| 3794 | The wasted elements are never initialized. */ |
| 3795 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3796 | yyssp = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3797 | yyvsp = yyvs; |
| 3798 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3799 | goto yysetstate; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3800 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3801 | /*------------------------------------------------------------. |
| 3802 | | yynewstate -- Push a new state, which is found in yystate. | |
| 3803 | `------------------------------------------------------------*/ |
| 3804 | yynewstate: |
| 3805 | /* In all cases, when you get here, the value and location stacks |
| 3806 | have just been pushed. so pushing a state here evens the stacks. |
| 3807 | */ |
| 3808 | yyssp++; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3809 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3810 | yysetstate: |
| 3811 | *yyssp = yystate; |
| 3812 | |
| 3813 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3814 | { |
| 3815 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3816 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3817 | |
| 3818 | #ifdef yyoverflow |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3819 | { |
| 3820 | /* Give user a chance to reallocate the stack. Use copies of |
| 3821 | these so that the &'s don't force the real ones into |
| 3822 | memory. */ |
| 3823 | YYSTYPE *yyvs1 = yyvs; |
| 3824 | short int *yyss1 = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3825 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3826 | |
| 3827 | /* Each stack pointer address is followed by the size of the |
| 3828 | data in use in that stack, in bytes. This used to be a |
| 3829 | conditional around just the two extra args, but that might |
| 3830 | be undefined if yyoverflow is a macro. */ |
| 3831 | yyoverflow (YY_("memory exhausted"), |
| 3832 | &yyss1, yysize * sizeof (*yyssp), |
| 3833 | &yyvs1, yysize * sizeof (*yyvsp), |
| 3834 | |
| 3835 | &yystacksize); |
| 3836 | |
| 3837 | yyss = yyss1; |
| 3838 | yyvs = yyvs1; |
| 3839 | } |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3840 | #else /* no yyoverflow */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3841 | # ifndef YYSTACK_RELOCATE |
| 3842 | goto yyexhaustedlab; |
| 3843 | # else |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3844 | /* Extend the stack our own way. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3845 | if (YYMAXDEPTH <= yystacksize) |
| 3846 | goto yyexhaustedlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3847 | yystacksize *= 2; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3848 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3849 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3850 | |
| 3851 | { |
| 3852 | short int *yyss1 = yyss; |
| 3853 | union yyalloc *yyptr = |
| 3854 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 3855 | if (! yyptr) |
| 3856 | goto yyexhaustedlab; |
| 3857 | YYSTACK_RELOCATE (yyss); |
| 3858 | YYSTACK_RELOCATE (yyvs); |
| 3859 | |
| 3860 | # undef YYSTACK_RELOCATE |
| 3861 | if (yyss1 != yyssa) |
| 3862 | YYSTACK_FREE (yyss1); |
| 3863 | } |
| 3864 | # endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3865 | #endif /* no yyoverflow */ |
| 3866 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3867 | yyssp = yyss + yysize - 1; |
| 3868 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3869 | |
| 3870 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3871 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 3872 | (unsigned long int) yystacksize)); |
| 3873 | |
| 3874 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3875 | YYABORT; |
| 3876 | } |
| 3877 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3878 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3879 | |
| 3880 | goto yybackup; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3881 | |
| 3882 | /*-----------. |
| 3883 | | yybackup. | |
| 3884 | `-----------*/ |
| 3885 | yybackup: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3886 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3887 | /* Do appropriate processing given the current state. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3888 | /* Read a look-ahead token if we need one and don't already have one. */ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3889 | /* yyresume: */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3890 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3891 | /* First try to decide what to do without reference to look-ahead token. */ |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3892 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3893 | yyn = yypact[yystate]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3894 | if (yyn == YYPACT_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3895 | goto yydefault; |
| 3896 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3897 | /* 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] | 3898 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3899 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3900 | if (yychar == YYEMPTY) |
| 3901 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3902 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3903 | yychar = YYLEX; |
| 3904 | } |
| 3905 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3906 | if (yychar <= YYEOF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3907 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3908 | yychar = yytoken = YYEOF; |
| 3909 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3910 | } |
| 3911 | else |
| 3912 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3913 | yytoken = YYTRANSLATE (yychar); |
| 3914 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3915 | } |
| 3916 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3917 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 3918 | detect an error, take that action. */ |
| 3919 | yyn += yytoken; |
| 3920 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3921 | goto yydefault; |
| 3922 | yyn = yytable[yyn]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3923 | if (yyn <= 0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3924 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3925 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3926 | goto yyerrlab; |
| 3927 | yyn = -yyn; |
| 3928 | goto yyreduce; |
| 3929 | } |
| 3930 | |
| 3931 | if (yyn == YYFINAL) |
| 3932 | YYACCEPT; |
| 3933 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3934 | /* Shift the look-ahead token. */ |
| 3935 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3936 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3937 | /* Discard the token being shifted unless it is eof. */ |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3938 | if (yychar != YYEOF) |
| 3939 | yychar = YYEMPTY; |
| 3940 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3941 | *++yyvsp = yylval; |
| 3942 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3943 | |
| 3944 | /* Count tokens shifted since error; after three, turn off error |
| 3945 | status. */ |
| 3946 | if (yyerrstatus) |
| 3947 | yyerrstatus--; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3948 | |
| 3949 | yystate = yyn; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3950 | goto yynewstate; |
| 3951 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3952 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3953 | /*-----------------------------------------------------------. |
| 3954 | | yydefault -- do the default action for the current state. | |
| 3955 | `-----------------------------------------------------------*/ |
| 3956 | yydefault: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3957 | yyn = yydefact[yystate]; |
| 3958 | if (yyn == 0) |
| 3959 | goto yyerrlab; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3960 | goto yyreduce; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3961 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3962 | |
| 3963 | /*-----------------------------. |
| 3964 | | yyreduce -- Do a reduction. | |
| 3965 | `-----------------------------*/ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3966 | yyreduce: |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3967 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3968 | yylen = yyr2[yyn]; |
| 3969 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3970 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3971 | `$$ = $1'. |
| 3972 | |
| 3973 | Otherwise, the following line sets YYVAL to garbage. |
| 3974 | This behavior is undocumented and Bison |
| 3975 | users should not rely upon it. Assigning to YYVAL |
| 3976 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3977 | GCC warning that YYVAL may be used uninitialized. */ |
| 3978 | yyval = yyvsp[1-yylen]; |
| 3979 | |
| 3980 | |
| 3981 | YY_REDUCE_PRINT (yyn); |
| 3982 | switch (yyn) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3983 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3984 | case 3: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 3985 | #line 1911 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3986 | { |
| 3987 | if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3988 | error("Value too large for type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3989 | (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); |
| 3990 | ;} |
| 3991 | break; |
| 3992 | |
| 3993 | case 5: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 3994 | #line 1920 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3995 | { |
| 3996 | if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3997 | error("Value too large for type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3998 | (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val); |
| 3999 | ;} |
| 4000 | break; |
| 4001 | |
| 4002 | case 26: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4003 | #line 1942 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4004 | { (yyval.IPred) = ICmpInst::ICMP_EQ; ;} |
| 4005 | break; |
| 4006 | |
| 4007 | case 27: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4008 | #line 1942 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4009 | { (yyval.IPred) = ICmpInst::ICMP_NE; ;} |
| 4010 | break; |
| 4011 | |
| 4012 | case 28: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4013 | #line 1943 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4014 | { (yyval.IPred) = ICmpInst::ICMP_SLT; ;} |
| 4015 | break; |
| 4016 | |
| 4017 | case 29: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4018 | #line 1943 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4019 | { (yyval.IPred) = ICmpInst::ICMP_SGT; ;} |
| 4020 | break; |
| 4021 | |
| 4022 | case 30: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4023 | #line 1944 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4024 | { (yyval.IPred) = ICmpInst::ICMP_SLE; ;} |
| 4025 | break; |
| 4026 | |
| 4027 | case 31: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4028 | #line 1944 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4029 | { (yyval.IPred) = ICmpInst::ICMP_SGE; ;} |
| 4030 | break; |
| 4031 | |
| 4032 | case 32: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4033 | #line 1945 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4034 | { (yyval.IPred) = ICmpInst::ICMP_ULT; ;} |
| 4035 | break; |
| 4036 | |
| 4037 | case 33: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4038 | #line 1945 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4039 | { (yyval.IPred) = ICmpInst::ICMP_UGT; ;} |
| 4040 | break; |
| 4041 | |
| 4042 | case 34: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4043 | #line 1946 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4044 | { (yyval.IPred) = ICmpInst::ICMP_ULE; ;} |
| 4045 | break; |
| 4046 | |
| 4047 | case 35: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4048 | #line 1946 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4049 | { (yyval.IPred) = ICmpInst::ICMP_UGE; ;} |
| 4050 | break; |
| 4051 | |
| 4052 | case 36: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4053 | #line 1950 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4054 | { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;} |
| 4055 | break; |
| 4056 | |
| 4057 | case 37: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4058 | #line 1950 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4059 | { (yyval.FPred) = FCmpInst::FCMP_ONE; ;} |
| 4060 | break; |
| 4061 | |
| 4062 | case 38: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4063 | #line 1951 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4064 | { (yyval.FPred) = FCmpInst::FCMP_OLT; ;} |
| 4065 | break; |
| 4066 | |
| 4067 | case 39: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4068 | #line 1951 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4069 | { (yyval.FPred) = FCmpInst::FCMP_OGT; ;} |
| 4070 | break; |
| 4071 | |
| 4072 | case 40: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4073 | #line 1952 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4074 | { (yyval.FPred) = FCmpInst::FCMP_OLE; ;} |
| 4075 | break; |
| 4076 | |
| 4077 | case 41: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4078 | #line 1952 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4079 | { (yyval.FPred) = FCmpInst::FCMP_OGE; ;} |
| 4080 | break; |
| 4081 | |
| 4082 | case 42: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4083 | #line 1953 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4084 | { (yyval.FPred) = FCmpInst::FCMP_ORD; ;} |
| 4085 | break; |
| 4086 | |
| 4087 | case 43: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4088 | #line 1953 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4089 | { (yyval.FPred) = FCmpInst::FCMP_UNO; ;} |
| 4090 | break; |
| 4091 | |
| 4092 | case 44: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4093 | #line 1954 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4094 | { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;} |
| 4095 | break; |
| 4096 | |
| 4097 | case 45: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4098 | #line 1954 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4099 | { (yyval.FPred) = FCmpInst::FCMP_UNE; ;} |
| 4100 | break; |
| 4101 | |
| 4102 | case 46: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4103 | #line 1955 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4104 | { (yyval.FPred) = FCmpInst::FCMP_ULT; ;} |
| 4105 | break; |
| 4106 | |
| 4107 | case 47: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4108 | #line 1955 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4109 | { (yyval.FPred) = FCmpInst::FCMP_UGT; ;} |
| 4110 | break; |
| 4111 | |
| 4112 | case 48: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4113 | #line 1956 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4114 | { (yyval.FPred) = FCmpInst::FCMP_ULE; ;} |
| 4115 | break; |
| 4116 | |
| 4117 | case 49: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4118 | #line 1956 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4119 | { (yyval.FPred) = FCmpInst::FCMP_UGE; ;} |
| 4120 | break; |
| 4121 | |
| 4122 | case 50: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4123 | #line 1957 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4124 | { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;} |
| 4125 | break; |
| 4126 | |
| 4127 | case 51: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4128 | #line 1958 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4129 | { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;} |
| 4130 | break; |
| 4131 | |
| 4132 | case 81: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4133 | #line 1989 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4134 | { |
| 4135 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
| 4136 | ;} |
| 4137 | break; |
| 4138 | |
| 4139 | case 82: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4140 | #line 1992 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4141 | { |
| 4142 | (yyval.StrVal) = 0; |
| 4143 | ;} |
| 4144 | break; |
| 4145 | |
| 4146 | case 83: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4147 | #line 1997 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4148 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 4149 | break; |
| 4150 | |
| 4151 | case 84: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4152 | #line 1998 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4153 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 4154 | break; |
| 4155 | |
| 4156 | case 85: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4157 | #line 1999 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4158 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 4159 | break; |
| 4160 | |
| 4161 | case 86: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4162 | #line 2000 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4163 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 4164 | break; |
| 4165 | |
| 4166 | case 87: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4167 | #line 2001 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4168 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 4169 | break; |
| 4170 | |
| 4171 | case 88: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4172 | #line 2002 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4173 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 4174 | break; |
| 4175 | |
| 4176 | case 89: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4177 | #line 2003 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4178 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 4179 | break; |
| 4180 | |
| 4181 | case 90: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4182 | #line 2004 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4183 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 4184 | break; |
| 4185 | |
| 4186 | case 91: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4187 | #line 2008 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4188 | { (yyval.UIntVal) = OldCallingConv::C; ;} |
| 4189 | break; |
| 4190 | |
| 4191 | case 92: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4192 | #line 2009 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4193 | { (yyval.UIntVal) = OldCallingConv::C; ;} |
| 4194 | break; |
| 4195 | |
| 4196 | case 93: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4197 | #line 2010 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4198 | { (yyval.UIntVal) = OldCallingConv::CSRet; ;} |
| 4199 | break; |
| 4200 | |
| 4201 | case 94: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4202 | #line 2011 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4203 | { (yyval.UIntVal) = OldCallingConv::Fast; ;} |
| 4204 | break; |
| 4205 | |
| 4206 | case 95: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4207 | #line 2012 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4208 | { (yyval.UIntVal) = OldCallingConv::Cold; ;} |
| 4209 | break; |
| 4210 | |
| 4211 | case 96: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4212 | #line 2013 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4213 | { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;} |
| 4214 | break; |
| 4215 | |
| 4216 | case 97: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4217 | #line 2014 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4218 | { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;} |
| 4219 | break; |
| 4220 | |
| 4221 | case 98: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4222 | #line 2015 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4223 | { |
| 4224 | if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4225 | error("Calling conv too large"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4226 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 4227 | ;} |
| 4228 | break; |
| 4229 | |
| 4230 | case 99: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4231 | #line 2025 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4232 | { (yyval.UIntVal) = 0; ;} |
| 4233 | break; |
| 4234 | |
| 4235 | case 100: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4236 | #line 2026 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4237 | { |
| 4238 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 4239 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4240 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4241 | ;} |
| 4242 | break; |
| 4243 | |
| 4244 | case 101: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4245 | #line 2034 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4246 | { (yyval.UIntVal) = 0; ;} |
| 4247 | break; |
| 4248 | |
| 4249 | case 102: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4250 | #line 2035 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4251 | { |
| 4252 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 4253 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4254 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4255 | ;} |
| 4256 | break; |
| 4257 | |
| 4258 | case 103: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4259 | #line 2043 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4260 | { |
| 4261 | for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) |
| 4262 | if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4263 | error("Invalid character in section name"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4264 | (yyval.StrVal) = (yyvsp[0].StrVal); |
| 4265 | ;} |
| 4266 | break; |
| 4267 | |
| 4268 | case 104: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4269 | #line 2052 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4270 | { (yyval.StrVal) = 0; ;} |
| 4271 | break; |
| 4272 | |
| 4273 | case 105: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4274 | #line 2053 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4275 | { (yyval.StrVal) = (yyvsp[0].StrVal); ;} |
| 4276 | break; |
| 4277 | |
| 4278 | case 106: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4279 | #line 2060 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4280 | {;} |
| 4281 | break; |
| 4282 | |
| 4283 | case 107: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4284 | #line 2061 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4285 | {;} |
| 4286 | break; |
| 4287 | |
| 4288 | case 108: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4289 | #line 2065 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4290 | { |
| 4291 | CurGV->setSection((yyvsp[0].StrVal)); |
| 4292 | free((yyvsp[0].StrVal)); |
| 4293 | ;} |
| 4294 | break; |
| 4295 | |
| 4296 | case 109: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4297 | #line 2069 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4298 | { |
| 4299 | if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4300 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4301 | CurGV->setAlignment((yyvsp[0].UInt64Val)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4302 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4303 | ;} |
| 4304 | break; |
| 4305 | |
| 4306 | case 111: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4307 | #line 2086 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4308 | { |
| 4309 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4310 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4311 | ;} |
| 4312 | break; |
| 4313 | |
| 4314 | case 113: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4315 | #line 2094 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4316 | { |
| 4317 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4318 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4319 | ;} |
| 4320 | break; |
| 4321 | |
| 4322 | case 114: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4323 | #line 2101 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4324 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4325 | if (!UpRefs.empty()) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4326 | error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription()); |
| 4327 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
| 4328 | ;} |
| 4329 | break; |
| 4330 | |
| 4331 | case 127: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4332 | #line 2115 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4333 | { |
| 4334 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4335 | (yyval.TypeVal).S.copy((yyvsp[0].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4336 | ;} |
| 4337 | break; |
| 4338 | |
| 4339 | case 128: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4340 | #line 2119 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4341 | { |
| 4342 | (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4343 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4344 | ;} |
| 4345 | break; |
| 4346 | |
| 4347 | case 129: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4348 | #line 2123 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4349 | { // Named types are also simple types... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4350 | (yyval.TypeVal).S.copy(getTypeSign((yyvsp[0].ValIDVal))); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4351 | const Type* tmp = getType((yyvsp[0].ValIDVal)); |
| 4352 | (yyval.TypeVal).PAT = new PATypeHolder(tmp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4353 | ;} |
| 4354 | break; |
| 4355 | |
| 4356 | case 130: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4357 | #line 2128 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4358 | { // Type UpReference |
| 4359 | if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4360 | error("Value out of range"); |
| 4361 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4362 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... |
| 4363 | (yyval.TypeVal).PAT = new PATypeHolder(OT); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4364 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4365 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4366 | ;} |
| 4367 | break; |
| 4368 | |
| 4369 | case 131: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4370 | #line 2137 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4371 | { // Function derived type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4372 | (yyval.TypeVal).S.makeComposite((yyvsp[-3].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4373 | std::vector<const Type*> Params; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4374 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 4375 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4376 | Params.push_back(I->PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4377 | (yyval.TypeVal).S.add(I->S); |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4378 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4379 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 4380 | if (isVarArg) Params.pop_back(); |
| 4381 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4382 | const FunctionType *FTy = |
| 4383 | FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg, 0); |
| 4384 | |
| 4385 | (yyval.TypeVal).PAT = new PATypeHolder( HandleUpRefs(FTy, (yyval.TypeVal).S) ); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4386 | delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4387 | delete (yyvsp[-1].TypeList); // Delete the argument list |
| 4388 | ;} |
| 4389 | break; |
| 4390 | |
| 4391 | case 132: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4392 | #line 2155 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4393 | { // Sized array type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4394 | (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4395 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).PAT->get(), |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4396 | (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4397 | delete (yyvsp[-1].TypeVal).PAT; |
| 4398 | ;} |
| 4399 | break; |
| 4400 | |
| 4401 | case 133: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4402 | #line 2161 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4403 | { // Vector type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4404 | const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get(); |
| 4405 | if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) |
| 4406 | error("Unsigned result not equal to signed result"); |
| 4407 | if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint())) |
| 4408 | error("Elements of a VectorType must be integer or floating point"); |
| 4409 | if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) |
| 4410 | error("VectorType length should be a power of 2"); |
| 4411 | (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
| 4412 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, |
| 4413 | (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S)); |
| 4414 | delete (yyvsp[-1].TypeVal).PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4415 | ;} |
| 4416 | break; |
| 4417 | |
| 4418 | case 134: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4419 | #line 2174 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4420 | { // Structure type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4421 | std::vector<const Type*> Elements; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4422 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4423 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(), |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4424 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4425 | Elements.push_back(I->PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4426 | (yyval.TypeVal).S.add(I->S); |
| 4427 | } |
| 4428 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4429 | delete (yyvsp[-1].TypeList); |
| 4430 | ;} |
| 4431 | break; |
| 4432 | |
| 4433 | case 135: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4434 | #line 2185 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4435 | { // Empty structure type? |
| 4436 | (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4437 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4438 | ;} |
| 4439 | break; |
| 4440 | |
| 4441 | case 136: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4442 | #line 2189 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4443 | { // Packed Structure type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4444 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4445 | std::vector<const Type*> Elements; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4446 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(), |
| 4447 | E = (yyvsp[-2].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4448 | Elements.push_back(I->PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4449 | (yyval.TypeVal).S.add(I->S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4450 | delete I->PAT; |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4451 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4452 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true), |
| 4453 | (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4454 | delete (yyvsp[-2].TypeList); |
| 4455 | ;} |
| 4456 | break; |
| 4457 | |
| 4458 | case 137: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4459 | #line 2202 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4460 | { // Empty packed structure type? |
| 4461 | (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4462 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4463 | ;} |
| 4464 | break; |
| 4465 | |
| 4466 | case 138: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4467 | #line 2206 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4468 | { // Pointer type? |
| 4469 | if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4470 | error("Cannot form a pointer to a basic block"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4471 | (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
| 4472 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get()), |
| 4473 | (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4474 | delete (yyvsp[-1].TypeVal).PAT; |
| 4475 | ;} |
| 4476 | break; |
| 4477 | |
| 4478 | case 139: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4479 | #line 2220 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4480 | { |
| 4481 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
| 4482 | (yyval.TypeList)->push_back((yyvsp[0].TypeVal)); |
| 4483 | ;} |
| 4484 | break; |
| 4485 | |
| 4486 | case 140: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4487 | #line 2224 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4488 | { |
| 4489 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal)); |
| 4490 | ;} |
| 4491 | break; |
| 4492 | |
| 4493 | case 142: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4494 | #line 2232 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4495 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4496 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4497 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4498 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4499 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI); |
| 4500 | ;} |
| 4501 | break; |
| 4502 | |
| 4503 | case 143: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4504 | #line 2238 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4505 | { |
| 4506 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4507 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4508 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4509 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4510 | (yyval.TypeList)->push_back(VoidTI); |
| 4511 | ;} |
| 4512 | break; |
| 4513 | |
| 4514 | case 144: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4515 | #line 2245 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4516 | { |
| 4517 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
| 4518 | ;} |
| 4519 | break; |
| 4520 | |
| 4521 | case 145: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4522 | #line 2257 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4523 | { // Nonempty unsized arr |
| 4524 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4525 | if (ATy == 0) |
| 4526 | error("Cannot make array constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4527 | (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4528 | const Type *ETy = ATy->getElementType(); |
| 4529 | int NumElements = ATy->getNumElements(); |
| 4530 | |
| 4531 | // Verify that we have the correct size... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4532 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4533 | error("Type mismatch: constant sized array initialized with " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4534 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4535 | itostr(NumElements) + ""); |
| 4536 | |
| 4537 | // Verify all elements are correct type! |
| 4538 | std::vector<Constant*> Elems; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4539 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4540 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4541 | const Type* ValTy = C->getType(); |
| 4542 | if (ETy != ValTy) |
| 4543 | error("Element #" + utostr(i) + " is not of type '" + |
| 4544 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4545 | ValTy->getDescription() + "'"); |
| 4546 | Elems.push_back(C); |
| 4547 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4548 | (yyval.ConstVal).C = ConstantArray::get(ATy, Elems); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4549 | (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4550 | delete (yyvsp[-3].TypeVal).PAT; |
| 4551 | delete (yyvsp[-1].ConstVector); |
| 4552 | ;} |
| 4553 | break; |
| 4554 | |
| 4555 | case 146: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4556 | #line 2287 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4557 | { |
| 4558 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4559 | if (ATy == 0) |
| 4560 | error("Cannot make array constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4561 | (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4562 | int NumElements = ATy->getNumElements(); |
| 4563 | if (NumElements != -1 && NumElements != 0) |
| 4564 | error("Type mismatch: constant sized array initialized with 0" |
| 4565 | " arguments, but has size of " + itostr(NumElements) +""); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4566 | (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4567 | (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4568 | delete (yyvsp[-2].TypeVal).PAT; |
| 4569 | ;} |
| 4570 | break; |
| 4571 | |
| 4572 | case 147: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4573 | #line 2300 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4574 | { |
| 4575 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4576 | if (ATy == 0) |
| 4577 | error("Cannot make array constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4578 | (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4579 | int NumElements = ATy->getNumElements(); |
| 4580 | const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType()); |
| 4581 | if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8) |
| 4582 | error("String arrays require type i8, not '" + ETy->getDescription() + |
| 4583 | "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4584 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4585 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4586 | error("Can't build string constant of size " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4587 | itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4588 | itostr(NumElements) + ""); |
| 4589 | std::vector<Constant*> Vals; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4590 | for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4591 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4592 | free((yyvsp[0].StrVal)); |
| 4593 | (yyval.ConstVal).C = ConstantArray::get(ATy, Vals); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4594 | (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4595 | delete (yyvsp[-2].TypeVal).PAT; |
| 4596 | ;} |
| 4597 | break; |
| 4598 | |
| 4599 | case 148: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4600 | #line 2323 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4601 | { // Nonempty unsized arr |
| 4602 | const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4603 | if (PTy == 0) |
| 4604 | error("Cannot make packed constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4605 | (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4606 | const Type *ETy = PTy->getElementType(); |
| 4607 | int NumElements = PTy->getNumElements(); |
| 4608 | // Verify that we have the correct size... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4609 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4610 | error("Type mismatch: constant sized packed initialized with " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4611 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4612 | itostr(NumElements) + ""); |
| 4613 | // Verify all elements are correct type! |
| 4614 | std::vector<Constant*> Elems; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4615 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4616 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4617 | const Type* ValTy = C->getType(); |
| 4618 | if (ETy != ValTy) |
| 4619 | error("Element #" + utostr(i) + " is not of type '" + |
| 4620 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4621 | ValTy->getDescription() + "'"); |
| 4622 | Elems.push_back(C); |
| 4623 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4624 | (yyval.ConstVal).C = ConstantVector::get(PTy, Elems); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4625 | (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4626 | delete (yyvsp[-3].TypeVal).PAT; |
| 4627 | delete (yyvsp[-1].ConstVector); |
| 4628 | ;} |
| 4629 | break; |
| 4630 | |
| 4631 | case 149: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4632 | #line 2351 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4633 | { |
| 4634 | const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4635 | if (STy == 0) |
| 4636 | error("Cannot make struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4637 | (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); |
| 4638 | if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4639 | error("Illegal number of initializers for structure type"); |
| 4640 | |
| 4641 | // Check to ensure that constants are compatible with the type initializer! |
| 4642 | std::vector<Constant*> Fields; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4643 | for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) { |
| 4644 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4645 | if (C->getType() != STy->getElementType(i)) |
| 4646 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4647 | "' for element #" + utostr(i) + " of structure initializer"); |
| 4648 | Fields.push_back(C); |
| 4649 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4650 | (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4651 | (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4652 | delete (yyvsp[-3].TypeVal).PAT; |
| 4653 | delete (yyvsp[-1].ConstVector); |
| 4654 | ;} |
| 4655 | break; |
| 4656 | |
| 4657 | case 150: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4658 | #line 2373 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4659 | { |
| 4660 | const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4661 | if (STy == 0) |
| 4662 | error("Cannot make struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4663 | (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4664 | if (STy->getNumContainedTypes() != 0) |
| 4665 | error("Illegal number of initializers for structure type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4666 | (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4667 | (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4668 | delete (yyvsp[-2].TypeVal).PAT; |
| 4669 | ;} |
| 4670 | break; |
| 4671 | |
| 4672 | case 151: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4673 | #line 2384 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4674 | { |
| 4675 | const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4676 | if (STy == 0) |
| 4677 | error("Cannot make packed struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4678 | (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'"); |
| 4679 | if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4680 | error("Illegal number of initializers for packed structure type"); |
| 4681 | |
| 4682 | // Check to ensure that constants are compatible with the type initializer! |
| 4683 | std::vector<Constant*> Fields; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4684 | for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) { |
| 4685 | Constant *C = (*(yyvsp[-2].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4686 | if (C->getType() != STy->getElementType(i)) |
| 4687 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4688 | "' for element #" + utostr(i) + " of packed struct initializer"); |
| 4689 | Fields.push_back(C); |
| 4690 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4691 | (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4692 | (yyval.ConstVal).S.copy((yyvsp[-5].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4693 | delete (yyvsp[-5].TypeVal).PAT; |
| 4694 | delete (yyvsp[-2].ConstVector); |
| 4695 | ;} |
| 4696 | break; |
| 4697 | |
| 4698 | case 152: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4699 | #line 2406 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4700 | { |
| 4701 | const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4702 | if (STy == 0) |
| 4703 | error("Cannot make packed struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4704 | (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4705 | if (STy->getNumContainedTypes() != 0) |
| 4706 | error("Illegal number of initializers for packed structure type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4707 | (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4708 | (yyval.ConstVal).S.copy((yyvsp[-4].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4709 | delete (yyvsp[-4].TypeVal).PAT; |
| 4710 | ;} |
| 4711 | break; |
| 4712 | |
| 4713 | case 153: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4714 | #line 2417 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4715 | { |
| 4716 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4717 | if (PTy == 0) |
| 4718 | error("Cannot make null pointer constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4719 | (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'"); |
| 4720 | (yyval.ConstVal).C = ConstantPointerNull::get(PTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4721 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4722 | delete (yyvsp[-1].TypeVal).PAT; |
| 4723 | ;} |
| 4724 | break; |
| 4725 | |
| 4726 | case 154: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4727 | #line 2426 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4728 | { |
| 4729 | (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4730 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4731 | delete (yyvsp[-1].TypeVal).PAT; |
| 4732 | ;} |
| 4733 | break; |
| 4734 | |
| 4735 | case 155: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4736 | #line 2431 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4737 | { |
| 4738 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4739 | if (Ty == 0) |
| 4740 | error("Global const reference must be a pointer type, not" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4741 | (yyvsp[-1].TypeVal).PAT->get()->getDescription()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4742 | |
| 4743 | // ConstExprs can exist in the body of a function, thus creating |
| 4744 | // GlobalValues whenever they refer to a variable. Because we are in |
| 4745 | // the context of a function, getExistingValue will search the functions |
| 4746 | // symbol table instead of the module symbol table for the global symbol, |
| 4747 | // which throws things all off. To get around this, we just tell |
| 4748 | // getExistingValue that we are at global scope here. |
| 4749 | // |
| 4750 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 4751 | CurFun.CurrentFunction = 0; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4752 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4753 | Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4754 | CurFun.CurrentFunction = SavedCurFn; |
| 4755 | |
| 4756 | // If this is an initializer for a constant pointer, which is referencing a |
| 4757 | // (currently) undefined variable, create a stub now that shall be replaced |
| 4758 | // in the future with the right type of variable. |
| 4759 | // |
| 4760 | if (V == 0) { |
| 4761 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers"); |
| 4762 | const PointerType *PT = cast<PointerType>(Ty); |
| 4763 | |
| 4764 | // First check to see if the forward references value is already created! |
| 4765 | PerModuleInfo::GlobalRefsType::iterator I = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4766 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4767 | |
| 4768 | if (I != CurModule.GlobalRefs.end()) { |
| 4769 | V = I->second; // Placeholder already exists, use it... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4770 | (yyvsp[0].ValIDVal).destroy(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4771 | } else { |
| 4772 | std::string Name; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4773 | if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4774 | |
| 4775 | // Create the forward referenced global. |
| 4776 | GlobalValue *GV; |
| 4777 | if (const FunctionType *FTy = |
| 4778 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 4779 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 4780 | CurModule.CurrentModule); |
| 4781 | } else { |
| 4782 | GV = new GlobalVariable(PT->getElementType(), false, |
| 4783 | GlobalValue::ExternalLinkage, 0, |
| 4784 | Name, CurModule.CurrentModule); |
| 4785 | } |
| 4786 | |
| 4787 | // Keep track of the fact that we have a forward ref to recycle it |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4788 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4789 | V = GV; |
| 4790 | } |
| 4791 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4792 | (yyval.ConstVal).C = cast<GlobalValue>(V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4793 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4794 | delete (yyvsp[-1].TypeVal).PAT; // Free the type handle |
| 4795 | ;} |
| 4796 | break; |
| 4797 | |
| 4798 | case 156: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4799 | #line 2490 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4800 | { |
| 4801 | if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4802 | error("Mismatched types for constant expression"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4803 | (yyval.ConstVal) = (yyvsp[0].ConstVal); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4804 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4805 | delete (yyvsp[-1].TypeVal).PAT; |
| 4806 | ;} |
| 4807 | break; |
| 4808 | |
| 4809 | case 157: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4810 | #line 2497 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4811 | { |
| 4812 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4813 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 4814 | error("Cannot create a null initialized value of this type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4815 | (yyval.ConstVal).C = Constant::getNullValue(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4816 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4817 | delete (yyvsp[-1].TypeVal).PAT; |
| 4818 | ;} |
| 4819 | break; |
| 4820 | |
| 4821 | case 158: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4822 | #line 2505 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4823 | { // integral constants |
| 4824 | const Type *Ty = (yyvsp[-1].PrimType).T; |
| 4825 | if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4826 | error("Constant value doesn't fit in type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4827 | (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4828 | (yyval.ConstVal).S.makeSigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4829 | ;} |
| 4830 | break; |
| 4831 | |
| 4832 | case 159: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4833 | #line 2512 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4834 | { // integral constants |
| 4835 | const Type *Ty = (yyvsp[-1].PrimType).T; |
| 4836 | if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4837 | error("Constant value doesn't fit in type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4838 | (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4839 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4840 | ;} |
| 4841 | break; |
| 4842 | |
| 4843 | case 160: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4844 | #line 2519 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4845 | { // Boolean constants |
| 4846 | (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4847 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4848 | ;} |
| 4849 | break; |
| 4850 | |
| 4851 | case 161: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4852 | #line 2523 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4853 | { // Boolean constants |
| 4854 | (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4855 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4856 | ;} |
| 4857 | break; |
| 4858 | |
| 4859 | case 162: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4860 | #line 2527 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4861 | { // Float & Double constants |
| 4862 | if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4863 | error("Floating point constant invalid for type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4864 | (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4865 | (yyval.ConstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4866 | ;} |
| 4867 | break; |
| 4868 | |
| 4869 | case 163: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4870 | #line 2536 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4871 | { |
| 4872 | const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType(); |
| 4873 | const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4874 | Signedness SrcSign((yyvsp[-3].ConstVal).S); |
| 4875 | Signedness DstSign((yyvsp[-1].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4876 | if (!SrcTy->isFirstClassType()) |
| 4877 | error("cast constant expression from a non-primitive type: '" + |
| 4878 | SrcTy->getDescription() + "'"); |
| 4879 | if (!DstTy->isFirstClassType()) |
| 4880 | error("cast constant expression to a non-primitive type: '" + |
| 4881 | DstTy->getDescription() + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4882 | (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4883 | (yyval.ConstVal).S.copy(DstSign); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4884 | delete (yyvsp[-1].TypeVal).PAT; |
| 4885 | ;} |
| 4886 | break; |
| 4887 | |
| 4888 | case 164: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4889 | #line 2551 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4890 | { |
| 4891 | const Type *Ty = (yyvsp[-2].ConstVal).C->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4892 | if (!isa<PointerType>(Ty)) |
| 4893 | error("GetElementPtr requires a pointer operand"); |
| 4894 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4895 | std::vector<Constant*> CIndices; |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4896 | upgradeGEPCEIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), CIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4897 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4898 | delete (yyvsp[-1].ValueList); |
| 4899 | (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, &CIndices[0], CIndices.size()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4900 | (yyval.ConstVal).S.copy(getElementSign((yyvsp[-2].ConstVal), CIndices)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4901 | ;} |
| 4902 | break; |
| 4903 | |
| 4904 | case 165: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4905 | #line 2563 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4906 | { |
| 4907 | if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() || |
| 4908 | cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4909 | error("Select condition must be bool type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4910 | if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4911 | error("Select operand types must match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4912 | (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4913 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4914 | ;} |
| 4915 | break; |
| 4916 | |
| 4917 | case 166: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4918 | #line 2572 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4919 | { |
| 4920 | const Type *Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4921 | if (Ty != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4922 | error("Binary operator types must match"); |
| 4923 | // First, make sure we're dealing with the right opcode by upgrading from |
| 4924 | // obsolete versions. |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4925 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4926 | |
| 4927 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 4928 | // To retain backward compatibility with these early compilers, we emit a |
| 4929 | // cast to the appropriate integer type automatically if we are in the |
| 4930 | // broken case. See PR424 for more information. |
| 4931 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4932 | (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4933 | } else { |
| 4934 | const Type *IntPtrTy = 0; |
| 4935 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 4936 | case Module::Pointer32: IntPtrTy = Type::Int32Ty; break; |
| 4937 | case Module::Pointer64: IntPtrTy = Type::Int64Ty; break; |
| 4938 | default: error("invalid pointer binary constant expr"); |
| 4939 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4940 | (yyval.ConstVal).C = ConstantExpr::get(Opcode, |
| 4941 | ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy), |
| 4942 | ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy)); |
| 4943 | (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4944 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4945 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4946 | ;} |
| 4947 | break; |
| 4948 | |
| 4949 | case 167: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4950 | #line 2600 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4951 | { |
| 4952 | const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4953 | if (Ty != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4954 | error("Logical operator types must match"); |
| 4955 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4956 | if (!isa<VectorType>(Ty) || |
| 4957 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4958 | error("Logical operator requires integer operands"); |
| 4959 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4960 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S); |
| 4961 | (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4962 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4963 | ;} |
| 4964 | break; |
| 4965 | |
| 4966 | case 168: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4967 | #line 2613 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4968 | { |
| 4969 | const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4970 | if (Ty != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4971 | error("setcc operand types must match"); |
| 4972 | unsigned short pred; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4973 | Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S); |
| 4974 | (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4975 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4976 | ;} |
| 4977 | break; |
| 4978 | |
| 4979 | case 169: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4980 | #line 2622 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4981 | { |
| 4982 | if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4983 | error("icmp operand types must match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4984 | (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4985 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4986 | ;} |
| 4987 | break; |
| 4988 | |
| 4989 | case 170: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 4990 | #line 2628 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4991 | { |
| 4992 | if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4993 | error("fcmp operand types must match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4994 | (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4995 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4996 | ;} |
| 4997 | break; |
| 4998 | |
| 4999 | case 171: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5000 | #line 2634 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5001 | { |
| 5002 | if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() || |
| 5003 | cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5004 | error("Shift count for shift constant must be unsigned byte"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5005 | const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 5006 | if (!(yyvsp[-3].ConstVal).C->getType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5007 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5008 | Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty); |
| 5009 | (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, ShiftAmt); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5010 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5011 | ;} |
| 5012 | break; |
| 5013 | |
| 5014 | case 172: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5015 | #line 2645 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5016 | { |
| 5017 | if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5018 | error("Invalid extractelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5019 | (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5020 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5021 | ;} |
| 5022 | break; |
| 5023 | |
| 5024 | case 173: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5025 | #line 2651 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5026 | { |
| 5027 | if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5028 | error("Invalid insertelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5029 | (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5030 | (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5031 | ;} |
| 5032 | break; |
| 5033 | |
| 5034 | case 174: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5035 | #line 2657 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5036 | { |
| 5037 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5038 | error("Invalid shufflevector operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5039 | (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5040 | (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5041 | ;} |
| 5042 | break; |
| 5043 | |
| 5044 | case 175: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5045 | #line 2668 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5046 | { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;} |
| 5047 | break; |
| 5048 | |
| 5049 | case 176: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5050 | #line 2669 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5051 | { |
| 5052 | (yyval.ConstVector) = new std::vector<ConstInfo>(); |
| 5053 | (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); |
| 5054 | ;} |
| 5055 | break; |
| 5056 | |
| 5057 | case 177: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5058 | #line 2678 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5059 | { (yyval.BoolVal) = false; ;} |
| 5060 | break; |
| 5061 | |
| 5062 | case 178: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5063 | #line 2679 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5064 | { (yyval.BoolVal) = true; ;} |
| 5065 | break; |
| 5066 | |
| 5067 | case 179: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5068 | #line 2691 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5069 | { |
| 5070 | (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5071 | CurModule.ModuleDone(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5072 | ;} |
| 5073 | break; |
| 5074 | |
| 5075 | case 180: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5076 | #line 2700 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5077 | { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;} |
| 5078 | break; |
| 5079 | |
| 5080 | case 181: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5081 | #line 2701 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5082 | { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;} |
| 5083 | break; |
| 5084 | |
| 5085 | case 182: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5086 | #line 2702 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5087 | { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;} |
| 5088 | break; |
| 5089 | |
| 5090 | case 183: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5091 | #line 2703 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5092 | { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;} |
| 5093 | break; |
| 5094 | |
| 5095 | case 184: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5096 | #line 2704 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5097 | { |
| 5098 | (yyval.ModuleVal) = CurModule.CurrentModule; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5099 | // Emit an error if there are any unresolved types left. |
| 5100 | if (!CurModule.LateResolveTypes.empty()) { |
| 5101 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 5102 | if (DID.Type == ValID::NameVal) { |
| 5103 | error("Reference to an undefined type: '"+DID.getName() + "'"); |
| 5104 | } else { |
| 5105 | error("Reference to an undefined type: #" + itostr(DID.Num)); |
| 5106 | } |
| 5107 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5108 | ;} |
| 5109 | break; |
| 5110 | |
| 5111 | case 185: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5112 | #line 2720 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5113 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5114 | // Eagerly resolve types. This is not an optimization, this is a |
| 5115 | // requirement that is due to the fact that we could have this: |
| 5116 | // |
| 5117 | // %list = type { %list * } |
| 5118 | // %list = type { %list * } ; repeated type decl |
| 5119 | // |
| 5120 | // If types are not resolved eagerly, then the two types will not be |
| 5121 | // determined to be the same type! |
| 5122 | // |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5123 | ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].TypeVal).PAT->get(), (yyvsp[0].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5124 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5125 | if (!setTypeName((yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
| 5126 | // If this is a numbered type that is not a redefinition, add it to the |
| 5127 | // slot table. |
| 5128 | CurModule.Types.push_back((yyvsp[0].TypeVal).PAT->get()); |
| 5129 | CurModule.TypeSigns.push_back((yyvsp[0].TypeVal).S); |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 5130 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5131 | delete (yyvsp[0].TypeVal).PAT; |
| 5132 | ;} |
| 5133 | break; |
| 5134 | |
| 5135 | case 186: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5136 | #line 2740 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5137 | { // Function prototypes can be in const pool |
| 5138 | ;} |
| 5139 | break; |
| 5140 | |
| 5141 | case 187: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5142 | #line 2742 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5143 | { // Asm blocks can be in the const pool |
| 5144 | ;} |
| 5145 | break; |
| 5146 | |
| 5147 | case 188: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5148 | #line 2744 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5149 | { |
| 5150 | if ((yyvsp[0].ConstVal).C == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5151 | error("Global value initializer is not a constant"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5152 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C, (yyvsp[0].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5153 | ;} |
| 5154 | break; |
| 5155 | |
| 5156 | case 189: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5157 | #line 2748 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5158 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5159 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5160 | ;} |
| 5161 | break; |
| 5162 | |
| 5163 | case 190: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5164 | #line 2751 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5165 | { |
| 5166 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5167 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0, |
| 5168 | (yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5169 | delete (yyvsp[0].TypeVal).PAT; |
| 5170 | ;} |
| 5171 | break; |
| 5172 | |
| 5173 | case 191: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5174 | #line 2756 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5175 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5176 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5177 | ;} |
| 5178 | break; |
| 5179 | |
| 5180 | case 192: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5181 | #line 2759 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5182 | { |
| 5183 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5184 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0, |
| 5185 | (yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5186 | delete (yyvsp[0].TypeVal).PAT; |
| 5187 | ;} |
| 5188 | break; |
| 5189 | |
| 5190 | case 193: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5191 | #line 2764 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5192 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5193 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5194 | ;} |
| 5195 | break; |
| 5196 | |
| 5197 | case 194: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5198 | #line 2767 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5199 | { |
| 5200 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5201 | CurGV = |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5202 | ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0, |
| 5203 | (yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5204 | delete (yyvsp[0].TypeVal).PAT; |
| 5205 | ;} |
| 5206 | break; |
| 5207 | |
| 5208 | case 195: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5209 | #line 2773 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5210 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5211 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5212 | ;} |
| 5213 | break; |
| 5214 | |
| 5215 | case 196: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5216 | #line 2776 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5217 | { |
| 5218 | ;} |
| 5219 | break; |
| 5220 | |
| 5221 | case 197: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5222 | #line 2778 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5223 | { |
| 5224 | ;} |
| 5225 | break; |
| 5226 | |
| 5227 | case 198: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5228 | #line 2780 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5229 | { |
| 5230 | ;} |
| 5231 | break; |
| 5232 | |
| 5233 | case 199: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5234 | #line 2785 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5235 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5236 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5237 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 5238 | std::string NewAsm((yyvsp[0].StrVal), EndStr); |
| 5239 | free((yyvsp[0].StrVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5240 | |
| 5241 | if (AsmSoFar.empty()) |
| 5242 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 5243 | else |
| 5244 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5245 | ;} |
| 5246 | break; |
| 5247 | |
| 5248 | case 200: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5249 | #line 2799 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5250 | { (yyval.Endianness) = Module::BigEndian; ;} |
| 5251 | break; |
| 5252 | |
| 5253 | case 201: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5254 | #line 2800 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5255 | { (yyval.Endianness) = Module::LittleEndian; ;} |
| 5256 | break; |
| 5257 | |
| 5258 | case 202: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5259 | #line 2804 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5260 | { |
| 5261 | CurModule.setEndianness((yyvsp[0].Endianness)); |
| 5262 | ;} |
| 5263 | break; |
| 5264 | |
| 5265 | case 203: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5266 | #line 2807 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5267 | { |
| 5268 | if ((yyvsp[0].UInt64Val) == 32) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5269 | CurModule.setPointerSize(Module::Pointer32); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5270 | else if ((yyvsp[0].UInt64Val) == 64) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5271 | CurModule.setPointerSize(Module::Pointer64); |
| 5272 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5273 | error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'"); |
| 5274 | ;} |
| 5275 | break; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5276 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5277 | case 204: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5278 | #line 2815 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5279 | { |
| 5280 | CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); |
| 5281 | free((yyvsp[0].StrVal)); |
| 5282 | ;} |
| 5283 | break; |
| 5284 | |
| 5285 | case 205: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5286 | #line 2819 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5287 | { |
| 5288 | CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); |
| 5289 | free((yyvsp[0].StrVal)); |
| 5290 | ;} |
| 5291 | break; |
| 5292 | |
| 5293 | case 207: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5294 | #line 2830 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5295 | { |
| 5296 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 5297 | free((yyvsp[0].StrVal)); |
| 5298 | ;} |
| 5299 | break; |
| 5300 | |
| 5301 | case 208: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5302 | #line 2834 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5303 | { |
| 5304 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 5305 | free((yyvsp[0].StrVal)); |
| 5306 | ;} |
| 5307 | break; |
| 5308 | |
| 5309 | case 209: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5310 | #line 2838 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5311 | { ;} |
| 5312 | break; |
| 5313 | |
| 5314 | case 213: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5315 | #line 2851 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5316 | { (yyval.StrVal) = 0; ;} |
| 5317 | break; |
| 5318 | |
| 5319 | case 214: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5320 | #line 2855 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5321 | { |
| 5322 | if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy) |
| 5323 | error("void typed arguments are invalid"); |
| 5324 | (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal)); |
| 5325 | ;} |
| 5326 | break; |
| 5327 | |
| 5328 | case 215: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5329 | #line 2863 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5330 | { |
| 5331 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 5332 | (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 5333 | delete (yyvsp[0].ArgVal); |
| 5334 | ;} |
| 5335 | break; |
| 5336 | |
| 5337 | case 216: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5338 | #line 2868 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5339 | { |
| 5340 | (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5341 | (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 5342 | delete (yyvsp[0].ArgVal); |
| 5343 | ;} |
| 5344 | break; |
| 5345 | |
| 5346 | case 217: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5347 | #line 2876 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5348 | { (yyval.ArgList) = (yyvsp[0].ArgList); ;} |
| 5349 | break; |
| 5350 | |
| 5351 | case 218: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5352 | #line 2877 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5353 | { |
| 5354 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 5355 | PATypeInfo VoidTI; |
| 5356 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5357 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5358 | (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 5359 | ;} |
| 5360 | break; |
| 5361 | |
| 5362 | case 219: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5363 | #line 2884 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5364 | { |
| 5365 | (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5366 | PATypeInfo VoidTI; |
| 5367 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5368 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5369 | (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 5370 | ;} |
| 5371 | break; |
| 5372 | |
| 5373 | case 220: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5374 | #line 2891 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5375 | { (yyval.ArgList) = 0; ;} |
| 5376 | break; |
| 5377 | |
| 5378 | case 221: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5379 | #line 2895 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5380 | { |
| 5381 | UnEscapeLexed((yyvsp[-5].StrVal)); |
| 5382 | std::string FunctionName((yyvsp[-5].StrVal)); |
| 5383 | free((yyvsp[-5].StrVal)); // Free strdup'd memory! |
| 5384 | |
| 5385 | const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5386 | |
| 5387 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 5388 | error("LLVM functions cannot return aggregate types"); |
| 5389 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5390 | Signedness FTySign; |
| 5391 | FTySign.makeComposite((yyvsp[-6].TypeVal).S); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5392 | std::vector<const Type*> ParamTyList; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5393 | |
| 5394 | // In LLVM 2.0 the signatures of three varargs intrinsics changed to take |
| 5395 | // i8*. We check here for those names and override the parameter list |
| 5396 | // types to ensure the prototype is correct. |
| 5397 | if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5398 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5399 | } else if (FunctionName == "llvm.va_copy") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5400 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
| 5401 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5402 | } else if ((yyvsp[-3].ArgList)) { // If there are arguments... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5403 | for (std::vector<std::pair<PATypeInfo,char*> >::iterator |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5404 | I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5405 | const Type *Ty = I->first.PAT->get(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5406 | ParamTyList.push_back(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5407 | FTySign.add(I->first.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5408 | } |
| 5409 | } |
| 5410 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5411 | bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy; |
| 5412 | if (isVarArg) |
| 5413 | ParamTyList.pop_back(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5414 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5415 | // Convert the CSRet calling convention into the corresponding parameter |
| 5416 | // attribute. |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5417 | ParamAttrsList *ParamAttrs = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5418 | if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) { |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5419 | ParamAttrs = new ParamAttrsList(); |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 5420 | ParamAttrs->addAttributes(0, ParamAttr::None); // result |
| 5421 | ParamAttrs->addAttributes(1, ParamAttr::StructRet); // first arg |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5422 | } |
| 5423 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5424 | const FunctionType *FT = |
| 5425 | FunctionType::get(RetTy, ParamTyList, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5426 | const PointerType *PFT = PointerType::get(FT); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5427 | delete (yyvsp[-6].TypeVal).PAT; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5428 | |
| 5429 | ValID ID; |
| 5430 | if (!FunctionName.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5431 | ID = ValID::create((char*)FunctionName.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5432 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5433 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5434 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5435 | ID.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5436 | |
| 5437 | Function *Fn = 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5438 | Module* M = CurModule.CurrentModule; |
| 5439 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5440 | // See if this function was forward referenced. If so, recycle the object. |
| 5441 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 5442 | // Move the function to the end of the list, from whereever it was |
| 5443 | // previously inserted. |
| 5444 | Fn = cast<Function>(FWRef); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5445 | M->getFunctionList().remove(Fn); |
| 5446 | M->getFunctionList().push_back(Fn); |
| 5447 | } else if (!FunctionName.empty()) { |
| 5448 | GlobalValue *Conflict = M->getFunction(FunctionName); |
| 5449 | if (!Conflict) |
| 5450 | Conflict = M->getNamedGlobal(FunctionName); |
| 5451 | if (Conflict && PFT == Conflict->getType()) { |
| 5452 | if (!CurFun.isDeclare && !Conflict->isDeclaration()) { |
| 5453 | // We have two function definitions that conflict, same type, same |
| 5454 | // name. We should really check to make sure that this is the result |
| 5455 | // of integer type planes collapsing and generate an error if it is |
| 5456 | // not, but we'll just rename on the assumption that it is. However, |
| 5457 | // let's do it intelligently and rename the internal linkage one |
| 5458 | // if there is one. |
| 5459 | std::string NewName(makeNameUnique(FunctionName)); |
| 5460 | if (Conflict->hasInternalLinkage()) { |
| 5461 | Conflict->setName(NewName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5462 | RenameMapKey Key = |
| 5463 | makeRenameMapKey(FunctionName, Conflict->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5464 | CurModule.RenameMap[Key] = NewName; |
| 5465 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5466 | InsertValue(Fn, CurModule.Values); |
| 5467 | } else { |
| 5468 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5469 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5470 | RenameMapKey Key = |
| 5471 | makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5472 | CurModule.RenameMap[Key] = NewName; |
| 5473 | } |
| 5474 | } else { |
| 5475 | // If they are not both definitions, then just use the function we |
| 5476 | // found since the types are the same. |
| 5477 | Fn = cast<Function>(Conflict); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5478 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5479 | // Make sure to strip off any argument names so we can't get |
| 5480 | // conflicts. |
| 5481 | if (Fn->isDeclaration()) |
| 5482 | for (Function::arg_iterator AI = Fn->arg_begin(), |
| 5483 | AE = Fn->arg_end(); AI != AE; ++AI) |
| 5484 | AI->setName(""); |
| 5485 | } |
| 5486 | } else if (Conflict) { |
| 5487 | // We have two globals with the same name and different types. |
| 5488 | // Previously, this was permitted because the symbol table had |
| 5489 | // "type planes" and names only needed to be distinct within a |
| 5490 | // type plane. After PR411 was fixed, this is no loner the case. |
| 5491 | // To resolve this we must rename one of the two. |
| 5492 | if (Conflict->hasInternalLinkage()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5493 | // We can safely rename the Conflict. |
| 5494 | RenameMapKey Key = |
| 5495 | makeRenameMapKey(Conflict->getName(), Conflict->getType(), |
| 5496 | CurModule.NamedValueSigns[Conflict->getName()]); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5497 | Conflict->setName(makeNameUnique(Conflict->getName())); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5498 | CurModule.RenameMap[Key] = Conflict->getName(); |
| 5499 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5500 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5501 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5502 | // We can't quietly rename either of these things, but we must |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5503 | // rename one of them. Only if the function's linkage is internal can |
| 5504 | // we forgo a warning message about the renamed function. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5505 | std::string NewName = makeNameUnique(FunctionName); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5506 | if (CurFun.Linkage != GlobalValue::InternalLinkage) { |
| 5507 | warning("Renaming function '" + FunctionName + "' as '" + NewName + |
| 5508 | "' may cause linkage errors"); |
| 5509 | } |
| 5510 | // Elect to rename the thing we're now defining. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5511 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5512 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5513 | RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5514 | CurModule.RenameMap[Key] = NewName; |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5515 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5516 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5517 | // There's no conflict, just define the function |
| 5518 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5519 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5520 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5521 | } |
| 5522 | |
| 5523 | CurFun.FunctionStart(Fn); |
| 5524 | |
| 5525 | if (CurFun.isDeclare) { |
| 5526 | // If we have declaration, always overwrite linkage. This will allow us |
| 5527 | // to correctly handle cases, when pointer to function is passed as |
| 5528 | // argument to another function. |
| 5529 | Fn->setLinkage(CurFun.Linkage); |
| 5530 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5531 | Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal))); |
| 5532 | Fn->setAlignment((yyvsp[0].UIntVal)); |
| 5533 | if ((yyvsp[-1].StrVal)) { |
| 5534 | Fn->setSection((yyvsp[-1].StrVal)); |
| 5535 | free((yyvsp[-1].StrVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5536 | } |
| 5537 | |
| 5538 | // Add all of the arguments we parsed to the function... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5539 | if ((yyvsp[-3].ArgList)) { // Is null if empty... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5540 | if (isVarArg) { // Nuke the last entry |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5541 | assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy && |
| 5542 | (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker"); |
| 5543 | delete (yyvsp[-3].ArgList)->back().first.PAT; |
| 5544 | (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5545 | } |
| 5546 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5547 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5548 | std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); |
| 5549 | std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5550 | for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5551 | delete I->first.PAT; // Delete the typeholder... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5552 | ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S); |
| 5553 | setValueName(VI, I->second); // Insert arg into symtab... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5554 | InsertValue(ArgIt); |
| 5555 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5556 | delete (yyvsp[-3].ArgList); // We're now done with the argument list |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5557 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5558 | ;} |
| 5559 | break; |
| 5560 | |
| 5561 | case 224: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5562 | #line 3081 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5563 | { CurFun.Linkage = (yyvsp[0].Linkage); ;} |
| 5564 | break; |
| 5565 | |
| 5566 | case 225: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5567 | #line 3081 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5568 | { |
| 5569 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5570 | |
| 5571 | // Make sure that we keep track of the linkage type even if there was a |
| 5572 | // previous "declare". |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5573 | (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5574 | ;} |
| 5575 | break; |
| 5576 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5577 | case 228: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5578 | #line 3095 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5579 | { |
| 5580 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 5581 | ;} |
| 5582 | break; |
| 5583 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5584 | case 229: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5585 | #line 3100 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5586 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 5587 | break; |
| 5588 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5589 | case 230: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5590 | #line 3101 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5591 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 5592 | break; |
| 5593 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5594 | case 231: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5595 | #line 3102 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5596 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 5597 | break; |
| 5598 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5599 | case 232: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5600 | #line 3106 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5601 | { CurFun.isDeclare = true; ;} |
| 5602 | break; |
| 5603 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5604 | case 233: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5605 | #line 3107 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5606 | { CurFun.Linkage = (yyvsp[0].Linkage); ;} |
| 5607 | break; |
| 5608 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5609 | case 234: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5610 | #line 3107 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5611 | { |
| 5612 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5613 | CurFun.FunctionDone(); |
| 5614 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5615 | ;} |
| 5616 | break; |
| 5617 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5618 | case 235: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5619 | #line 3119 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5620 | { (yyval.BoolVal) = false; ;} |
| 5621 | break; |
| 5622 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5623 | case 236: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5624 | #line 3120 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5625 | { (yyval.BoolVal) = true; ;} |
| 5626 | break; |
| 5627 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5628 | case 237: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5629 | #line 3125 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5630 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5631 | break; |
| 5632 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5633 | case 238: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5634 | #line 3126 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5635 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;} |
| 5636 | break; |
| 5637 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5638 | case 239: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5639 | #line 3127 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5640 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;} |
| 5641 | break; |
| 5642 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5643 | case 240: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5644 | #line 3128 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5645 | { |
| 5646 | (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); |
| 5647 | (yyval.ValIDVal).S.makeUnsigned(); |
| 5648 | ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5649 | break; |
| 5650 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5651 | case 241: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5652 | #line 3132 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5653 | { |
| 5654 | (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); |
| 5655 | (yyval.ValIDVal).S.makeUnsigned(); |
| 5656 | ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5657 | break; |
| 5658 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5659 | case 242: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5660 | #line 3136 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5661 | { (yyval.ValIDVal) = ValID::createNull(); ;} |
| 5662 | break; |
| 5663 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5664 | case 243: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5665 | #line 3137 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5666 | { (yyval.ValIDVal) = ValID::createUndef(); ;} |
| 5667 | break; |
| 5668 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5669 | case 244: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5670 | #line 3138 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5671 | { (yyval.ValIDVal) = ValID::createZeroInit(); ;} |
| 5672 | break; |
| 5673 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5674 | case 245: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5675 | #line 3139 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5676 | { // Nonempty unsized packed vector |
| 5677 | const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType(); |
| 5678 | int NumElements = (yyvsp[-1].ConstVector)->size(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5679 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5680 | (yyval.ValIDVal).S.makeComposite((*(yyvsp[-1].ConstVector))[0].S); |
| 5681 | PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5682 | |
| 5683 | // Verify all elements are correct type! |
| 5684 | std::vector<Constant*> Elems; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5685 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 5686 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5687 | const Type *CTy = C->getType(); |
| 5688 | if (ETy != CTy) |
| 5689 | error("Element #" + utostr(i) + " is not of type '" + |
| 5690 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 5691 | CTy->getDescription() + "'"); |
| 5692 | Elems.push_back(C); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 5693 | } |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5694 | (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5695 | delete PTy; delete (yyvsp[-1].ConstVector); |
| 5696 | ;} |
| 5697 | break; |
| 5698 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5699 | case 246: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5700 | #line 3160 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5701 | { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5702 | (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5703 | (yyval.ValIDVal).S.copy((yyvsp[0].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5704 | ;} |
| 5705 | break; |
| 5706 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5707 | case 247: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5708 | #line 3164 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5709 | { |
| 5710 | char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); |
| 5711 | std::string AsmStr = std::string((yyvsp[-2].StrVal), End); |
| 5712 | End = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 5713 | std::string Constraints = std::string((yyvsp[0].StrVal), End); |
| 5714 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); |
| 5715 | free((yyvsp[-2].StrVal)); |
| 5716 | free((yyvsp[0].StrVal)); |
| 5717 | ;} |
| 5718 | break; |
| 5719 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5720 | case 248: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5721 | #line 3178 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5722 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5723 | break; |
| 5724 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5725 | case 249: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5726 | #line 3179 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5727 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5728 | break; |
| 5729 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5730 | case 252: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5731 | #line 3192 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5732 | { |
| 5733 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5734 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5735 | (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5736 | (yyval.ValueVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5737 | delete (yyvsp[-1].TypeVal).PAT; |
| 5738 | ;} |
| 5739 | break; |
| 5740 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5741 | case 253: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5742 | #line 3202 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5743 | { |
| 5744 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 5745 | ;} |
| 5746 | break; |
| 5747 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5748 | case 254: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5749 | #line 3205 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5750 | { // Do not allow functions with 0 basic blocks |
| 5751 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 5752 | ;} |
| 5753 | break; |
| 5754 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5755 | case 255: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5756 | #line 3214 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5757 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5758 | ValueInfo VI; VI.V = (yyvsp[0].TermInstVal).TI; VI.S.copy((yyvsp[0].TermInstVal).S); |
| 5759 | setValueName(VI, (yyvsp[-1].StrVal)); |
| 5760 | InsertValue((yyvsp[0].TermInstVal).TI); |
| 5761 | (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal).TI); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5762 | InsertValue((yyvsp[-2].BasicBlockVal)); |
| 5763 | (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); |
| 5764 | ;} |
| 5765 | break; |
| 5766 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5767 | case 256: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5768 | #line 3225 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5769 | { |
| 5770 | if ((yyvsp[0].InstVal).I) |
| 5771 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I); |
| 5772 | (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); |
| 5773 | ;} |
| 5774 | break; |
| 5775 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5776 | case 257: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5777 | #line 3230 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5778 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5779 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5780 | // Make sure to move the basic block to the correct location in the |
| 5781 | // function, instead of leaving it inserted wherever it was first |
| 5782 | // referenced. |
| 5783 | Function::BasicBlockListType &BBL = |
| 5784 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5785 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
| 5786 | ;} |
| 5787 | break; |
| 5788 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5789 | case 258: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5790 | #line 3239 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5791 | { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5792 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5793 | // Make sure to move the basic block to the correct location in the |
| 5794 | // function, instead of leaving it inserted wherever it was first |
| 5795 | // referenced. |
| 5796 | Function::BasicBlockListType &BBL = |
| 5797 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5798 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
| 5799 | ;} |
| 5800 | break; |
| 5801 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5802 | case 261: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5803 | #line 3253 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5804 | { // Return with a result... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5805 | (yyval.TermInstVal).TI = new ReturnInst((yyvsp[0].ValueVal).V); |
| 5806 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5807 | ;} |
| 5808 | break; |
| 5809 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5810 | case 262: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5811 | #line 3257 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5812 | { // Return with no result... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5813 | (yyval.TermInstVal).TI = new ReturnInst(); |
| 5814 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5815 | ;} |
| 5816 | break; |
| 5817 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5818 | case 263: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5819 | #line 3261 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5820 | { // Unconditional Branch... |
| 5821 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5822 | (yyval.TermInstVal).TI = new BranchInst(tmpBB); |
| 5823 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5824 | ;} |
| 5825 | break; |
| 5826 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5827 | case 264: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5828 | #line 3266 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5829 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5830 | (yyvsp[-3].ValIDVal).S.makeSignless(); |
| 5831 | (yyvsp[0].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5832 | BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); |
| 5833 | BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5834 | (yyvsp[-6].ValIDVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5835 | Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5836 | (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 5837 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5838 | ;} |
| 5839 | break; |
| 5840 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5841 | case 265: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5842 | #line 3276 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5843 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5844 | (yyvsp[-6].ValIDVal).S.copy((yyvsp[-7].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5845 | Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5846 | (yyvsp[-3].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5847 | BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); |
| 5848 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5849 | (yyval.TermInstVal).TI = S; |
| 5850 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5851 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), |
| 5852 | E = (yyvsp[-1].JumpTable)->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5853 | for (; I != E; ++I) { |
| 5854 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 5855 | S->addCase(CI, I->second); |
| 5856 | else |
| 5857 | error("Switch case is constant, but not a simple integer"); |
| 5858 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5859 | delete (yyvsp[-1].JumpTable); |
| 5860 | ;} |
| 5861 | break; |
| 5862 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5863 | case 266: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5864 | #line 3294 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5865 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5866 | (yyvsp[-5].ValIDVal).S.copy((yyvsp[-6].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5867 | Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5868 | (yyvsp[-2].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5869 | BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5870 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5871 | (yyval.TermInstVal).TI = S; |
| 5872 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5873 | ;} |
| 5874 | break; |
| 5875 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5876 | case 267: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5877 | #line 3304 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5878 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5879 | const PointerType *PFTy; |
| 5880 | const FunctionType *Ty; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5881 | Signedness FTySign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5882 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5883 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5884 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5885 | // Pull out the types of all of the arguments... |
| 5886 | std::vector<const Type*> ParamTypes; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5887 | FTySign.makeComposite((yyvsp[-10].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5888 | if ((yyvsp[-7].ValueList)) { |
| 5889 | for (std::vector<ValueInfo>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5890 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5891 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5892 | FTySign.add(I->S); |
| 5893 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5894 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5895 | ParamAttrsList *ParamAttrs = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5896 | if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) { |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5897 | ParamAttrs = new ParamAttrsList(); |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 5898 | ParamAttrs->addAttributes(0, ParamAttr::None); // Function result |
| 5899 | ParamAttrs->addAttributes(1, ParamAttr::StructRet); // first param |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5900 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5901 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5902 | if (isVarArg) ParamTypes.pop_back(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5903 | Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5904 | PFTy = PointerType::get(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5905 | (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S); |
| 5906 | } else { |
| 5907 | FTySign = (yyvsp[-10].TypeVal).S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 5908 | // Get the signedness of the result type. $3 is the pointer to the |
| 5909 | // function type so we get the 0th element to extract the function type, |
| 5910 | // and then the 0th element again to get the result type. |
| 5911 | (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5912 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5913 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5914 | (yyvsp[-9].ValIDVal).S.makeComposite(FTySign); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5915 | Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling... |
| 5916 | BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); |
| 5917 | BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5918 | |
| 5919 | // Create the call node... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5920 | if (!(yyvsp[-7].ValueList)) { // Has no arguments? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5921 | (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, 0, 0); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5922 | } else { // Has arguments? |
| 5923 | // Loop through FunctionType's arguments and ensure they are specified |
| 5924 | // correctly! |
| 5925 | // |
| 5926 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5927 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5928 | std::vector<ValueInfo>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5929 | |
| 5930 | std::vector<Value*> Args; |
| 5931 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5932 | if ((*ArgI).V->getType() != *I) |
| 5933 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 5934 | (*I)->getDescription() + "'"); |
| 5935 | Args.push_back((*ArgI).V); |
| 5936 | } |
| 5937 | |
| 5938 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 5939 | error("Invalid number of parameters detected"); |
| 5940 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5941 | (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5942 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5943 | cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal))); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5944 | delete (yyvsp[-10].TypeVal).PAT; |
| 5945 | delete (yyvsp[-7].ValueList); |
| 5946 | ;} |
| 5947 | break; |
| 5948 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5949 | case 268: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5950 | #line 3373 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5951 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5952 | (yyval.TermInstVal).TI = new UnwindInst(); |
| 5953 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5954 | ;} |
| 5955 | break; |
| 5956 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5957 | case 269: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5958 | #line 3377 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5959 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5960 | (yyval.TermInstVal).TI = new UnreachableInst(); |
| 5961 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5962 | ;} |
| 5963 | break; |
| 5964 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5965 | case 270: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5966 | #line 3384 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5967 | { |
| 5968 | (yyval.JumpTable) = (yyvsp[-5].JumpTable); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5969 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5970 | Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5971 | |
| 5972 | if (V == 0) |
| 5973 | error("May only switch on a constant pool value"); |
| 5974 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5975 | (yyvsp[0].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5976 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 5977 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5978 | ;} |
| 5979 | break; |
| 5980 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5981 | case 271: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5982 | #line 3396 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5983 | { |
| 5984 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5985 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5986 | Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5987 | |
| 5988 | if (V == 0) |
| 5989 | error("May only switch on a constant pool value"); |
| 5990 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5991 | (yyvsp[0].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5992 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 5993 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5994 | ;} |
| 5995 | break; |
| 5996 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5997 | case 272: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 5998 | #line 3411 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5999 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6000 | bool omit = false; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6001 | if ((yyvsp[-1].StrVal)) |
| 6002 | if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6003 | if (BCI->getSrcTy() == BCI->getDestTy() && |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6004 | BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6005 | // This is a useless bit cast causing a name redefinition. It is |
| 6006 | // a bit cast from a type to the same type of an operand with the |
| 6007 | // same name as the name we would give this instruction. Since this |
| 6008 | // instruction results in no code generation, it is safe to omit |
| 6009 | // the instruction. This situation can occur because of collapsed |
| 6010 | // type planes. For example: |
| 6011 | // %X = add int %Y, %Z |
| 6012 | // %X = cast int %Y to uint |
| 6013 | // After upgrade, this looks like: |
| 6014 | // %X = add i32 %Y, %Z |
| 6015 | // %X = bitcast i32 to i32 |
| 6016 | // The bitcast is clearly useless so we omit it. |
| 6017 | omit = true; |
| 6018 | if (omit) { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6019 | (yyval.InstVal).I = 0; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6020 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6021 | } else { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6022 | ValueInfo VI; VI.V = (yyvsp[0].InstVal).I; VI.S.copy((yyvsp[0].InstVal).S); |
| 6023 | setValueName(VI, (yyvsp[-1].StrVal)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6024 | InsertValue((yyvsp[0].InstVal).I); |
| 6025 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6026 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6027 | ;} |
| 6028 | break; |
| 6029 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6030 | case 273: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6031 | #line 3441 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6032 | { // Used for PHI nodes |
| 6033 | (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6034 | (yyval.PHIList).S.copy((yyvsp[-5].TypeVal).S); |
| 6035 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-5].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6036 | Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6037 | (yyvsp[-1].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6038 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
| 6039 | (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 6040 | delete (yyvsp[-5].TypeVal).PAT; |
| 6041 | ;} |
| 6042 | break; |
| 6043 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6044 | case 274: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6045 | #line 3451 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6046 | { |
| 6047 | (yyval.PHIList) = (yyvsp[-6].PHIList); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6048 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-6].PHIList).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6049 | Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6050 | (yyvsp[-1].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6051 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
| 6052 | (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 6053 | ;} |
| 6054 | break; |
| 6055 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6056 | case 275: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6057 | #line 3461 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6058 | { // Used for call statements, and memory insts... |
| 6059 | (yyval.ValueList) = new std::vector<ValueInfo>(); |
| 6060 | (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); |
| 6061 | ;} |
| 6062 | break; |
| 6063 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6064 | case 276: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6065 | #line 3465 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6066 | { |
| 6067 | (yyval.ValueList) = (yyvsp[-2].ValueList); |
| 6068 | (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); |
| 6069 | ;} |
| 6070 | break; |
| 6071 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6072 | case 278: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6073 | #line 3473 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6074 | { (yyval.ValueList) = 0; ;} |
| 6075 | break; |
| 6076 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6077 | case 279: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6078 | #line 3477 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6079 | { |
| 6080 | (yyval.BoolVal) = true; |
| 6081 | ;} |
| 6082 | break; |
| 6083 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6084 | case 280: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6085 | #line 3480 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6086 | { |
| 6087 | (yyval.BoolVal) = false; |
| 6088 | ;} |
| 6089 | break; |
| 6090 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6091 | case 281: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6092 | #line 3486 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6093 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6094 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6095 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6096 | const Type* Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6097 | if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6098 | error("Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6099 | if (isa<VectorType>(Ty) && |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6100 | ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6101 | error("Remainder not supported on vector types"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6102 | // Upgrade the opcode from obsolete versions before we do anything with it. |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6103 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S); |
| 6104 | Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6105 | Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6106 | (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2); |
| 6107 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6108 | error("binary operator returned null"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6109 | (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6110 | delete (yyvsp[-3].TypeVal).PAT; |
| 6111 | ;} |
| 6112 | break; |
| 6113 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6114 | case 282: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6115 | #line 3505 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6116 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6117 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6118 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6119 | const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6120 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6121 | if (!isa<VectorType>(Ty) || |
| 6122 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6123 | error("Logical operator requires integral operands"); |
| 6124 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6125 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S); |
| 6126 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6127 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6128 | (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); |
| 6129 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6130 | error("binary operator returned null"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6131 | (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6132 | delete (yyvsp[-3].TypeVal).PAT; |
| 6133 | ;} |
| 6134 | break; |
| 6135 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6136 | case 283: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6137 | #line 3523 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6138 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6139 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6140 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6141 | const Type* Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6142 | if(isa<VectorType>(Ty)) |
| 6143 | error("VectorTypes currently not supported in setcc instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6144 | unsigned short pred; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6145 | Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S); |
| 6146 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6147 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6148 | (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); |
| 6149 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6150 | error("binary operator returned null"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6151 | (yyval.InstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6152 | delete (yyvsp[-3].TypeVal).PAT; |
| 6153 | ;} |
| 6154 | break; |
| 6155 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6156 | case 284: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6157 | #line 3539 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6158 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6159 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6160 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6161 | const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6162 | if (isa<VectorType>(Ty)) |
| 6163 | error("VectorTypes currently not supported in icmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6164 | else if (!Ty->isInteger() && !isa<PointerType>(Ty)) |
| 6165 | error("icmp requires integer or pointer typed operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6166 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6167 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6168 | (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6169 | (yyval.InstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6170 | delete (yyvsp[-3].TypeVal).PAT; |
| 6171 | ;} |
| 6172 | break; |
| 6173 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6174 | case 285: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6175 | #line 3553 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6176 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6177 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6178 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6179 | const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6180 | if (isa<VectorType>(Ty)) |
| 6181 | error("VectorTypes currently not supported in fcmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6182 | else if (!Ty->isFloatingPoint()) |
| 6183 | error("fcmp instruction requires floating point operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6184 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6185 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6186 | (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6187 | (yyval.InstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6188 | delete (yyvsp[-3].TypeVal).PAT; |
| 6189 | ;} |
| 6190 | break; |
| 6191 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6192 | case 286: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6193 | #line 3567 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6194 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6195 | warning("Use of obsolete 'not' instruction: Replacing with 'xor"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6196 | const Type *Ty = (yyvsp[0].ValueVal).V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6197 | Value *Ones = ConstantInt::getAllOnesValue(Ty); |
| 6198 | if (Ones == 0) |
| 6199 | error("Expected integral type for not instruction"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6200 | (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones); |
| 6201 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6202 | error("Could not create a xor instruction"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6203 | (yyval.InstVal).S.copy((yyvsp[0].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6204 | ;} |
| 6205 | break; |
| 6206 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6207 | case 287: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6208 | #line 3578 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6209 | { |
| 6210 | if (!(yyvsp[0].ValueVal).V->getType()->isInteger() || |
| 6211 | cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6212 | error("Shift amount must be int8"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6213 | const Type* Ty = (yyvsp[-2].ValueVal).V->getType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6214 | if (!Ty->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6215 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6216 | Value* ShiftAmt = 0; |
| 6217 | if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth()) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6218 | if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V)) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6219 | ShiftAmt = ConstantExpr::getZExt(C, Ty); |
| 6220 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6221 | ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6222 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6223 | ShiftAmt = (yyvsp[0].ValueVal).V; |
| 6224 | (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[-3].BinaryOpVal), Ty, (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, ShiftAmt); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6225 | (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6226 | ;} |
| 6227 | break; |
| 6228 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6229 | case 288: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6230 | #line 3596 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6231 | { |
| 6232 | const Type *DstTy = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6233 | if (!DstTy->isFirstClassType()) |
| 6234 | error("cast instruction to a non-primitive type: '" + |
| 6235 | DstTy->getDescription() + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6236 | (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6237 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6238 | delete (yyvsp[0].TypeVal).PAT; |
| 6239 | ;} |
| 6240 | break; |
| 6241 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6242 | case 289: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6243 | #line 3605 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6244 | { |
| 6245 | if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() || |
| 6246 | cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6247 | error("select condition must be bool"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6248 | if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6249 | error("select value types should match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6250 | (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6251 | (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6252 | ;} |
| 6253 | break; |
| 6254 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6255 | case 290: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6256 | #line 3614 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6257 | { |
| 6258 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6259 | NewVarArgs = true; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6260 | (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6261 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6262 | delete (yyvsp[0].TypeVal).PAT; |
| 6263 | ;} |
| 6264 | break; |
| 6265 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6266 | case 291: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6267 | #line 3621 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6268 | { |
| 6269 | const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType(); |
| 6270 | const Type* DstTy = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6271 | ObsoleteVarArgs = true; |
| 6272 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6273 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6274 | |
| 6275 | //b = vaarg a, t -> |
| 6276 | //foo = alloca 1 of t |
| 6277 | //bar = vacopy a |
| 6278 | //store bar -> foo |
| 6279 | //b = vaarg foo, t |
| 6280 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 6281 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6282 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6283 | CurBB->getInstList().push_back(bar); |
| 6284 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6285 | (yyval.InstVal).I = new VAArgInst(foo, DstTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6286 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6287 | delete (yyvsp[0].TypeVal).PAT; |
| 6288 | ;} |
| 6289 | break; |
| 6290 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6291 | case 292: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6292 | #line 3642 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6293 | { |
| 6294 | const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType(); |
| 6295 | const Type* DstTy = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6296 | ObsoleteVarArgs = true; |
| 6297 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6298 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6299 | |
| 6300 | //b = vanext a, t -> |
| 6301 | //foo = alloca 1 of t |
| 6302 | //bar = vacopy a |
| 6303 | //store bar -> foo |
| 6304 | //tmp = vaarg foo, t |
| 6305 | //b = load foo |
| 6306 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 6307 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6308 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6309 | CurBB->getInstList().push_back(bar); |
| 6310 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 6311 | Instruction* tmp = new VAArgInst(foo, DstTy); |
| 6312 | CurBB->getInstList().push_back(tmp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6313 | (yyval.InstVal).I = new LoadInst(foo); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6314 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6315 | delete (yyvsp[0].TypeVal).PAT; |
| 6316 | ;} |
| 6317 | break; |
| 6318 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6319 | case 293: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6320 | #line 3666 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6321 | { |
| 6322 | if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6323 | error("Invalid extractelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6324 | (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6325 | (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6326 | ;} |
| 6327 | break; |
| 6328 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6329 | case 294: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6330 | #line 3672 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6331 | { |
| 6332 | if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6333 | error("Invalid insertelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6334 | (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6335 | (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6336 | ;} |
| 6337 | break; |
| 6338 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6339 | case 295: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6340 | #line 3678 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6341 | { |
| 6342 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6343 | error("Invalid shufflevector operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6344 | (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6345 | (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6346 | ;} |
| 6347 | break; |
| 6348 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6349 | case 296: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6350 | #line 3684 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6351 | { |
| 6352 | const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6353 | if (!Ty->isFirstClassType()) |
| 6354 | error("PHI node operands must be of first class type"); |
| 6355 | PHINode *PHI = new PHINode(Ty); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6356 | PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size()); |
| 6357 | while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) { |
| 6358 | if ((yyvsp[0].PHIList).P->front().first->getType() != Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6359 | error("All elements of a PHI node must be of the same type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6360 | PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second); |
| 6361 | (yyvsp[0].PHIList).P->pop_front(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6362 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6363 | (yyval.InstVal).I = PHI; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6364 | (yyval.InstVal).S.copy((yyvsp[0].PHIList).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6365 | delete (yyvsp[0].PHIList).P; // Free the list... |
| 6366 | ;} |
| 6367 | break; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6368 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6369 | case 297: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6370 | #line 3700 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6371 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6372 | // Handle the short call syntax |
| 6373 | const PointerType *PFTy; |
| 6374 | const FunctionType *FTy; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6375 | Signedness FTySign; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6376 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6377 | !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 6378 | // Pull out the types of all of the arguments... |
| 6379 | std::vector<const Type*> ParamTypes; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6380 | FTySign.makeComposite((yyvsp[-4].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6381 | if ((yyvsp[-1].ValueList)) { |
| 6382 | for (std::vector<ValueInfo>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6383 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6384 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6385 | FTySign.add(I->S); |
| 6386 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6387 | } |
| 6388 | |
| 6389 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 6390 | if (isVarArg) ParamTypes.pop_back(); |
| 6391 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6392 | const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6393 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 6394 | error("Functions cannot return aggregate types"); |
| 6395 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 6396 | // Deal with CSRetCC |
| 6397 | ParamAttrsList *ParamAttrs = 0; |
| 6398 | if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) { |
| 6399 | ParamAttrs = new ParamAttrsList(); |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 6400 | ParamAttrs->addAttributes(0, ParamAttr::None); // function result |
| 6401 | ParamAttrs->addAttributes(1, ParamAttr::StructRet); // first parameter |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 6402 | } |
| 6403 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 6404 | FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6405 | PFTy = PointerType::get(FTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6406 | (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S); |
| 6407 | } else { |
| 6408 | FTySign = (yyvsp[-4].TypeVal).S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 6409 | // Get the signedness of the result type. $3 is the pointer to the |
| 6410 | // function type so we get the 0th element to extract the function type, |
| 6411 | // and then the 0th element again to get the result type. |
| 6412 | (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6413 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6414 | (yyvsp[-3].ValIDVal).S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6415 | |
| 6416 | // First upgrade any intrinsic calls. |
| 6417 | std::vector<Value*> Args; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6418 | if ((yyvsp[-1].ValueList)) |
| 6419 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i) |
| 6420 | Args.push_back((*(yyvsp[-1].ValueList))[i].V); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 6421 | Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[-3].ValIDVal), Args); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6422 | |
| 6423 | // If we got an upgraded intrinsic |
| 6424 | if (Inst) { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6425 | (yyval.InstVal).I = Inst; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6426 | } else { |
| 6427 | // Get the function we're calling |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6428 | Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6429 | |
| 6430 | // Check the argument values match |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6431 | if (!(yyvsp[-1].ValueList)) { // Has no arguments? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6432 | // Make sure no arguments is a good thing! |
| 6433 | if (FTy->getNumParams() != 0) |
| 6434 | error("No arguments passed to a function that expects arguments"); |
| 6435 | } else { // Has arguments? |
| 6436 | // Loop through FunctionType's arguments and ensure they are specified |
| 6437 | // correctly! |
| 6438 | // |
| 6439 | FunctionType::param_iterator I = FTy->param_begin(); |
| 6440 | FunctionType::param_iterator E = FTy->param_end(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6441 | std::vector<ValueInfo>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6442 | |
| 6443 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 6444 | if ((*ArgI).V->getType() != *I) |
| 6445 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 6446 | (*I)->getDescription() + "'"); |
| 6447 | |
| 6448 | if (I != E || (ArgI != ArgE && !FTy->isVarArg())) |
| 6449 | error("Invalid number of parameters detected"); |
| 6450 | } |
| 6451 | |
| 6452 | // Create the call instruction |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6453 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6454 | CI->setTailCall((yyvsp[-6].BoolVal)); |
| 6455 | CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal))); |
| 6456 | (yyval.InstVal).I = CI; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6457 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6458 | delete (yyvsp[-4].TypeVal).PAT; |
| 6459 | delete (yyvsp[-1].ValueList); |
| 6460 | ;} |
| 6461 | break; |
| 6462 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6463 | case 298: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6464 | #line 3790 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6465 | { |
| 6466 | (yyval.InstVal) = (yyvsp[0].InstVal); |
| 6467 | ;} |
| 6468 | break; |
| 6469 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6470 | case 299: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6471 | #line 3798 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6472 | { (yyval.ValueList) = (yyvsp[0].ValueList); ;} |
| 6473 | break; |
| 6474 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6475 | case 300: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6476 | #line 3799 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6477 | { (yyval.ValueList) = new std::vector<ValueInfo>(); ;} |
| 6478 | break; |
| 6479 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6480 | case 301: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6481 | #line 3803 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6482 | { (yyval.BoolVal) = true; ;} |
| 6483 | break; |
| 6484 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6485 | case 302: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6486 | #line 3804 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6487 | { (yyval.BoolVal) = false; ;} |
| 6488 | break; |
| 6489 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6490 | case 303: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6491 | #line 3808 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6492 | { |
| 6493 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6494 | (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6495 | (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal)); |
| 6496 | delete (yyvsp[-1].TypeVal).PAT; |
| 6497 | ;} |
| 6498 | break; |
| 6499 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6500 | case 304: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6501 | #line 3814 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6502 | { |
| 6503 | const Type *Ty = (yyvsp[-4].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6504 | (yyvsp[-1].ValIDVal).S.makeUnsigned(); |
| 6505 | (yyval.InstVal).S.makeComposite((yyvsp[-4].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6506 | (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal)); |
| 6507 | delete (yyvsp[-4].TypeVal).PAT; |
| 6508 | ;} |
| 6509 | break; |
| 6510 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6511 | case 305: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6512 | #line 3821 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6513 | { |
| 6514 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6515 | (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6516 | (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal)); |
| 6517 | delete (yyvsp[-1].TypeVal).PAT; |
| 6518 | ;} |
| 6519 | break; |
| 6520 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6521 | case 306: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6522 | #line 3827 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6523 | { |
| 6524 | const Type *Ty = (yyvsp[-4].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6525 | (yyvsp[-1].ValIDVal).S.makeUnsigned(); |
| 6526 | (yyval.InstVal).S.makeComposite((yyvsp[-2].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6527 | (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal)); |
| 6528 | delete (yyvsp[-4].TypeVal).PAT; |
| 6529 | ;} |
| 6530 | break; |
| 6531 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6532 | case 307: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6533 | #line 3834 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6534 | { |
| 6535 | const Type *PTy = (yyvsp[0].ValueVal).V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6536 | if (!isa<PointerType>(PTy)) |
| 6537 | error("Trying to free nonpointer type '" + PTy->getDescription() + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6538 | (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6539 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6540 | ;} |
| 6541 | break; |
| 6542 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6543 | case 308: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6544 | #line 3841 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6545 | { |
| 6546 | const Type* Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6547 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6548 | if (!isa<PointerType>(Ty)) |
| 6549 | error("Can't load from nonpointer type: " + Ty->getDescription()); |
| 6550 | if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType()) |
| 6551 | error("Can't load from pointer of non-first-class type: " + |
| 6552 | Ty->getDescription()); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6553 | Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6554 | (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6555 | (yyval.InstVal).S.copy((yyvsp[-1].TypeVal).S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6556 | delete (yyvsp[-1].TypeVal).PAT; |
| 6557 | ;} |
| 6558 | break; |
| 6559 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6560 | case 309: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6561 | #line 3854 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6562 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6563 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6564 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6565 | if (!PTy) |
| 6566 | error("Can't store to a nonpointer type: " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6567 | (yyvsp[-1].TypeVal).PAT->get()->getDescription()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6568 | const Type *ElTy = PTy->getElementType(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6569 | Value *StoreVal = (yyvsp[-3].ValueVal).V; |
| 6570 | Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal)); |
| 6571 | if (ElTy != (yyvsp[-3].ValueVal).V->getType()) { |
| 6572 | StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6573 | if (!StoreVal) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6574 | error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() + |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6575 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 6576 | else { |
| 6577 | PTy = PointerType::get(StoreVal->getType()); |
| 6578 | if (Constant *C = dyn_cast<Constant>(tmpVal)) |
| 6579 | tmpVal = ConstantExpr::getBitCast(C, PTy); |
| 6580 | else |
| 6581 | tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB); |
| 6582 | } |
| 6583 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6584 | (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6585 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6586 | delete (yyvsp[-1].TypeVal).PAT; |
| 6587 | ;} |
| 6588 | break; |
| 6589 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6590 | case 310: |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6591 | #line 3880 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6592 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6593 | (yyvsp[-1].ValIDVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6594 | const Type* Ty = (yyvsp[-2].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6595 | if (!isa<PointerType>(Ty)) |
| 6596 | error("getelementptr insn requires pointer operand"); |
| 6597 | |
| 6598 | std::vector<Value*> VIndices; |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6599 | upgradeGEPInstIndices(Ty, (yyvsp[0].ValueList), VIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6600 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6601 | Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal)); |
| 6602 | (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6603 | ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[-2].TypeVal).S); |
| 6604 | (yyval.InstVal).S.copy(getElementSign(VI, VIndices)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6605 | delete (yyvsp[-2].TypeVal).PAT; |
| 6606 | delete (yyvsp[0].ValueList); |
| 6607 | ;} |
| 6608 | break; |
| 6609 | |
| 6610 | |
| 6611 | default: break; |
| 6612 | } |
| 6613 | |
| 6614 | /* Line 1126 of yacc.c. */ |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6615 | #line 6616 "UpgradeParser.tab.c" |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6616 | |
| 6617 | yyvsp -= yylen; |
| 6618 | yyssp -= yylen; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 6619 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6620 | |
| 6621 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6622 | |
| 6623 | *++yyvsp = yyval; |
| 6624 | |
| 6625 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6626 | /* Now `shift' the result of the reduction. Determine what state |
| 6627 | that goes to, based on the state we popped back to and the rule |
| 6628 | number reduced by. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6629 | |
| 6630 | yyn = yyr1[yyn]; |
| 6631 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6632 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 6633 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6634 | yystate = yytable[yystate]; |
| 6635 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6636 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6637 | |
| 6638 | goto yynewstate; |
| 6639 | |
| 6640 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6641 | /*------------------------------------. |
| 6642 | | yyerrlab -- here on detecting error | |
| 6643 | `------------------------------------*/ |
| 6644 | yyerrlab: |
| 6645 | /* If not already recovering from an error, report this error. */ |
| 6646 | if (!yyerrstatus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6647 | { |
| 6648 | ++yynerrs; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6649 | #if YYERROR_VERBOSE |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6650 | yyn = yypact[yystate]; |
| 6651 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6652 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6653 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6654 | int yytype = YYTRANSLATE (yychar); |
| 6655 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 6656 | YYSIZE_T yysize = yysize0; |
| 6657 | YYSIZE_T yysize1; |
| 6658 | int yysize_overflow = 0; |
| 6659 | char *yymsg = 0; |
| 6660 | # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 |
| 6661 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 6662 | int yyx; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6663 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6664 | #if 0 |
| 6665 | /* This is so xgettext sees the translatable formats that are |
| 6666 | constructed on the fly. */ |
| 6667 | YY_("syntax error, unexpected %s"); |
| 6668 | YY_("syntax error, unexpected %s, expecting %s"); |
| 6669 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 6670 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 6671 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 6672 | #endif |
| 6673 | char *yyfmt; |
| 6674 | char const *yyf; |
| 6675 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 6676 | static char const yyexpecting[] = ", expecting %s"; |
| 6677 | static char const yyor[] = " or %s"; |
| 6678 | char yyformat[sizeof yyunexpected |
| 6679 | + sizeof yyexpecting - 1 |
| 6680 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 6681 | * (sizeof yyor - 1))]; |
| 6682 | char const *yyprefix = yyexpecting; |
| 6683 | |
| 6684 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 6685 | YYCHECK. */ |
| 6686 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 6687 | |
| 6688 | /* Stay within bounds of both yycheck and yytname. */ |
| 6689 | int yychecklim = YYLAST - yyn; |
| 6690 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 6691 | int yycount = 1; |
| 6692 | |
| 6693 | yyarg[0] = yytname[yytype]; |
| 6694 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 6695 | |
| 6696 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 6697 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 6698 | { |
| 6699 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 6700 | { |
| 6701 | yycount = 1; |
| 6702 | yysize = yysize0; |
| 6703 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 6704 | break; |
| 6705 | } |
| 6706 | yyarg[yycount++] = yytname[yyx]; |
| 6707 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 6708 | yysize_overflow |= yysize1 < yysize; |
| 6709 | yysize = yysize1; |
| 6710 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 6711 | yyprefix = yyor; |
| 6712 | } |
| 6713 | |
| 6714 | yyf = YY_(yyformat); |
| 6715 | yysize1 = yysize + yystrlen (yyf); |
| 6716 | yysize_overflow |= yysize1 < yysize; |
| 6717 | yysize = yysize1; |
| 6718 | |
| 6719 | if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) |
| 6720 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 6721 | if (yymsg) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6722 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6723 | /* Avoid sprintf, as that infringes on the user's name space. |
| 6724 | Don't have undefined behavior even if the translation |
| 6725 | produced a string with the wrong number of "%s"s. */ |
| 6726 | char *yyp = yymsg; |
| 6727 | int yyi = 0; |
| 6728 | while ((*yyp = *yyf)) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6729 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6730 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 6731 | { |
| 6732 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 6733 | yyf += 2; |
| 6734 | } |
| 6735 | else |
| 6736 | { |
| 6737 | yyp++; |
| 6738 | yyf++; |
| 6739 | } |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6740 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6741 | yyerror (yymsg); |
| 6742 | YYSTACK_FREE (yymsg); |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6743 | } |
| 6744 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6745 | { |
| 6746 | yyerror (YY_("syntax error")); |
| 6747 | goto yyexhaustedlab; |
| 6748 | } |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6749 | } |
| 6750 | else |
| 6751 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6752 | yyerror (YY_("syntax error")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6753 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6754 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6755 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6756 | |
| 6757 | if (yyerrstatus == 3) |
| 6758 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6759 | /* If just tried and failed to reuse look-ahead token after an |
| 6760 | error, discard it. */ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6761 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6762 | if (yychar <= YYEOF) |
| 6763 | { |
| 6764 | /* Return failure if at end of input. */ |
| 6765 | if (yychar == YYEOF) |
| 6766 | YYABORT; |
| 6767 | } |
| 6768 | else |
| 6769 | { |
| 6770 | yydestruct ("Error: discarding", yytoken, &yylval); |
| 6771 | yychar = YYEMPTY; |
| 6772 | } |
| 6773 | } |
| 6774 | |
| 6775 | /* Else will try to reuse look-ahead token after shifting the error |
| 6776 | token. */ |
| 6777 | goto yyerrlab1; |
| 6778 | |
| 6779 | |
| 6780 | /*---------------------------------------------------. |
| 6781 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 6782 | `---------------------------------------------------*/ |
| 6783 | yyerrorlab: |
| 6784 | |
| 6785 | /* Pacify compilers like GCC when the user code never invokes |
| 6786 | YYERROR and the label yyerrorlab therefore never appears in user |
| 6787 | code. */ |
| 6788 | if (0) |
| 6789 | goto yyerrorlab; |
| 6790 | |
| 6791 | yyvsp -= yylen; |
| 6792 | yyssp -= yylen; |
| 6793 | yystate = *yyssp; |
| 6794 | goto yyerrlab1; |
| 6795 | |
| 6796 | |
| 6797 | /*-------------------------------------------------------------. |
| 6798 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 6799 | `-------------------------------------------------------------*/ |
| 6800 | yyerrlab1: |
| 6801 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 6802 | |
| 6803 | for (;;) |
| 6804 | { |
| 6805 | yyn = yypact[yystate]; |
| 6806 | if (yyn != YYPACT_NINF) |
| 6807 | { |
| 6808 | yyn += YYTERROR; |
| 6809 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 6810 | { |
| 6811 | yyn = yytable[yyn]; |
| 6812 | if (0 < yyn) |
| 6813 | break; |
| 6814 | } |
| 6815 | } |
| 6816 | |
| 6817 | /* Pop the current state because it cannot handle the error token. */ |
| 6818 | if (yyssp == yyss) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6819 | YYABORT; |
| 6820 | |
| 6821 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6822 | yydestruct ("Error: popping", yystos[yystate], yyvsp); |
| 6823 | YYPOPSTACK; |
| 6824 | yystate = *yyssp; |
| 6825 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6826 | } |
| 6827 | |
| 6828 | if (yyn == YYFINAL) |
| 6829 | YYACCEPT; |
| 6830 | |
| 6831 | *++yyvsp = yylval; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6832 | |
| 6833 | |
| 6834 | /* Shift the error token. */ |
| 6835 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6836 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6837 | yystate = yyn; |
| 6838 | goto yynewstate; |
| 6839 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6840 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6841 | /*-------------------------------------. |
| 6842 | | yyacceptlab -- YYACCEPT comes here. | |
| 6843 | `-------------------------------------*/ |
| 6844 | yyacceptlab: |
| 6845 | yyresult = 0; |
| 6846 | goto yyreturn; |
| 6847 | |
| 6848 | /*-----------------------------------. |
| 6849 | | yyabortlab -- YYABORT comes here. | |
| 6850 | `-----------------------------------*/ |
| 6851 | yyabortlab: |
| 6852 | yyresult = 1; |
| 6853 | goto yyreturn; |
| 6854 | |
| 6855 | #ifndef yyoverflow |
| 6856 | /*-------------------------------------------------. |
| 6857 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 6858 | `-------------------------------------------------*/ |
| 6859 | yyexhaustedlab: |
| 6860 | yyerror (YY_("memory exhausted")); |
| 6861 | yyresult = 2; |
| 6862 | /* Fall through. */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6863 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6864 | |
| 6865 | yyreturn: |
| 6866 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 6867 | yydestruct ("Cleanup: discarding lookahead", |
| 6868 | yytoken, &yylval); |
| 6869 | while (yyssp != yyss) |
| 6870 | { |
| 6871 | yydestruct ("Cleanup: popping", |
| 6872 | yystos[*yyssp], yyvsp); |
| 6873 | YYPOPSTACK; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6874 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6875 | #ifndef yyoverflow |
| 6876 | if (yyss != yyssa) |
| 6877 | YYSTACK_FREE (yyss); |
| 6878 | #endif |
| 6879 | return yyresult; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6880 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6881 | |
| 6882 | |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 6883 | #line 3898 "/proj/llvm/llvm-2/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6884 | |
| 6885 | |
| 6886 | int yyerror(const char *ErrorMsg) { |
| 6887 | std::string where |
| 6888 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6889 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6890 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 6891 | if (yychar != YYEMPTY && yychar != 0) |
| 6892 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6893 | "'."; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 6894 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6895 | std::cout << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6896 | exit(1); |
| 6897 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6898 | |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 6899 | void warning(const std::string& ErrorMsg) { |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6900 | std::string where |
| 6901 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6902 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6903 | std::string errMsg = where + "warning: " + std::string(ErrorMsg); |
| 6904 | if (yychar != YYEMPTY && yychar != 0) |
| 6905 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6906 | "'."; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6907 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
| 6908 | } |
| 6909 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6910 | void error(const std::string& ErrorMsg, int LineNo) { |
| 6911 | if (LineNo == -1) LineNo = Upgradelineno; |
| 6912 | Upgradelineno = LineNo; |
| 6913 | yyerror(ErrorMsg.c_str()); |
| 6914 | } |
| 6915 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6916 | |