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. */ |
| 373 | #line 14 "/proj/llvm/llvm-1/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; |
| 751 | unsigned SRetMask = ~unsigned(StructRetAttribute); |
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(); |
| 796 | if (PAL2 && PAL2->paramHasAttr(1, StructRetAttribute)) |
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 | |
| 1137 | CurModule.NamedTypeSigns[Name] = Sign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1138 | |
| 1139 | std::map<ValID, PATypeHolder>::iterator I = |
| 1140 | CurModule.LateResolveTypes.find(D); |
| 1141 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1142 | const Type *OldTy = I->second.get(); |
| 1143 | ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1144 | CurModule.LateResolveTypes.erase(I); |
| 1145 | } |
| 1146 | } |
| 1147 | |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1148 | /// This is the implementation portion of TypeHasInteger. It traverses the |
| 1149 | /// type given, avoiding recursive types, and returns true as soon as it finds |
| 1150 | /// an integer type. If no integer type is found, it returns false. |
| 1151 | static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) { |
| 1152 | // Handle some easy cases |
| 1153 | if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID)) |
| 1154 | return false; |
| 1155 | if (Ty->isInteger()) |
| 1156 | return true; |
| 1157 | if (const SequentialType *STy = dyn_cast<SequentialType>(Ty)) |
| 1158 | return STy->getElementType()->isInteger(); |
| 1159 | |
| 1160 | // Avoid type structure recursion |
| 1161 | for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end(); |
| 1162 | I != E; ++I) |
| 1163 | if (Ty == *I) |
| 1164 | return false; |
| 1165 | |
| 1166 | // Push us on the type stack |
| 1167 | Stack.push_back(Ty); |
| 1168 | |
| 1169 | if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) { |
| 1170 | if (TypeHasIntegerI(FTy->getReturnType(), Stack)) |
| 1171 | return true; |
| 1172 | FunctionType::param_iterator I = FTy->param_begin(); |
| 1173 | FunctionType::param_iterator E = FTy->param_end(); |
| 1174 | for (; I != E; ++I) |
| 1175 | if (TypeHasIntegerI(*I, Stack)) |
| 1176 | return true; |
| 1177 | return false; |
| 1178 | } else if (const StructType *STy = dyn_cast<StructType>(Ty)) { |
| 1179 | StructType::element_iterator I = STy->element_begin(); |
| 1180 | StructType::element_iterator E = STy->element_end(); |
| 1181 | for (; I != E; ++I) { |
| 1182 | if (TypeHasIntegerI(*I, Stack)) |
| 1183 | return true; |
| 1184 | } |
| 1185 | return false; |
| 1186 | } |
| 1187 | // There shouldn't be anything else, but its definitely not integer |
| 1188 | assert(0 && "What type is this?"); |
| 1189 | return false; |
| 1190 | } |
| 1191 | |
| 1192 | /// This is the interface to TypeHasIntegerI. It just provides the type stack, |
| 1193 | /// to avoid recursion, and then calls TypeHasIntegerI. |
| 1194 | static inline bool TypeHasInteger(const Type *Ty) { |
| 1195 | std::vector<const Type*> TyStack; |
| 1196 | return TypeHasIntegerI(Ty, TyStack); |
| 1197 | } |
| 1198 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1199 | // setValueName - Set the specified value to the name given. The name may be |
| 1200 | // null potentially, in which case this is a noop. The string passed in is |
| 1201 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 1202 | // |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1203 | static void setValueName(const ValueInfo &V, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1204 | if (NameStr) { |
| 1205 | std::string Name(NameStr); // Copy string |
| 1206 | free(NameStr); // Free old string |
| 1207 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1208 | if (V.V->getType() == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1209 | error("Can't assign name '" + Name + "' to value with void type"); |
| 1210 | return; |
| 1211 | } |
| 1212 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1213 | assert(inFunctionScope() && "Must be in function scope"); |
| 1214 | |
| 1215 | // 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] | 1216 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 1217 | Value* Existing = ST.lookup(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1218 | if (Existing) { |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1219 | // An existing value of the same name was found. This might have happened |
| 1220 | // because of the integer type planes collapsing in LLVM 2.0. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1221 | if (Existing->getType() == V.V->getType() && |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1222 | !TypeHasInteger(Existing->getType())) { |
| 1223 | // If the type does not contain any integers in them then this can't be |
| 1224 | // a type plane collapsing issue. It truly is a redefinition and we |
| 1225 | // should error out as the assembly is invalid. |
| 1226 | error("Redefinition of value named '" + Name + "' of type '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1227 | V.V->getType()->getDescription() + "'"); |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1228 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1229 | } |
| 1230 | // In LLVM 2.0 we don't allow names to be re-used for any values in a |
| 1231 | // function, regardless of Type. Previously re-use of names was okay as |
| 1232 | // long as they were distinct types. With type planes collapsing because |
| 1233 | // of the signedness change and because of PR411, this can no longer be |
| 1234 | // supported. We must search the entire symbol table for a conflicting |
| 1235 | // name and make the name unique. No warning is needed as this can't |
| 1236 | // cause a problem. |
| 1237 | std::string NewName = makeNameUnique(Name); |
| 1238 | // We're changing the name but it will probably be used by other |
| 1239 | // instructions as operands later on. Consequently we have to retain |
| 1240 | // a mapping of the renaming that we're doing. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1241 | RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1242 | CurFun.RenameMap[Key] = NewName; |
| 1243 | Name = NewName; |
| 1244 | } |
| 1245 | |
| 1246 | // Set the name. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1247 | V.V->setName(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 1252 | /// this is a declaration, otherwise it is a definition. |
| 1253 | static GlobalVariable * |
| 1254 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 1255 | bool isConstantGlobal, const Type *Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1256 | Constant *Initializer, |
| 1257 | const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1258 | if (isa<FunctionType>(Ty)) |
| 1259 | error("Cannot declare global vars of function type"); |
| 1260 | |
| 1261 | const PointerType *PTy = PointerType::get(Ty); |
| 1262 | |
| 1263 | std::string Name; |
| 1264 | if (NameStr) { |
| 1265 | Name = NameStr; // Copy string |
| 1266 | free(NameStr); // Free old string |
| 1267 | } |
| 1268 | |
| 1269 | // See if this global value was forward referenced. If so, recycle the |
| 1270 | // object. |
| 1271 | ValID ID; |
| 1272 | if (!Name.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1273 | ID = ValID::create((char*)Name.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1274 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1275 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1276 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1277 | ID.S.makeComposite(Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1278 | |
| 1279 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1280 | // Move the global to the end of the list, from whereever it was |
| 1281 | // previously inserted. |
| 1282 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1283 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1284 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1285 | GV->setInitializer(Initializer); |
| 1286 | GV->setLinkage(Linkage); |
| 1287 | GV->setConstant(isConstantGlobal); |
| 1288 | InsertValue(GV, CurModule.Values); |
| 1289 | return GV; |
| 1290 | } |
| 1291 | |
| 1292 | // If this global has a name, check to see if there is already a definition |
| 1293 | // of this global in the module and emit warnings if there are conflicts. |
| 1294 | if (!Name.empty()) { |
| 1295 | // The global has a name. See if there's an existing one of the same name. |
| 1296 | if (CurModule.CurrentModule->getNamedGlobal(Name)) { |
| 1297 | // We found an existing global ov the same name. This isn't allowed |
| 1298 | // in LLVM 2.0. Consequently, we must alter the name of the global so it |
| 1299 | // can at least compile. This can happen because of type planes |
| 1300 | // There is alread a global of the same name which means there is a |
| 1301 | // conflict. Let's see what we can do about it. |
| 1302 | std::string NewName(makeNameUnique(Name)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1303 | if (Linkage != GlobalValue::InternalLinkage) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1304 | // The linkage of this gval is external so we can't reliably rename |
| 1305 | // it because it could potentially create a linking problem. |
| 1306 | // However, we can't leave the name conflict in the output either or |
| 1307 | // it won't assemble with LLVM 2.0. So, all we can do is rename |
| 1308 | // this one to something unique and emit a warning about the problem. |
| 1309 | warning("Renaming global variable '" + Name + "' to '" + NewName + |
| 1310 | "' may cause linkage errors"); |
| 1311 | } |
| 1312 | |
| 1313 | // Put the renaming in the global rename map |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1314 | RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1315 | CurModule.RenameMap[Key] = NewName; |
| 1316 | |
| 1317 | // Rename it |
| 1318 | Name = NewName; |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | // Otherwise there is no existing GV to use, create one now. |
| 1323 | GlobalVariable *GV = |
| 1324 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 1325 | CurModule.CurrentModule); |
| 1326 | InsertValue(GV, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1327 | // Remember the sign of this global. |
| 1328 | CurModule.NamedValueSigns[Name] = ID.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1329 | return GV; |
| 1330 | } |
| 1331 | |
| 1332 | // setTypeName - Set the specified type to the name given. The name may be |
| 1333 | // null potentially, in which case this is a noop. The string passed in is |
| 1334 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1335 | // |
| 1336 | // This function returns true if the type has already been defined, but is |
| 1337 | // allowed to be redefined in the specified context. If the name is a new name |
| 1338 | // for the type plane, it is inserted and false is returned. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1339 | static bool setTypeName(const PATypeInfo& TI, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1340 | assert(!inFunctionScope() && "Can't give types function-local names"); |
| 1341 | if (NameStr == 0) return false; |
| 1342 | |
| 1343 | std::string Name(NameStr); // Copy string |
| 1344 | free(NameStr); // Free old string |
| 1345 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1346 | const Type* Ty = TI.PAT->get(); |
| 1347 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1348 | // We don't allow assigning names to void type |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1349 | if (Ty == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1350 | error("Can't assign name '" + Name + "' to the void type"); |
| 1351 | return false; |
| 1352 | } |
| 1353 | |
| 1354 | // Set the type name, checking for conflicts as we do so. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1355 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty); |
| 1356 | |
| 1357 | // Save the sign information for later use |
| 1358 | CurModule.NamedTypeSigns[Name] = TI.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1359 | |
| 1360 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1361 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 1362 | assert(Existing && "Conflict but no matching type?"); |
| 1363 | |
| 1364 | // There is only one case where this is allowed: when we are refining an |
| 1365 | // opaque type. In this case, Existing will be an opaque type. |
| 1366 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1367 | // We ARE replacing an opaque type! |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1368 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1369 | return true; |
| 1370 | } |
| 1371 | |
| 1372 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1373 | // the redefinition is identical to the original. This will be so if |
| 1374 | // Existing and T point to the same Type object. In this one case we |
| 1375 | // allow the equivalent redefinition. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1376 | if (Existing == Ty) return true; // Yes, it's equal. |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1377 | |
| 1378 | // Any other kind of (non-equivalent) redefinition is an error. |
| 1379 | error("Redefinition of type named '" + Name + "' in the '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1380 | Ty->getDescription() + "' type plane"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | return false; |
| 1384 | } |
| 1385 | |
| 1386 | //===----------------------------------------------------------------------===// |
| 1387 | // Code for handling upreferences in type names... |
| 1388 | // |
| 1389 | |
| 1390 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1391 | // |
| 1392 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1393 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1394 | E) != Ty->subtype_end(); |
| 1395 | } |
| 1396 | |
| 1397 | namespace { |
| 1398 | struct UpRefRecord { |
| 1399 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1400 | // this type is resolved. |
| 1401 | unsigned NestingLevel; |
| 1402 | |
| 1403 | // LastContainedTy - This is the type at the current binding level for the |
| 1404 | // type. Every time we reduce the nesting level, this gets updated. |
| 1405 | const Type *LastContainedTy; |
| 1406 | |
| 1407 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1408 | // represented with. |
| 1409 | OpaqueType *UpRefTy; |
| 1410 | |
| 1411 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1412 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1413 | }; |
| 1414 | } |
| 1415 | |
| 1416 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1417 | static std::vector<UpRefRecord> UpRefs; |
| 1418 | |
| 1419 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1420 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1421 | /// currently active types. For each type, if the up reference is contained in |
| 1422 | /// the newly completed type, we decrement the level count. When the level |
| 1423 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1424 | /// thus we can complete the cycle. |
| 1425 | /// |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1426 | static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1427 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1428 | // nothing to resolve here. |
| 1429 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1430 | |
| 1431 | PATypeHolder Ty(ty); |
| 1432 | UR_OUT("Type '" << Ty->getDescription() << |
| 1433 | "' newly formed. Resolving upreferences.\n" << |
| 1434 | UpRefs.size() << " upreferences active!\n"); |
| 1435 | |
| 1436 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1437 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1438 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1439 | // this variable. |
| 1440 | OpaqueType *TypeToResolve = 0; |
| 1441 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1442 | unsigned i = 0; |
| 1443 | for (; i != UpRefs.size(); ++i) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1444 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1445 | << UpRefs[i].UpRefTy->getDescription() << ") = " |
| 1446 | << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1447 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1448 | // Decrement level of upreference |
| 1449 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1450 | UpRefs[i].LastContainedTy = Ty; |
| 1451 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1452 | if (Level == 0) { // Upreference should be resolved! |
| 1453 | if (!TypeToResolve) { |
| 1454 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1455 | } else { |
| 1456 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1457 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
| 1458 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1459 | ResolveTypeSign(UpRefs[i].UpRefTy, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1460 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1461 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1462 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1463 | } |
| 1464 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1465 | --i; // Do not skip the next element... |
| 1466 | } |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | if (TypeToResolve) { |
| 1471 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1472 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1473 | std::string OldName = TypeToResolve->getDescription()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1474 | ResolveTypeSign(TypeToResolve, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1475 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1476 | } |
| 1477 | |
| 1478 | return Ty; |
| 1479 | } |
| 1480 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1481 | bool Signedness::operator<(const Signedness &that) const { |
| 1482 | if (isNamed()) { |
| 1483 | if (that.isNamed()) |
| 1484 | return *(this->name) < *(that.name); |
| 1485 | else |
| 1486 | return CurModule.NamedTypeSigns[*name] < that; |
| 1487 | } else if (that.isNamed()) { |
| 1488 | return *this < CurModule.NamedTypeSigns[*that.name]; |
| 1489 | } |
| 1490 | |
| 1491 | if (isComposite() && that.isComposite()) { |
| 1492 | if (sv->size() == that.sv->size()) { |
| 1493 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1494 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1495 | thatE = that.sv->end(); |
| 1496 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1497 | if (*thisI < *thatI) |
| 1498 | return true; |
| 1499 | else if (!(*thisI == *thatI)) |
| 1500 | return false; |
| 1501 | } |
| 1502 | return false; |
| 1503 | } |
| 1504 | return sv->size() < that.sv->size(); |
| 1505 | } |
| 1506 | return kind < that.kind; |
| 1507 | } |
| 1508 | |
| 1509 | bool Signedness::operator==(const Signedness &that) const { |
| 1510 | if (isNamed()) |
| 1511 | if (that.isNamed()) |
| 1512 | return *(this->name) == *(that.name); |
| 1513 | else |
| 1514 | return CurModule.NamedTypeSigns[*(this->name)] == that; |
| 1515 | else if (that.isNamed()) |
| 1516 | return *this == CurModule.NamedTypeSigns[*(that.name)]; |
| 1517 | if (isComposite() && that.isComposite()) { |
| 1518 | if (sv->size() == that.sv->size()) { |
| 1519 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1520 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1521 | thatE = that.sv->end(); |
| 1522 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1523 | if (!(*thisI == *thatI)) |
| 1524 | return false; |
| 1525 | } |
| 1526 | return true; |
| 1527 | } |
| 1528 | return false; |
| 1529 | } |
| 1530 | return kind == that.kind; |
| 1531 | } |
| 1532 | |
| 1533 | void Signedness::copy(const Signedness &that) { |
| 1534 | if (that.isNamed()) { |
| 1535 | kind = Named; |
| 1536 | name = new std::string(*that.name); |
| 1537 | } else if (that.isComposite()) { |
| 1538 | kind = Composite; |
| 1539 | sv = new SignVector(); |
| 1540 | *sv = *that.sv; |
| 1541 | } else { |
| 1542 | kind = that.kind; |
| 1543 | sv = 0; |
| 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | void Signedness::destroy() { |
| 1548 | if (isNamed()) { |
| 1549 | delete name; |
| 1550 | } else if (isComposite()) { |
| 1551 | delete sv; |
| 1552 | } |
| 1553 | } |
| 1554 | |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1555 | #ifndef NDEBUG |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1556 | void Signedness::dump() const { |
| 1557 | if (isComposite()) { |
| 1558 | if (sv->size() == 1) { |
| 1559 | (*sv)[0].dump(); |
| 1560 | std::cerr << "*"; |
| 1561 | } else { |
| 1562 | std::cerr << "{ " ; |
| 1563 | for (unsigned i = 0; i < sv->size(); ++i) { |
| 1564 | if (i != 0) |
| 1565 | std::cerr << ", "; |
| 1566 | (*sv)[i].dump(); |
| 1567 | } |
| 1568 | std::cerr << "} " ; |
| 1569 | } |
| 1570 | } else if (isNamed()) { |
| 1571 | std::cerr << *name; |
| 1572 | } else if (isSigned()) { |
| 1573 | std::cerr << "S"; |
| 1574 | } else if (isUnsigned()) { |
| 1575 | std::cerr << "U"; |
| 1576 | } else |
| 1577 | std::cerr << "."; |
| 1578 | } |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1579 | #endif |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1580 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1581 | static inline Instruction::TermOps |
| 1582 | getTermOp(TermOps op) { |
| 1583 | switch (op) { |
| 1584 | default : assert(0 && "Invalid OldTermOp"); |
| 1585 | case RetOp : return Instruction::Ret; |
| 1586 | case BrOp : return Instruction::Br; |
| 1587 | case SwitchOp : return Instruction::Switch; |
| 1588 | case InvokeOp : return Instruction::Invoke; |
| 1589 | case UnwindOp : return Instruction::Unwind; |
| 1590 | case UnreachableOp: return Instruction::Unreachable; |
| 1591 | } |
| 1592 | } |
| 1593 | |
| 1594 | static inline Instruction::BinaryOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1595 | getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1596 | switch (op) { |
| 1597 | default : assert(0 && "Invalid OldBinaryOps"); |
| 1598 | case SetEQ : |
| 1599 | case SetNE : |
| 1600 | case SetLE : |
| 1601 | case SetGE : |
| 1602 | case SetLT : |
| 1603 | case SetGT : assert(0 && "Should use getCompareOp"); |
| 1604 | case AddOp : return Instruction::Add; |
| 1605 | case SubOp : return Instruction::Sub; |
| 1606 | case MulOp : return Instruction::Mul; |
| 1607 | case DivOp : { |
| 1608 | // This is an obsolete instruction so we must upgrade it based on the |
| 1609 | // types of its operands. |
| 1610 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1611 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1612 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1613 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1614 | if (isFP) |
| 1615 | return Instruction::FDiv; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1616 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1617 | return Instruction::SDiv; |
| 1618 | return Instruction::UDiv; |
| 1619 | } |
| 1620 | case UDivOp : return Instruction::UDiv; |
| 1621 | case SDivOp : return Instruction::SDiv; |
| 1622 | case FDivOp : return Instruction::FDiv; |
| 1623 | case RemOp : { |
| 1624 | // This is an obsolete instruction so we must upgrade it based on the |
| 1625 | // types of its operands. |
| 1626 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1627 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1628 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1629 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1630 | // Select correct opcode |
| 1631 | if (isFP) |
| 1632 | return Instruction::FRem; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1633 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1634 | return Instruction::SRem; |
| 1635 | return Instruction::URem; |
| 1636 | } |
| 1637 | case URemOp : return Instruction::URem; |
| 1638 | case SRemOp : return Instruction::SRem; |
| 1639 | case FRemOp : return Instruction::FRem; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1640 | case LShrOp : return Instruction::LShr; |
| 1641 | case AShrOp : return Instruction::AShr; |
| 1642 | case ShlOp : return Instruction::Shl; |
| 1643 | case ShrOp : |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1644 | if (Sign.isSigned()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1645 | return Instruction::AShr; |
| 1646 | return Instruction::LShr; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1647 | case AndOp : return Instruction::And; |
| 1648 | case OrOp : return Instruction::Or; |
| 1649 | case XorOp : return Instruction::Xor; |
| 1650 | } |
| 1651 | } |
| 1652 | |
| 1653 | static inline Instruction::OtherOps |
| 1654 | getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1655 | const Signedness &Sign) { |
| 1656 | bool isSigned = Sign.isSigned(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1657 | bool isFP = Ty->isFloatingPoint(); |
| 1658 | switch (op) { |
| 1659 | default : assert(0 && "Invalid OldSetCC"); |
| 1660 | case SetEQ : |
| 1661 | if (isFP) { |
| 1662 | predicate = FCmpInst::FCMP_OEQ; |
| 1663 | return Instruction::FCmp; |
| 1664 | } else { |
| 1665 | predicate = ICmpInst::ICMP_EQ; |
| 1666 | return Instruction::ICmp; |
| 1667 | } |
| 1668 | case SetNE : |
| 1669 | if (isFP) { |
| 1670 | predicate = FCmpInst::FCMP_UNE; |
| 1671 | return Instruction::FCmp; |
| 1672 | } else { |
| 1673 | predicate = ICmpInst::ICMP_NE; |
| 1674 | return Instruction::ICmp; |
| 1675 | } |
| 1676 | case SetLE : |
| 1677 | if (isFP) { |
| 1678 | predicate = FCmpInst::FCMP_OLE; |
| 1679 | return Instruction::FCmp; |
| 1680 | } else { |
| 1681 | if (isSigned) |
| 1682 | predicate = ICmpInst::ICMP_SLE; |
| 1683 | else |
| 1684 | predicate = ICmpInst::ICMP_ULE; |
| 1685 | return Instruction::ICmp; |
| 1686 | } |
| 1687 | case SetGE : |
| 1688 | if (isFP) { |
| 1689 | predicate = FCmpInst::FCMP_OGE; |
| 1690 | return Instruction::FCmp; |
| 1691 | } else { |
| 1692 | if (isSigned) |
| 1693 | predicate = ICmpInst::ICMP_SGE; |
| 1694 | else |
| 1695 | predicate = ICmpInst::ICMP_UGE; |
| 1696 | return Instruction::ICmp; |
| 1697 | } |
| 1698 | case SetLT : |
| 1699 | if (isFP) { |
| 1700 | predicate = FCmpInst::FCMP_OLT; |
| 1701 | return Instruction::FCmp; |
| 1702 | } else { |
| 1703 | if (isSigned) |
| 1704 | predicate = ICmpInst::ICMP_SLT; |
| 1705 | else |
| 1706 | predicate = ICmpInst::ICMP_ULT; |
| 1707 | return Instruction::ICmp; |
| 1708 | } |
| 1709 | case SetGT : |
| 1710 | if (isFP) { |
| 1711 | predicate = FCmpInst::FCMP_OGT; |
| 1712 | return Instruction::FCmp; |
| 1713 | } else { |
| 1714 | if (isSigned) |
| 1715 | predicate = ICmpInst::ICMP_SGT; |
| 1716 | else |
| 1717 | predicate = ICmpInst::ICMP_UGT; |
| 1718 | return Instruction::ICmp; |
| 1719 | } |
| 1720 | } |
| 1721 | } |
| 1722 | |
| 1723 | static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) { |
| 1724 | switch (op) { |
| 1725 | default : assert(0 && "Invalid OldMemoryOps"); |
| 1726 | case MallocOp : return Instruction::Malloc; |
| 1727 | case FreeOp : return Instruction::Free; |
| 1728 | case AllocaOp : return Instruction::Alloca; |
| 1729 | case LoadOp : return Instruction::Load; |
| 1730 | case StoreOp : return Instruction::Store; |
| 1731 | case GetElementPtrOp : return Instruction::GetElementPtr; |
| 1732 | } |
| 1733 | } |
| 1734 | |
| 1735 | static inline Instruction::OtherOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1736 | getOtherOp(OtherOps op, const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1737 | switch (op) { |
| 1738 | default : assert(0 && "Invalid OldOtherOps"); |
| 1739 | case PHIOp : return Instruction::PHI; |
| 1740 | case CallOp : return Instruction::Call; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1741 | case SelectOp : return Instruction::Select; |
| 1742 | case UserOp1 : return Instruction::UserOp1; |
| 1743 | case UserOp2 : return Instruction::UserOp2; |
| 1744 | case VAArg : return Instruction::VAArg; |
| 1745 | case ExtractElementOp : return Instruction::ExtractElement; |
| 1746 | case InsertElementOp : return Instruction::InsertElement; |
| 1747 | case ShuffleVectorOp : return Instruction::ShuffleVector; |
| 1748 | case ICmpOp : return Instruction::ICmp; |
| 1749 | case FCmpOp : return Instruction::FCmp; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1750 | }; |
| 1751 | } |
| 1752 | |
| 1753 | static inline Value* |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1754 | getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy, |
| 1755 | const Signedness &DstSign, bool ForceInstruction = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1756 | Instruction::CastOps Opcode; |
| 1757 | const Type* SrcTy = Src->getType(); |
| 1758 | if (op == CastOp) { |
| 1759 | if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) { |
| 1760 | // fp -> ptr cast is no longer supported but we must upgrade this |
| 1761 | // by doing a double cast: fp -> int -> ptr |
| 1762 | SrcTy = Type::Int64Ty; |
| 1763 | Opcode = Instruction::IntToPtr; |
| 1764 | if (isa<Constant>(Src)) { |
| 1765 | Src = ConstantExpr::getCast(Instruction::FPToUI, |
| 1766 | cast<Constant>(Src), SrcTy); |
| 1767 | } else { |
| 1768 | std::string NewName(makeNameUnique(Src->getName())); |
| 1769 | Src = new FPToUIInst(Src, SrcTy, NewName, CurBB); |
| 1770 | } |
| 1771 | } else if (isa<IntegerType>(DstTy) && |
| 1772 | cast<IntegerType>(DstTy)->getBitWidth() == 1) { |
| 1773 | // cast type %x to bool was previously defined as setne type %x, null |
| 1774 | // The cast semantic is now to truncate, not compare so we must retain |
| 1775 | // the original intent by replacing the cast with a setne |
| 1776 | Constant* Null = Constant::getNullValue(SrcTy); |
| 1777 | Instruction::OtherOps Opcode = Instruction::ICmp; |
| 1778 | unsigned short predicate = ICmpInst::ICMP_NE; |
| 1779 | if (SrcTy->isFloatingPoint()) { |
| 1780 | Opcode = Instruction::FCmp; |
| 1781 | predicate = FCmpInst::FCMP_ONE; |
| 1782 | } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) { |
| 1783 | error("Invalid cast to bool"); |
| 1784 | } |
| 1785 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1786 | return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null); |
| 1787 | else |
| 1788 | return CmpInst::create(Opcode, predicate, Src, Null); |
| 1789 | } |
| 1790 | // Determine the opcode to use by calling CastInst::getCastOpcode |
| 1791 | Opcode = |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1792 | CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy, |
| 1793 | DstSign.isSigned()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1794 | |
| 1795 | } else switch (op) { |
| 1796 | default: assert(0 && "Invalid cast token"); |
| 1797 | case TruncOp: Opcode = Instruction::Trunc; break; |
| 1798 | case ZExtOp: Opcode = Instruction::ZExt; break; |
| 1799 | case SExtOp: Opcode = Instruction::SExt; break; |
| 1800 | case FPTruncOp: Opcode = Instruction::FPTrunc; break; |
| 1801 | case FPExtOp: Opcode = Instruction::FPExt; break; |
| 1802 | case FPToUIOp: Opcode = Instruction::FPToUI; break; |
| 1803 | case FPToSIOp: Opcode = Instruction::FPToSI; break; |
| 1804 | case UIToFPOp: Opcode = Instruction::UIToFP; break; |
| 1805 | case SIToFPOp: Opcode = Instruction::SIToFP; break; |
| 1806 | case PtrToIntOp: Opcode = Instruction::PtrToInt; break; |
| 1807 | case IntToPtrOp: Opcode = Instruction::IntToPtr; break; |
| 1808 | case BitCastOp: Opcode = Instruction::BitCast; break; |
| 1809 | } |
| 1810 | |
| 1811 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1812 | return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy); |
| 1813 | return CastInst::create(Opcode, Src, DstTy); |
| 1814 | } |
| 1815 | |
| 1816 | static Instruction * |
| 1817 | upgradeIntrinsicCall(const Type* RetTy, const ValID &ID, |
| 1818 | std::vector<Value*>& Args) { |
| 1819 | |
| 1820 | std::string Name = ID.Type == ValID::NameVal ? ID.Name : ""; |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1821 | switch (Name[5]) { |
| 1822 | case 'i': |
| 1823 | if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") { |
| 1824 | if (Args.size() != 2) |
| 1825 | error("Invalid prototype for " + Name); |
| 1826 | return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]); |
| 1827 | } |
| 1828 | break; |
| 1829 | case 'b': |
| 1830 | if (Name.length() == 14 && !memcmp(&Name[5], "bswap.i", 7)) { |
| 1831 | const Type* ArgTy = Args[0]->getType(); |
| 1832 | Name += ".i" + utostr(cast<IntegerType>(ArgTy)->getBitWidth()); |
| 1833 | Function *F = cast<Function>( |
| 1834 | CurModule.CurrentModule->getOrInsertFunction(Name, RetTy, ArgTy, |
| 1835 | (void*)0)); |
| 1836 | return new CallInst(F, Args[0]); |
| 1837 | } |
| 1838 | break; |
Reid Spencer | 8166a6c | 2007-04-02 02:08:35 +0000 | [diff] [blame] | 1839 | case 'c': |
| 1840 | if ((Name.length() <= 14 && !memcmp(&Name[5], "ctpop.i", 7)) || |
| 1841 | (Name.length() <= 13 && !memcmp(&Name[5], "ctlz.i", 6)) || |
| 1842 | (Name.length() <= 13 && !memcmp(&Name[5], "cttz.i", 6))) { |
| 1843 | // These intrinsics changed their result type. |
| 1844 | const Type* ArgTy = Args[0]->getType(); |
| 1845 | Function *OldF = CurModule.CurrentModule->getFunction(Name); |
| 1846 | if (OldF) |
| 1847 | OldF->setName("upgrd.rm." + Name); |
| 1848 | |
| 1849 | Function *NewF = cast<Function>( |
| 1850 | CurModule.CurrentModule->getOrInsertFunction(Name, Type::Int32Ty, |
| 1851 | ArgTy, (void*)0)); |
| 1852 | |
| 1853 | Instruction *Call = new CallInst(NewF, Args[0], "", CurBB); |
| 1854 | return CastInst::createIntegerCast(Call, RetTy, false); |
| 1855 | } |
| 1856 | break; |
| 1857 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1858 | case 'v' : { |
| 1859 | const Type* PtrTy = PointerType::get(Type::Int8Ty); |
| 1860 | std::vector<const Type*> Params; |
| 1861 | if (Name == "llvm.va_start" || Name == "llvm.va_end") { |
| 1862 | if (Args.size() != 1) |
| 1863 | error("Invalid prototype for " + Name + " prototype"); |
| 1864 | Params.push_back(PtrTy); |
| 1865 | const FunctionType *FTy = |
| 1866 | FunctionType::get(Type::VoidTy, Params, false); |
| 1867 | const PointerType *PFTy = PointerType::get(FTy); |
| 1868 | Value* Func = getVal(PFTy, ID); |
| 1869 | Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB); |
| 1870 | return new CallInst(Func, &Args[0], Args.size()); |
| 1871 | } else if (Name == "llvm.va_copy") { |
| 1872 | if (Args.size() != 2) |
| 1873 | error("Invalid prototype for " + Name + " prototype"); |
| 1874 | Params.push_back(PtrTy); |
| 1875 | Params.push_back(PtrTy); |
| 1876 | const FunctionType *FTy = |
| 1877 | FunctionType::get(Type::VoidTy, Params, false); |
| 1878 | const PointerType *PFTy = PointerType::get(FTy); |
| 1879 | Value* Func = getVal(PFTy, ID); |
| 1880 | std::string InstName0(makeNameUnique("va0")); |
| 1881 | std::string InstName1(makeNameUnique("va1")); |
| 1882 | Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB); |
| 1883 | Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB); |
| 1884 | return new CallInst(Func, &Args[0], Args.size()); |
| 1885 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1886 | } |
| 1887 | } |
| 1888 | return 0; |
| 1889 | } |
| 1890 | |
| 1891 | const Type* upgradeGEPIndices(const Type* PTy, |
| 1892 | std::vector<ValueInfo> *Indices, |
| 1893 | std::vector<Value*> &VIndices, |
| 1894 | std::vector<Constant*> *CIndices = 0) { |
| 1895 | // Traverse the indices with a gep_type_iterator so we can build the list |
| 1896 | // of constant and value indices for use later. Also perform upgrades |
| 1897 | VIndices.clear(); |
| 1898 | if (CIndices) CIndices->clear(); |
| 1899 | for (unsigned i = 0, e = Indices->size(); i != e; ++i) |
| 1900 | VIndices.push_back((*Indices)[i].V); |
| 1901 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
| 1902 | GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()), |
| 1903 | GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end()); |
| 1904 | for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) { |
| 1905 | Value *Index = VIndices[i]; |
| 1906 | if (CIndices && !isa<Constant>(Index)) |
| 1907 | error("Indices to constant getelementptr must be constants"); |
| 1908 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1909 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1910 | else if (isa<StructType>(*GTI)) { // Only change struct indices |
| 1911 | if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index)) |
| 1912 | if (CUI->getType()->getBitWidth() == 8) |
| 1913 | Index = |
| 1914 | ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty); |
| 1915 | } else { |
| 1916 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1917 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1918 | // all indices for SequentialType elements. We must retain the same |
| 1919 | // semantic (zext) for unsigned types. |
| 1920 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1921 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1922 | if (CIndices) |
| 1923 | Index = ConstantExpr::getCast(Instruction::ZExt, |
| 1924 | cast<Constant>(Index), Type::Int64Ty); |
| 1925 | else |
| 1926 | Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty, |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1927 | makeNameUnique("gep"), CurBB); |
Reid Spencer | 38f682b | 2007-01-26 20:31:18 +0000 | [diff] [blame] | 1928 | VIndices[i] = Index; |
| 1929 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1930 | } |
| 1931 | // Add to the CIndices list, if requested. |
| 1932 | if (CIndices) |
| 1933 | CIndices->push_back(cast<Constant>(Index)); |
| 1934 | } |
| 1935 | |
| 1936 | const Type *IdxTy = |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 1937 | GetElementPtrInst::getIndexedType(PTy, &VIndices[0], VIndices.size(), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1938 | if (!IdxTy) |
| 1939 | error("Index list invalid for constant getelementptr"); |
| 1940 | return IdxTy; |
| 1941 | } |
| 1942 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 1943 | unsigned upgradeCallingConv(unsigned CC) { |
| 1944 | switch (CC) { |
| 1945 | case OldCallingConv::C : return CallingConv::C; |
| 1946 | case OldCallingConv::CSRet : return CallingConv::C; |
| 1947 | case OldCallingConv::Fast : return CallingConv::Fast; |
| 1948 | case OldCallingConv::Cold : return CallingConv::Cold; |
| 1949 | case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall; |
| 1950 | case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall; |
| 1951 | default: |
| 1952 | return CC; |
| 1953 | } |
| 1954 | } |
| 1955 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1956 | Module* UpgradeAssembly(const std::string &infile, std::istream& in, |
| 1957 | bool debug, bool addAttrs) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1958 | { |
| 1959 | Upgradelineno = 1; |
| 1960 | CurFilename = infile; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 1961 | LexInput = ∈ |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1962 | yydebug = debug; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 1963 | AddAttributes = addAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1964 | ObsoleteVarArgs = false; |
| 1965 | NewVarArgs = false; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1966 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1967 | CurModule.CurrentModule = new Module(CurFilename); |
| 1968 | |
| 1969 | // Check to make sure the parser succeeded |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1970 | if (yyparse()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1971 | if (ParserResult) |
| 1972 | delete ParserResult; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1973 | std::cerr << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1974 | return 0; |
| 1975 | } |
| 1976 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1977 | // Check to make sure that parsing produced a result |
| 1978 | if (!ParserResult) { |
| 1979 | std::cerr << "llvm-upgrade: no parse result.\n"; |
| 1980 | return 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1981 | } |
| 1982 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1983 | // Reset ParserResult variable while saving its value for the result. |
| 1984 | Module *Result = ParserResult; |
| 1985 | ParserResult = 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1986 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1987 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1988 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1989 | Function* F; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1990 | if ((F = Result->getFunction("llvm.va_start")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1991 | && F->getFunctionType()->getNumParams() == 0) |
| 1992 | ObsoleteVarArgs = true; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1993 | if((F = Result->getFunction("llvm.va_copy")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1994 | && F->getFunctionType()->getNumParams() == 1) |
| 1995 | ObsoleteVarArgs = true; |
Reid Spencer | 280d801 | 2006-12-01 23:40:53 +0000 | [diff] [blame] | 1996 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1997 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1998 | if (ObsoleteVarArgs && NewVarArgs) { |
| 1999 | error("This file is corrupt: it uses both new and old style varargs"); |
| 2000 | return 0; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2001 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2002 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2003 | if(ObsoleteVarArgs) { |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2004 | if(Function* F = Result->getFunction("llvm.va_start")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2005 | if (F->arg_size() != 0) { |
| 2006 | error("Obsolete va_start takes 0 argument"); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2007 | return 0; |
| 2008 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2009 | |
| 2010 | //foo = va_start() |
| 2011 | // -> |
| 2012 | //bar = alloca typeof(foo) |
| 2013 | //va_start(bar) |
| 2014 | //foo = load bar |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2015 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2016 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2017 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2018 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2019 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2020 | "llvm.va_start", RetTy, ArgTyPtr, (Type *)0)); |
| 2021 | |
| 2022 | while (!F->use_empty()) { |
| 2023 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2024 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 2025 | new CallInst(NF, bar, "", CI); |
| 2026 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 2027 | CI->replaceAllUsesWith(foo); |
| 2028 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2029 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2030 | Result->getFunctionList().erase(F); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2031 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2032 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2033 | if(Function* F = Result->getFunction("llvm.va_end")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2034 | if(F->arg_size() != 1) { |
| 2035 | error("Obsolete va_end takes 1 argument"); |
| 2036 | return 0; |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2037 | } |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2038 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2039 | //vaend foo |
| 2040 | // -> |
| 2041 | //bar = alloca 1 of typeof(foo) |
| 2042 | //vaend bar |
| 2043 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2044 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 2045 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2046 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2047 | "llvm.va_end", RetTy, ArgTyPtr, (Type *)0)); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2048 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2049 | while (!F->use_empty()) { |
| 2050 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2051 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 2052 | new StoreInst(CI->getOperand(1), bar, CI); |
| 2053 | new CallInst(NF, bar, "", CI); |
| 2054 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2055 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2056 | Result->getFunctionList().erase(F); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2057 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2058 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2059 | if(Function* F = Result->getFunction("llvm.va_copy")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2060 | if(F->arg_size() != 1) { |
| 2061 | error("Obsolete va_copy takes 1 argument"); |
| 2062 | return 0; |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2063 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2064 | //foo = vacopy(bar) |
| 2065 | // -> |
| 2066 | //a = alloca 1 of typeof(foo) |
| 2067 | //b = alloca 1 of typeof(foo) |
| 2068 | //store bar -> b |
| 2069 | //vacopy(a, b) |
| 2070 | //foo = load a |
| 2071 | |
| 2072 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2073 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2074 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2075 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2076 | "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0)); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +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* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); |
| 2081 | AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); |
| 2082 | new StoreInst(CI->getOperand(1), b, CI); |
| 2083 | new CallInst(NF, a, b, "", CI); |
| 2084 | Value* foo = new LoadInst(a, "vacopy.fix.3", CI); |
| 2085 | CI->replaceAllUsesWith(foo); |
| 2086 | CI->getParent()->getInstList().erase(CI); |
| 2087 | } |
| 2088 | Result->getFunctionList().erase(F); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2089 | } |
| 2090 | } |
| 2091 | |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 2092 | return Result; |
| 2093 | } |
| 2094 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2095 | } // end llvm namespace |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2096 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2097 | using namespace llvm; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2098 | |
| 2099 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2100 | |
| 2101 | /* Enabling traces. */ |
| 2102 | #ifndef YYDEBUG |
| 2103 | # define YYDEBUG 0 |
| 2104 | #endif |
| 2105 | |
| 2106 | /* Enabling verbose error messages. */ |
| 2107 | #ifdef YYERROR_VERBOSE |
| 2108 | # undef YYERROR_VERBOSE |
| 2109 | # define YYERROR_VERBOSE 1 |
| 2110 | #else |
| 2111 | # define YYERROR_VERBOSE 0 |
| 2112 | #endif |
| 2113 | |
| 2114 | /* Enabling the token table. */ |
| 2115 | #ifndef YYTOKEN_TABLE |
| 2116 | # define YYTOKEN_TABLE 0 |
| 2117 | #endif |
| 2118 | |
| 2119 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 2120 | #line 1741 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2121 | typedef union YYSTYPE { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2122 | llvm::Module *ModuleVal; |
| 2123 | llvm::Function *FunctionVal; |
| 2124 | std::pair<llvm::PATypeInfo, char*> *ArgVal; |
| 2125 | llvm::BasicBlock *BasicBlockVal; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 2126 | llvm::TermInstInfo TermInstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2127 | llvm::InstrInfo InstVal; |
| 2128 | llvm::ConstInfo ConstVal; |
| 2129 | llvm::ValueInfo ValueVal; |
| 2130 | llvm::PATypeInfo TypeVal; |
| 2131 | llvm::TypeInfo PrimType; |
| 2132 | llvm::PHIListInfo PHIList; |
| 2133 | std::list<llvm::PATypeInfo> *TypeList; |
| 2134 | std::vector<llvm::ValueInfo> *ValueList; |
| 2135 | std::vector<llvm::ConstInfo> *ConstVector; |
| 2136 | |
| 2137 | |
| 2138 | std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList; |
| 2139 | // Represent the RHS of PHI node |
| 2140 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 2141 | |
| 2142 | llvm::GlobalValue::LinkageTypes Linkage; |
| 2143 | int64_t SInt64Val; |
| 2144 | uint64_t UInt64Val; |
| 2145 | int SIntVal; |
| 2146 | unsigned UIntVal; |
| 2147 | double FPVal; |
| 2148 | bool BoolVal; |
| 2149 | |
| 2150 | char *StrVal; // This memory is strdup'd! |
| 2151 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 2152 | |
| 2153 | llvm::BinaryOps BinaryOpVal; |
| 2154 | llvm::TermOps TermOpVal; |
| 2155 | llvm::MemoryOps MemOpVal; |
| 2156 | llvm::OtherOps OtherOpVal; |
| 2157 | llvm::CastOps CastOpVal; |
| 2158 | llvm::ICmpInst::Predicate IPred; |
| 2159 | llvm::FCmpInst::Predicate FPred; |
| 2160 | llvm::Module::Endianness Endianness; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2161 | } YYSTYPE; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2162 | /* Line 196 of yacc.c. */ |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 2163 | #line 2164 "UpgradeParser.tab.c" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2164 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 2165 | # define YYSTYPE_IS_DECLARED 1 |
| 2166 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2167 | #endif |
| 2168 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2169 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2170 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2171 | /* Copy the second part of user declarations. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2172 | |
| 2173 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2174 | /* Line 219 of yacc.c. */ |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 2175 | #line 2176 "UpgradeParser.tab.c" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2176 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2177 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 2178 | # define YYSIZE_T __SIZE_TYPE__ |
| 2179 | #endif |
| 2180 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 2181 | # define YYSIZE_T size_t |
| 2182 | #endif |
| 2183 | #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) |
| 2184 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 2185 | # define YYSIZE_T size_t |
| 2186 | #endif |
| 2187 | #if ! defined (YYSIZE_T) |
| 2188 | # define YYSIZE_T unsigned int |
| 2189 | #endif |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2190 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2191 | #ifndef YY_ |
| 2192 | # if YYENABLE_NLS |
| 2193 | # if ENABLE_NLS |
| 2194 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 2195 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 2196 | # endif |
| 2197 | # endif |
| 2198 | # ifndef YY_ |
| 2199 | # define YY_(msgid) msgid |
| 2200 | # endif |
| 2201 | #endif |
| 2202 | |
| 2203 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 2204 | |
| 2205 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 2206 | |
| 2207 | # ifdef YYSTACK_USE_ALLOCA |
| 2208 | # if YYSTACK_USE_ALLOCA |
| 2209 | # ifdef __GNUC__ |
| 2210 | # define YYSTACK_ALLOC __builtin_alloca |
| 2211 | # else |
| 2212 | # define YYSTACK_ALLOC alloca |
| 2213 | # if defined (__STDC__) || defined (__cplusplus) |
| 2214 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 2215 | # define YYINCLUDED_STDLIB_H |
| 2216 | # endif |
| 2217 | # endif |
| 2218 | # endif |
| 2219 | # endif |
| 2220 | |
| 2221 | # ifdef YYSTACK_ALLOC |
| 2222 | /* Pacify GCC's `empty if-body' warning. */ |
| 2223 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 2224 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 2225 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 2226 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 2227 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 2228 | to allow for a few compiler-allocated temporary stack slots. */ |
| 2229 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ |
| 2230 | # endif |
| 2231 | # else |
| 2232 | # define YYSTACK_ALLOC YYMALLOC |
| 2233 | # define YYSTACK_FREE YYFREE |
| 2234 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 2235 | # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) |
| 2236 | # endif |
| 2237 | # ifdef __cplusplus |
| 2238 | extern "C" { |
| 2239 | # endif |
| 2240 | # ifndef YYMALLOC |
| 2241 | # define YYMALLOC malloc |
| 2242 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 2243 | && (defined (__STDC__) || defined (__cplusplus))) |
| 2244 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 2245 | # endif |
| 2246 | # endif |
| 2247 | # ifndef YYFREE |
| 2248 | # define YYFREE free |
| 2249 | # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 2250 | && (defined (__STDC__) || defined (__cplusplus))) |
| 2251 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 2252 | # endif |
| 2253 | # endif |
| 2254 | # ifdef __cplusplus |
| 2255 | } |
| 2256 | # endif |
| 2257 | # endif |
| 2258 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 2259 | |
| 2260 | |
| 2261 | #if (! defined (yyoverflow) \ |
| 2262 | && (! defined (__cplusplus) \ |
| 2263 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 2264 | |
| 2265 | /* A type that is properly aligned for any stack member. */ |
| 2266 | union yyalloc |
| 2267 | { |
| 2268 | short int yyss; |
| 2269 | YYSTYPE yyvs; |
| 2270 | }; |
| 2271 | |
| 2272 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 2273 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 2274 | |
| 2275 | /* The size of an array large to enough to hold all stacks, each with |
| 2276 | N elements. */ |
| 2277 | # define YYSTACK_BYTES(N) \ |
| 2278 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
| 2279 | + YYSTACK_GAP_MAXIMUM) |
| 2280 | |
| 2281 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 2282 | not overlap. */ |
| 2283 | # ifndef YYCOPY |
| 2284 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 2285 | # define YYCOPY(To, From, Count) \ |
| 2286 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 2287 | # else |
| 2288 | # define YYCOPY(To, From, Count) \ |
| 2289 | do \ |
| 2290 | { \ |
| 2291 | YYSIZE_T yyi; \ |
| 2292 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 2293 | (To)[yyi] = (From)[yyi]; \ |
| 2294 | } \ |
| 2295 | while (0) |
| 2296 | # endif |
| 2297 | # endif |
| 2298 | |
| 2299 | /* Relocate STACK from its old location to the new one. The |
| 2300 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 2301 | elements in the stack, and YYPTR gives the new location of the |
| 2302 | stack. Advance YYPTR to a properly aligned location for the next |
| 2303 | stack. */ |
| 2304 | # define YYSTACK_RELOCATE(Stack) \ |
| 2305 | do \ |
| 2306 | { \ |
| 2307 | YYSIZE_T yynewbytes; \ |
| 2308 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 2309 | Stack = &yyptr->Stack; \ |
| 2310 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 2311 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 2312 | } \ |
| 2313 | while (0) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2314 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2315 | #endif |
| 2316 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2317 | #if defined (__STDC__) || defined (__cplusplus) |
| 2318 | typedef signed char yysigned_char; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2319 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2320 | typedef short int yysigned_char; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2321 | #endif |
| 2322 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2323 | /* YYFINAL -- State number of the termination state. */ |
| 2324 | #define YYFINAL 4 |
| 2325 | /* YYLAST -- Last index in YYTABLE. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2326 | #define YYLAST 1630 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2327 | |
| 2328 | /* YYNTOKENS -- Number of terminals. */ |
| 2329 | #define YYNTOKENS 166 |
| 2330 | /* YYNNTS -- Number of nonterminals. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2331 | #define YYNNTS 81 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2332 | /* YYNRULES -- Number of rules. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2333 | #define YYNRULES 310 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2334 | /* YYNRULES -- Number of states. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2335 | #define YYNSTATES 606 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2336 | |
| 2337 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 2338 | #define YYUNDEFTOK 2 |
| 2339 | #define YYMAXUTOK 406 |
| 2340 | |
| 2341 | #define YYTRANSLATE(YYX) \ |
| 2342 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 2343 | |
| 2344 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 2345 | static const unsigned char yytranslate[] = |
| 2346 | { |
| 2347 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2348 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2349 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2350 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2351 | 155, 156, 164, 2, 153, 2, 2, 2, 2, 2, |
| 2352 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2353 | 160, 152, 161, 2, 2, 2, 2, 2, 2, 2, |
| 2354 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2355 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2356 | 2, 157, 154, 159, 2, 2, 2, 2, 2, 165, |
| 2357 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2358 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2359 | 158, 2, 2, 162, 2, 163, 2, 2, 2, 2, |
| 2360 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2361 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2362 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2363 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2364 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2365 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2366 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2367 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2368 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2369 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2370 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2371 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2372 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 2373 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 2374 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 2375 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 2376 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 2377 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 2378 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 2379 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 2380 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2381 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2382 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2383 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 2384 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2385 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
| 2386 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 2387 | 145, 146, 147, 148, 149, 150, 151 |
| 2388 | }; |
| 2389 | |
| 2390 | #if YYDEBUG |
| 2391 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 2392 | YYRHS. */ |
| 2393 | static const unsigned short int yyprhs[] = |
| 2394 | { |
| 2395 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 2396 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 2397 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 2398 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 2399 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 2400 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 2401 | 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, |
| 2402 | 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, |
| 2403 | 159, 161, 164, 165, 167, 169, 171, 173, 175, 177, |
| 2404 | 179, 180, 181, 183, 185, 187, 189, 191, 193, 196, |
| 2405 | 197, 200, 201, 205, 208, 209, 211, 212, 216, 218, |
| 2406 | 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, |
| 2407 | 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, |
| 2408 | 261, 264, 269, 275, 281, 285, 288, 294, 299, 302, |
| 2409 | 304, 308, 310, 314, 316, 317, 322, 326, 330, 335, |
| 2410 | 340, 344, 351, 357, 360, 363, 366, 369, 372, 375, |
| 2411 | 378, 381, 384, 387, 394, 400, 409, 416, 423, 430, |
| 2412 | 438, 446, 453, 460, 469, 478, 482, 484, 486, 488, |
| 2413 | 490, 493, 496, 501, 504, 506, 511, 514, 519, 520, |
| 2414 | 528, 529, 537, 538, 546, 547, 555, 559, 564, 565, |
| 2415 | 567, 569, 571, 575, 579, 583, 587, 591, 595, 597, |
| 2416 | 598, 600, 602, 604, 605, 608, 612, 614, 616, 620, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2417 | 622, 623, 632, 634, 636, 637, 642, 644, 646, 649, |
| 2418 | 650, 652, 654, 655, 656, 662, 663, 665, 667, 669, |
| 2419 | 671, 673, 675, 677, 679, 681, 685, 687, 693, 695, |
| 2420 | 697, 699, 701, 704, 707, 710, 714, 717, 718, 720, |
| 2421 | 722, 724, 727, 730, 734, 744, 754, 763, 777, 779, |
| 2422 | 781, 788, 794, 797, 804, 812, 814, 818, 820, 821, |
| 2423 | 824, 826, 832, 838, 844, 851, 858, 861, 866, 871, |
| 2424 | 878, 883, 888, 893, 898, 905, 912, 915, 923, 925, |
| 2425 | 928, 929, 931, 932, 936, 943, 947, 954, 957, 962, |
| 2426 | 969 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2427 | }; |
| 2428 | |
| 2429 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 2430 | static const short int yyrhs[] = |
| 2431 | { |
| 2432 | 200, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
| 2433 | -1, 79, -1, 80, -1, 81, -1, 82, -1, 83, |
| 2434 | -1, 84, -1, 85, -1, 86, -1, 87, -1, 88, |
| 2435 | -1, 89, -1, 90, -1, 91, -1, 92, -1, 97, |
| 2436 | -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, |
| 2437 | -1, 119, -1, 120, -1, 121, -1, 122, -1, 123, |
| 2438 | -1, 124, -1, 125, -1, 126, -1, 127, -1, 128, |
| 2439 | -1, 129, -1, 130, -1, 131, -1, 132, -1, 133, |
| 2440 | -1, 134, -1, 135, -1, 136, -1, 137, -1, 138, |
| 2441 | -1, 125, -1, 126, -1, 127, -1, 128, -1, 27, |
| 2442 | -1, 28, -1, 93, -1, 94, -1, 95, -1, 96, |
| 2443 | -1, 140, -1, 141, -1, 142, -1, 143, -1, 144, |
| 2444 | -1, 145, -1, 146, -1, 147, -1, 148, -1, 149, |
| 2445 | -1, 150, -1, 151, -1, 139, -1, 16, -1, 14, |
| 2446 | -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, |
| 2447 | -1, 11, -1, 176, -1, 177, -1, 18, -1, 19, |
| 2448 | -1, 212, 152, -1, -1, 41, -1, 42, -1, 43, |
| 2449 | -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, |
| 2450 | -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, |
| 2451 | -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, |
| 2452 | -1, 153, 57, 4, -1, 34, 24, -1, -1, 185, |
| 2453 | -1, -1, 153, 188, 187, -1, 185, -1, 57, 4, |
| 2454 | -1, 191, -1, 8, -1, 193, -1, 8, -1, 193, |
| 2455 | -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, |
| 2456 | -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2457 | -1, 19, -1, 21, -1, 192, -1, 48, -1, 229, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2458 | -1, 154, 4, -1, 190, 155, 195, 156, -1, 157, |
| 2459 | 4, 158, 193, 159, -1, 160, 4, 158, 193, 161, |
| 2460 | -1, 162, 194, 163, -1, 162, 163, -1, 160, 162, |
| 2461 | 194, 163, 161, -1, 160, 162, 163, 161, -1, 193, |
| 2462 | 164, -1, 193, -1, 194, 153, 193, -1, 194, -1, |
| 2463 | 194, 153, 37, -1, 37, -1, -1, 191, 157, 198, |
| 2464 | 159, -1, 191, 157, 159, -1, 191, 165, 24, -1, |
| 2465 | 191, 160, 198, 161, -1, 191, 162, 198, 163, -1, |
| 2466 | 191, 162, 163, -1, 191, 160, 162, 198, 163, 161, |
| 2467 | -1, 191, 160, 162, 163, 161, -1, 191, 38, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2468 | 191, 39, -1, 191, 229, -1, 191, 197, -1, 191, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2469 | 26, -1, 176, 168, -1, 177, 4, -1, 9, 27, |
| 2470 | -1, 9, 28, -1, 179, 7, -1, 175, 155, 196, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2471 | 36, 191, 156, -1, 110, 155, 196, 244, 156, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2472 | 112, 155, 196, 153, 196, 153, 196, 156, -1, 169, |
| 2473 | 155, 196, 153, 196, 156, -1, 170, 155, 196, 153, |
| 2474 | 196, 156, -1, 171, 155, 196, 153, 196, 156, -1, |
| 2475 | 103, 172, 155, 196, 153, 196, 156, -1, 104, 173, |
| 2476 | 155, 196, 153, 196, 156, -1, 174, 155, 196, 153, |
| 2477 | 196, 156, -1, 114, 155, 196, 153, 196, 156, -1, |
| 2478 | 115, 155, 196, 153, 196, 153, 196, 156, -1, 116, |
| 2479 | 155, 196, 153, 196, 153, 196, 156, -1, 198, 153, |
| 2480 | 196, -1, 196, -1, 32, -1, 33, -1, 201, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2481 | 201, 222, -1, 201, 224, -1, 201, 62, 61, 207, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2482 | -1, 201, 25, -1, 202, -1, 202, 180, 20, 189, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2483 | -1, 202, 224, -1, 202, 62, 61, 207, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2484 | 202, 180, 181, 199, 196, 203, 187, -1, -1, 202, |
| 2485 | 180, 50, 199, 191, 204, 187, -1, -1, 202, 180, |
| 2486 | 45, 199, 191, 205, 187, -1, -1, 202, 180, 47, |
| 2487 | 199, 191, 206, 187, -1, 202, 51, 209, -1, 202, |
| 2488 | 58, 152, 210, -1, -1, 24, -1, 56, -1, 55, |
| 2489 | -1, 53, 152, 208, -1, 54, 152, 4, -1, 52, |
| 2490 | 152, 24, -1, 71, 152, 24, -1, 157, 211, 159, |
| 2491 | -1, 211, 153, 24, -1, 24, -1, -1, 22, -1, |
| 2492 | 24, -1, 212, -1, -1, 191, 213, -1, 215, 153, |
| 2493 | 214, -1, 214, -1, 215, -1, 215, 153, 37, -1, |
| 2494 | 37, -1, -1, 182, 189, 212, 155, 216, 156, 186, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2495 | 183, -1, 29, -1, 162, -1, -1, 181, 220, 217, |
| 2496 | 218, -1, 30, -1, 163, -1, 232, 221, -1, -1, |
| 2497 | 45, -1, 47, -1, -1, -1, 31, 225, 223, 226, |
| 2498 | 217, -1, -1, 63, -1, 3, -1, 4, -1, 7, |
| 2499 | -1, 27, -1, 28, -1, 38, -1, 39, -1, 26, |
| 2500 | -1, 160, 198, 161, -1, 197, -1, 61, 227, 24, |
| 2501 | 153, 24, -1, 167, -1, 212, -1, 229, -1, 228, |
| 2502 | -1, 191, 230, -1, 232, 233, -1, 219, 233, -1, |
| 2503 | 234, 180, 236, -1, 234, 238, -1, -1, 23, -1, |
| 2504 | 77, -1, 78, -1, 72, 231, -1, 72, 8, -1, |
| 2505 | 73, 21, 230, -1, 73, 9, 230, 153, 21, 230, |
| 2506 | 153, 21, 230, -1, 74, 178, 230, 153, 21, 230, |
| 2507 | 157, 237, 159, -1, 74, 178, 230, 153, 21, 230, |
| 2508 | 157, 159, -1, 75, 182, 189, 230, 155, 241, 156, |
| 2509 | 36, 21, 230, 235, 21, 230, -1, 235, -1, 76, |
| 2510 | -1, 237, 178, 228, 153, 21, 230, -1, 178, 228, |
| 2511 | 153, 21, 230, -1, 180, 243, -1, 191, 157, 230, |
| 2512 | 153, 230, 159, -1, 239, 153, 157, 230, 153, 230, |
| 2513 | 159, -1, 231, -1, 240, 153, 231, -1, 240, -1, |
| 2514 | -1, 60, 59, -1, 59, -1, 169, 191, 230, 153, |
| 2515 | 230, -1, 170, 191, 230, 153, 230, -1, 171, 191, |
| 2516 | 230, 153, 230, -1, 103, 172, 191, 230, 153, 230, |
| 2517 | -1, 104, 173, 191, 230, 153, 230, -1, 49, 231, |
| 2518 | -1, 174, 231, 153, 231, -1, 175, 231, 36, 191, |
| 2519 | -1, 112, 231, 153, 231, 153, 231, -1, 113, 231, |
| 2520 | 153, 191, -1, 117, 231, 153, 191, -1, 118, 231, |
| 2521 | 153, 191, -1, 114, 231, 153, 231, -1, 115, 231, |
| 2522 | 153, 231, 153, 231, -1, 116, 231, 153, 231, 153, |
| 2523 | 231, -1, 111, 239, -1, 242, 182, 189, 230, 155, |
| 2524 | 241, 156, -1, 246, -1, 153, 240, -1, -1, 35, |
| 2525 | -1, -1, 105, 191, 184, -1, 105, 191, 153, 15, |
| 2526 | 230, 184, -1, 106, 191, 184, -1, 106, 191, 153, |
| 2527 | 15, 230, 184, -1, 107, 231, -1, 245, 108, 191, |
| 2528 | 230, -1, 245, 109, 231, 153, 191, 230, -1, 110, |
| 2529 | 191, 230, 244, -1 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2530 | }; |
| 2531 | |
| 2532 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 2533 | static const unsigned short int yyrline[] = |
| 2534 | { |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 2535 | 0, 1881, 1881, 1882, 1890, 1891, 1901, 1901, 1901, 1901, |
| 2536 | 1901, 1901, 1901, 1901, 1901, 1901, 1901, 1905, 1905, 1905, |
| 2537 | 1909, 1909, 1909, 1909, 1909, 1909, 1913, 1913, 1914, 1914, |
| 2538 | 1915, 1915, 1916, 1916, 1917, 1917, 1921, 1921, 1922, 1922, |
| 2539 | 1923, 1923, 1924, 1924, 1925, 1925, 1926, 1926, 1927, 1927, |
| 2540 | 1928, 1929, 1932, 1932, 1932, 1932, 1936, 1936, 1936, 1936, |
| 2541 | 1936, 1936, 1936, 1937, 1937, 1937, 1937, 1937, 1937, 1943, |
| 2542 | 1943, 1943, 1943, 1947, 1947, 1947, 1947, 1951, 1951, 1955, |
| 2543 | 1955, 1960, 1963, 1968, 1969, 1970, 1971, 1972, 1973, 1974, |
| 2544 | 1975, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1996, |
| 2545 | 1997, 2005, 2006, 2014, 2023, 2024, 2031, 2032, 2036, 2040, |
| 2546 | 2056, 2057, 2064, 2065, 2072, 2080, 2080, 2080, 2080, 2080, |
| 2547 | 2080, 2080, 2081, 2081, 2081, 2081, 2081, 2086, 2090, 2094, |
| 2548 | 2099, 2108, 2126, 2132, 2145, 2156, 2160, 2173, 2177, 2191, |
| 2549 | 2195, 2202, 2203, 2209, 2216, 2228, 2258, 2271, 2294, 2322, |
| 2550 | 2344, 2355, 2377, 2388, 2397, 2402, 2461, 2468, 2476, 2483, |
| 2551 | 2490, 2494, 2498, 2507, 2522, 2535, 2544, 2572, 2585, 2594, |
| 2552 | 2600, 2606, 2617, 2623, 2629, 2640, 2641, 2650, 2651, 2663, |
| 2553 | 2672, 2673, 2674, 2675, 2676, 2692, 2712, 2714, 2716, 2716, |
| 2554 | 2723, 2723, 2731, 2731, 2739, 2739, 2748, 2750, 2752, 2757, |
| 2555 | 2771, 2772, 2776, 2779, 2787, 2791, 2798, 2802, 2806, 2810, |
| 2556 | 2818, 2818, 2822, 2823, 2827, 2835, 2840, 2848, 2849, 2856, |
| 2557 | 2863, 2867, 3049, 3049, 3053, 3053, 3063, 3063, 3067, 3072, |
| 2558 | 3073, 3074, 3078, 3079, 3078, 3091, 3092, 3097, 3098, 3099, |
| 2559 | 3100, 3104, 3108, 3109, 3110, 3111, 3132, 3136, 3150, 3151, |
| 2560 | 3156, 3156, 3164, 3174, 3177, 3186, 3197, 3202, 3211, 3222, |
| 2561 | 3222, 3225, 3229, 3233, 3238, 3248, 3266, 3275, 3345, 3349, |
| 2562 | 3356, 3368, 3383, 3413, 3423, 3433, 3437, 3444, 3445, 3449, |
| 2563 | 3452, 3458, 3477, 3495, 3511, 3525, 3539, 3550, 3568, 3577, |
| 2564 | 3586, 3593, 3614, 3638, 3644, 3650, 3656, 3672, 3762, 3770, |
| 2565 | 3771, 3775, 3776, 3780, 3786, 3793, 3799, 3806, 3813, 3826, |
| 2566 | 3852 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2567 | }; |
| 2568 | #endif |
| 2569 | |
| 2570 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 2571 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 2572 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 2573 | static const char *const yytname[] = |
| 2574 | { |
| 2575 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 2576 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 2577 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 2578 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 2579 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 2580 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 2581 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 2582 | "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 2583 | "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", |
| 2584 | "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", |
| 2585 | "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", |
| 2586 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 2587 | "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT", |
| 2588 | "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM", |
| 2589 | "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR", |
| 2590 | "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP", |
| 2591 | "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", |
| 2592 | "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", |
| 2593 | "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", |
| 2594 | "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", |
| 2595 | "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", |
| 2596 | "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR", |
| 2597 | "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", |
| 2598 | "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL", |
| 2599 | "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates", |
| 2600 | "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType", |
| 2601 | "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", |
| 2602 | "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes", |
| 2603 | "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", |
| 2604 | "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", |
| 2605 | "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", |
| 2606 | "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition", |
| 2607 | "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal", |
| 2608 | "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2609 | "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7", |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2610 | "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", |
| 2611 | "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", |
| 2612 | "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList", |
| 2613 | "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList", |
| 2614 | "OptVolatile", "MemoryInst", 0 |
| 2615 | }; |
| 2616 | #endif |
| 2617 | |
| 2618 | # ifdef YYPRINT |
| 2619 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 2620 | token YYLEX-NUM. */ |
| 2621 | static const unsigned short int yytoknum[] = |
| 2622 | { |
| 2623 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 2624 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 2625 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 2626 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 2627 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 2628 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 2629 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 2630 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 2631 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 2632 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 2633 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 2634 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 2635 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 2636 | 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, |
| 2637 | 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, |
| 2638 | 405, 406, 61, 44, 92, 40, 41, 91, 120, 93, |
| 2639 | 60, 62, 123, 125, 42, 99 |
| 2640 | }; |
| 2641 | # endif |
| 2642 | |
| 2643 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 2644 | static const unsigned char yyr1[] = |
| 2645 | { |
| 2646 | 0, 166, 167, 167, 168, 168, 169, 169, 169, 169, |
| 2647 | 169, 169, 169, 169, 169, 169, 169, 170, 170, 170, |
| 2648 | 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, |
| 2649 | 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, |
| 2650 | 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, |
| 2651 | 173, 173, 174, 174, 174, 174, 175, 175, 175, 175, |
| 2652 | 175, 175, 175, 175, 175, 175, 175, 175, 175, 176, |
| 2653 | 176, 176, 176, 177, 177, 177, 177, 178, 178, 179, |
| 2654 | 179, 180, 180, 181, 181, 181, 181, 181, 181, 181, |
| 2655 | 181, 182, 182, 182, 182, 182, 182, 182, 182, 183, |
| 2656 | 183, 184, 184, 185, 186, 186, 187, 187, 188, 188, |
| 2657 | 189, 189, 190, 190, 191, 192, 192, 192, 192, 192, |
| 2658 | 192, 192, 192, 192, 192, 192, 192, 193, 193, 193, |
| 2659 | 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, |
| 2660 | 194, 195, 195, 195, 195, 196, 196, 196, 196, 196, |
| 2661 | 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, |
| 2662 | 196, 196, 196, 197, 197, 197, 197, 197, 197, 197, |
| 2663 | 197, 197, 197, 197, 197, 198, 198, 199, 199, 200, |
| 2664 | 201, 201, 201, 201, 201, 202, 202, 202, 203, 202, |
| 2665 | 204, 202, 205, 202, 206, 202, 202, 202, 202, 207, |
| 2666 | 208, 208, 209, 209, 209, 209, 210, 211, 211, 211, |
| 2667 | 212, 212, 213, 213, 214, 215, 215, 216, 216, 216, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2668 | 216, 217, 218, 218, 220, 219, 221, 221, 222, 223, |
| 2669 | 223, 223, 225, 226, 224, 227, 227, 228, 228, 228, |
| 2670 | 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, |
| 2671 | 230, 230, 231, 232, 232, 233, 234, 234, 234, 235, |
| 2672 | 235, 236, 236, 236, 236, 236, 236, 236, 236, 236, |
| 2673 | 237, 237, 238, 239, 239, 240, 240, 241, 241, 242, |
| 2674 | 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, |
| 2675 | 243, 243, 243, 243, 243, 243, 243, 243, 243, 244, |
| 2676 | 244, 245, 245, 246, 246, 246, 246, 246, 246, 246, |
| 2677 | 246 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2678 | }; |
| 2679 | |
| 2680 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 2681 | static const unsigned char yyr2[] = |
| 2682 | { |
| 2683 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2684 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2685 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2686 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2687 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2688 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2689 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2690 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2691 | 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, |
| 2692 | 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, |
| 2693 | 2, 0, 3, 2, 0, 1, 0, 3, 1, 2, |
| 2694 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2695 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2696 | 2, 4, 5, 5, 3, 2, 5, 4, 2, 1, |
| 2697 | 3, 1, 3, 1, 0, 4, 3, 3, 4, 4, |
| 2698 | 3, 6, 5, 2, 2, 2, 2, 2, 2, 2, |
| 2699 | 2, 2, 2, 6, 5, 8, 6, 6, 6, 7, |
| 2700 | 7, 6, 6, 8, 8, 3, 1, 1, 1, 1, |
| 2701 | 2, 2, 4, 2, 1, 4, 2, 4, 0, 7, |
| 2702 | 0, 7, 0, 7, 0, 7, 3, 4, 0, 1, |
| 2703 | 1, 1, 3, 3, 3, 3, 3, 3, 1, 0, |
| 2704 | 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2705 | 0, 8, 1, 1, 0, 4, 1, 1, 2, 0, |
| 2706 | 1, 1, 0, 0, 5, 0, 1, 1, 1, 1, |
| 2707 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 2708 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 1, |
| 2709 | 1, 2, 2, 3, 9, 9, 8, 13, 1, 1, |
| 2710 | 6, 5, 2, 6, 7, 1, 3, 1, 0, 2, |
| 2711 | 1, 5, 5, 5, 6, 6, 2, 4, 4, 6, |
| 2712 | 4, 4, 4, 4, 6, 6, 2, 7, 1, 2, |
| 2713 | 0, 1, 0, 3, 6, 3, 6, 2, 4, 6, |
| 2714 | 4 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2715 | }; |
| 2716 | |
| 2717 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 2718 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 2719 | means the default is an error. */ |
| 2720 | static const unsigned short int yydefact[] = |
| 2721 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2722 | 198, 0, 90, 184, 1, 183, 232, 83, 84, 85, |
| 2723 | 86, 87, 88, 89, 0, 224, 257, 180, 181, 257, |
| 2724 | 210, 211, 0, 0, 0, 90, 0, 186, 229, 0, |
| 2725 | 91, 258, 254, 82, 226, 227, 228, 253, 0, 0, |
| 2726 | 0, 0, 196, 0, 0, 0, 0, 0, 0, 0, |
| 2727 | 81, 230, 231, 233, 199, 182, 0, 92, 93, 94, |
| 2728 | 95, 96, 97, 0, 0, 302, 256, 0, 0, 0, |
| 2729 | 0, 209, 197, 187, 2, 3, 111, 115, 116, 117, |
| 2730 | 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, |
| 2731 | 0, 0, 0, 0, 248, 185, 0, 110, 127, 114, |
| 2732 | 249, 129, 177, 178, 0, 0, 0, 0, 91, 98, |
| 2733 | 0, 222, 223, 225, 301, 0, 280, 0, 0, 0, |
| 2734 | 0, 91, 269, 259, 260, 6, 7, 8, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2735 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 52, |
| 2736 | 53, 54, 55, 20, 21, 22, 23, 24, 25, 0, |
| 2737 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2738 | 0, 0, 0, 68, 56, 57, 58, 59, 60, 61, |
| 2739 | 62, 63, 64, 65, 66, 67, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2740 | 0, 268, 255, 91, 272, 0, 298, 204, 201, 200, |
| 2741 | 202, 203, 205, 208, 0, 130, 0, 0, 0, 113, |
| 2742 | 135, 139, 0, 144, 138, 192, 194, 190, 115, 116, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2743 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2744 | 0, 0, 0, 188, 234, 0, 0, 286, 279, 262, |
| 2745 | 261, 0, 0, 72, 76, 71, 75, 70, 74, 69, |
| 2746 | 73, 77, 78, 0, 0, 26, 27, 28, 29, 30, |
| 2747 | 31, 32, 33, 34, 35, 0, 50, 51, 46, 47, |
| 2748 | 48, 49, 36, 37, 38, 39, 40, 41, 42, 43, |
| 2749 | 44, 45, 0, 101, 101, 307, 0, 0, 296, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2750 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2751 | 0, 0, 0, 0, 0, 206, 0, 0, 0, 0, |
| 2752 | 0, 134, 143, 141, 0, 106, 106, 106, 160, 161, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2753 | 4, 5, 158, 159, 162, 157, 153, 154, 0, 0, |
| 2754 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2755 | 0, 0, 0, 0, 156, 155, 106, 220, 237, 238, |
| 2756 | 239, 244, 240, 241, 242, 243, 235, 0, 246, 251, |
| 2757 | 250, 252, 0, 263, 0, 0, 0, 0, 0, 303, |
| 2758 | 0, 305, 300, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2759 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2760 | 207, 112, 112, 137, 0, 140, 0, 131, 0, 193, |
| 2761 | 195, 191, 0, 0, 0, 0, 0, 0, 0, 146, |
| 2762 | 176, 0, 0, 0, 150, 0, 147, 0, 0, 0, |
| 2763 | 0, 0, 189, 219, 213, 216, 217, 0, 236, 0, |
| 2764 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2765 | 310, 0, 0, 0, 290, 293, 0, 0, 291, 292, |
| 2766 | 0, 0, 0, 287, 288, 0, 308, 0, 132, 133, |
| 2767 | 136, 142, 0, 0, 108, 106, 0, 0, 300, 0, |
| 2768 | 0, 0, 0, 0, 145, 135, 114, 0, 148, 149, |
| 2769 | 0, 0, 0, 0, 0, 212, 214, 0, 104, 0, |
| 2770 | 245, 0, 0, 278, 0, 0, 101, 102, 101, 275, |
| 2771 | 299, 0, 0, 0, 0, 0, 281, 282, 283, 278, |
| 2772 | 0, 103, 109, 107, 0, 0, 0, 0, 0, 0, |
| 2773 | 0, 175, 152, 0, 0, 0, 0, 0, 0, 218, |
| 2774 | 215, 105, 99, 0, 0, 0, 277, 0, 284, 285, |
| 2775 | 0, 304, 306, 0, 0, 0, 289, 294, 295, 0, |
| 2776 | 309, 0, 0, 164, 0, 0, 0, 0, 151, 0, |
| 2777 | 0, 0, 0, 0, 0, 221, 247, 0, 0, 0, |
| 2778 | 276, 273, 0, 297, 0, 0, 0, 172, 0, 0, |
| 2779 | 166, 167, 168, 171, 163, 100, 0, 266, 0, 0, |
| 2780 | 0, 274, 169, 170, 0, 0, 0, 264, 0, 265, |
| 2781 | 0, 0, 165, 173, 174, 0, 0, 0, 0, 0, |
| 2782 | 0, 271, 0, 0, 270, 267 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2783 | }; |
| 2784 | |
| 2785 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 2786 | static const short int yydefgoto[] = |
| 2787 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2788 | -1, 94, 312, 329, 330, 331, 255, 272, 332, 333, |
| 2789 | 219, 220, 243, 221, 25, 15, 63, 555, 359, 454, |
| 2790 | 522, 389, 455, 95, 96, 222, 98, 99, 202, 304, |
| 2791 | 400, 348, 401, 104, 1, 2, 3, 336, 307, 305, |
| 2792 | 306, 55, 190, 42, 72, 194, 100, 476, 415, 416, |
| 2793 | 417, 64, 113, 16, 30, 36, 17, 53, 18, 28, |
| 2794 | 108, 419, 349, 101, 351, 489, 19, 32, 33, 181, |
| 2795 | 182, 579, 66, 278, 526, 527, 183, 184, 430, 185, |
| 2796 | 186 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2797 | }; |
| 2798 | |
| 2799 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 2800 | STATE-NUM. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2801 | #define YYPACT_NINF -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2802 | static const short int yypact[] = |
| 2803 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2804 | -542, 13, 162, 567, -542, -542, -542, -542, -542, -542, |
| 2805 | -542, -542, -542, -542, 83, -542, 19, -542, -542, -14, |
| 2806 | -542, -542, 50, -87, 87, 233, 27, -542, 123, 141, |
| 2807 | 175, -542, -542, 98, -542, -542, -542, -542, 33, 40, |
| 2808 | 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156, |
| 2809 | -542, -542, -542, -542, -542, -542, 221, -542, -542, -542, |
| 2810 | -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226, |
| 2811 | 227, 235, -542, -542, -542, -542, 81, -542, -542, -542, |
| 2812 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2813 | 256, 257, 4, 15, -542, -542, 108, -542, -542, 12, |
| 2814 | -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542, |
| 2815 | 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116, |
| 2816 | 479, 175, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2817 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2818 | -542, -542, -542, -542, -542, -542, -542, -542, -542, 355, |
| 2819 | 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, |
| 2820 | 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542, |
| 2821 | -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306, |
| 2822 | 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542, |
| 2823 | -542, -542, -542, -542, -13, -542, 110, 111, 75, -542, |
| 2824 | -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208, |
| 2825 | 266, 210, 267, 212, 268, 230, 277, 275, 278, 246, |
| 2826 | 280, 279, 566, -542, -542, 136, 766, -542, -542, 81, |
| 2827 | -542, 766, 766, -542, -542, -542, -542, -542, -542, -542, |
| 2828 | -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542, |
| 2829 | -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542, |
| 2830 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2831 | -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147, |
| 2832 | 148, 149, 151, 152, 158, 160, 766, 766, 766, 161, |
| 2833 | 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27, |
| 2834 | 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542, |
| 2835 | -542, -542, -542, -542, -542, -542, -542, -542, 355, 429, |
| 2836 | 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184, |
| 2837 | 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542, |
| 2838 | -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542, |
| 2839 | -542, -542, 193, -542, 194, 766, 766, 766, 7, -542, |
| 2840 | 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306, |
| 2841 | 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207, |
| 2842 | -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542, |
| 2843 | -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542, |
| 2844 | -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326, |
| 2845 | 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337, |
| 2846 | -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306, |
| 2847 | -542, 223, 766, 224, -542, -542, 225, 234, -542, -542, |
| 2848 | 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542, |
| 2849 | -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236, |
| 2850 | 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542, |
| 2851 | 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252, |
| 2852 | -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542, |
| 2853 | 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306, |
| 2854 | 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326, |
| 2855 | 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542, |
| 2856 | -542, -542, 368, 402, 274, 276, 259, 287, -542, -542, |
| 2857 | 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290, |
| 2858 | -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296, |
| 2859 | 297, 299, 302, 303, 430, -542, -542, 414, 41, 425, |
| 2860 | -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326, |
| 2861 | -542, -542, -542, -542, -542, -542, 766, -542, 893, 144, |
| 2862 | 448, -542, -542, -542, 314, 315, 316, -542, 331, -542, |
| 2863 | 893, 766, -542, -542, -542, 464, 334, 180, 766, 481, |
| 2864 | 482, -542, 766, 766, -542, -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2865 | }; |
| 2866 | |
| 2867 | /* YYPGOTO[NTERM-NUM]. */ |
| 2868 | static const short int yypgoto[] = |
| 2869 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2870 | -542, -542, -542, 435, 439, 441, 191, 197, 442, 445, |
| 2871 | -119, -116, -541, -542, 478, 489, -107, -542, -267, 37, |
| 2872 | -542, -238, -542, -60, -542, -45, -542, -74, -51, -542, |
| 2873 | -101, 300, -252, 134, -542, -542, -542, -542, -542, -542, |
| 2874 | -542, 473, -542, -542, -542, -542, 8, -542, 46, -542, |
| 2875 | -542, 410, -542, -542, -542, -542, -542, -542, 518, -542, |
| 2876 | -542, -542, -528, 142, -90, -113, -542, 505, -542, -72, |
| 2877 | -542, -542, -542, -542, 97, 28, -542, -542, 70, -542, |
| 2878 | -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2879 | }; |
| 2880 | |
| 2881 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2882 | positive, shift that token. If negative, reduce the rule which |
| 2883 | number is the opposite. If zero, do what YYDEFACT says. |
| 2884 | If YYTABLE_NINF, syntax error. */ |
| 2885 | #define YYTABLE_NINF -180 |
| 2886 | static const short int yytable[] = |
| 2887 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2888 | 97, 241, 227, 110, 242, 230, 223, 361, 197, 31, |
| 2889 | 111, 26, 449, 4, 244, 204, 34, 578, 97, 201, |
| 2890 | 74, 75, 426, 199, 77, 78, 79, 80, 81, 82, |
| 2891 | 83, 84, 85, 86, 87, 428, 88, 20, 590, 21, |
| 2892 | 275, 26, 31, 279, 280, 281, 282, 283, 284, 285, |
| 2893 | 588, 233, 234, 235, 236, 237, 238, 239, 240, 205, |
| 2894 | 206, 207, 596, 89, 427, 43, 289, 290, 390, 391, |
| 2895 | 226, 463, 300, 226, 403, 405, 291, 427, 452, 468, |
| 2896 | 74, 75, 301, 199, 77, 78, 79, 80, 81, 82, |
| 2897 | 83, 84, 85, 86, 87, 420, 88, 20, 412, 21, |
| 2898 | 448, 453, 38, 39, 40, 204, 273, 274, 226, 276, |
| 2899 | 277, 226, 226, 226, 226, 226, 226, 226, 225, 463, |
| 2900 | 20, 41, 21, 89, 201, 231, 300, 480, -139, 201, |
| 2901 | -112, 286, 287, 288, 226, 226, 384, 232, -139, 204, |
| 2902 | 294, 352, 353, 112, 29, 463, 295, 299, 44, 35, |
| 2903 | 467, 464, 303, 354, 233, 234, 235, 236, 237, 238, |
| 2904 | 239, 240, -179, 463, 463, 54, 198, -112, 51, 90, |
| 2905 | 52, 71, 91, 469, 513, 92, 204, 93, 200, 50, |
| 2906 | 379, 105, 106, 107, 355, 67, 362, 5, 102, 103, |
| 2907 | 188, 189, 68, 6, 292, 293, 372, 373, 374, 97, |
| 2908 | 577, 308, 309, 7, 8, 9, 10, 11, 12, 13, |
| 2909 | 356, -72, -72, -71, -71, -70, -70, 503, 69, 531, |
| 2910 | 70, 532, 381, 382, 14, 109, 385, 357, 187, 90, |
| 2911 | 191, 377, 91, -69, -69, 92, -113, 93, 298, 56, |
| 2912 | 57, 58, 59, 60, 61, 62, 97, 378, 226, 310, |
| 2913 | 311, 192, 433, 45, 435, 436, 437, 123, 124, 193, |
| 2914 | 195, 196, 443, 203, 228, 423, 424, 425, 296, 297, |
| 2915 | -76, -75, -74, 431, 7, 8, 9, 10, 46, 12, |
| 2916 | 47, -73, -79, 48, 313, -80, 314, 445, 446, 363, |
| 2917 | 358, 337, 414, 458, 459, 460, 461, 462, 360, 364, |
| 2918 | 365, 366, 367, 589, 368, 369, 470, 471, 472, 473, |
| 2919 | 474, 370, 385, 371, 375, 380, 383, 376, 386, 387, |
| 2920 | 226, 434, 226, 226, 226, 438, 439, 394, 466, 388, |
| 2921 | 226, 444, 395, 396, 397, 406, 486, 398, 488, 407, |
| 2922 | 408, 409, 492, 410, 411, 418, 421, 422, 429, 432, |
| 2923 | 496, 497, 498, 440, 441, 504, 505, 450, 456, 442, |
| 2924 | 447, 479, 511, 481, 335, 478, 457, 477, 350, 482, |
| 2925 | 483, 484, 485, 350, 350, 487, 491, 493, 494, 502, |
| 2926 | 536, 537, 538, 499, 226, 350, 501, 495, 518, 507, |
| 2927 | 508, 524, 525, 509, 528, 529, 510, 514, 515, 512, |
| 2928 | 516, 534, 500, 517, 452, 523, 544, 545, 546, 547, |
| 2929 | 540, 530, 533, 549, 550, 551, 552, 535, 350, 543, |
| 2930 | 560, 548, 475, 541, 542, 554, 556, 557, 350, 350, |
| 2931 | 350, 427, 414, 558, 575, 576, 566, 568, 226, 241, |
| 2932 | 564, 565, 242, 559, 561, 562, 563, 569, 226, 226, |
| 2933 | 226, 567, 570, 571, 226, 572, 256, 257, 573, 574, |
| 2934 | 241, 580, 582, 242, 581, 584, 583, 585, 586, 591, |
| 2935 | 592, 593, 594, 553, 245, 246, 247, 248, 249, 250, |
| 2936 | 251, 252, 253, 254, 595, 598, 587, 599, 226, 233, |
| 2937 | 234, 235, 236, 237, 238, 239, 240, 350, 350, 350, |
| 2938 | 176, 597, 602, 603, 177, 350, 178, 179, 601, 392, |
| 2939 | 180, 65, 604, 605, 49, 521, 393, 73, 224, 350, |
| 2940 | 350, 27, 334, 520, 37, 600, 490, 539, 506, 0, |
| 2941 | 0, 0, 0, 0, 74, 75, 0, 199, 208, 209, |
| 2942 | 210, 211, 212, 213, 214, 215, 216, 217, 218, 0, |
| 2943 | 88, 20, 0, 21, 258, 259, 260, 261, 262, 263, |
| 2944 | 264, 265, 266, 267, 268, 269, 270, 271, 350, 0, |
| 2945 | 350, 74, 75, 0, 350, 0, 0, 89, 0, 0, |
| 2946 | 0, 0, 350, 350, 350, 0, 0, -82, 20, 20, |
| 2947 | 21, 21, 315, 0, 0, 0, 0, 0, 6, -82, |
| 2948 | -82, 0, 0, 0, 316, 317, 0, 0, -82, -82, |
| 2949 | -82, -82, -82, -82, -82, 0, 0, -82, 22, 0, |
| 2950 | 0, 0, 0, 350, 350, 23, 350, 350, 0, 24, |
| 2951 | 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2952 | 0, 0, 350, 0, 0, 125, 126, 127, 128, 129, |
| 2953 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2954 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
| 2955 | 319, 0, 0, 0, 0, 0, 320, 350, 321, 0, |
| 2956 | 322, 323, 324, 90, 0, 0, 91, 0, 0, 92, |
| 2957 | 0, 93, 404, 0, 0, 0, 0, 0, 0, 0, |
| 2958 | 0, 0, 0, 0, 0, 163, 164, 165, 166, 167, |
| 2959 | 168, 169, 170, 171, 172, 173, 174, 175, 350, 0, |
| 2960 | 0, 0, 0, 325, 0, 0, 326, 0, 327, 0, |
| 2961 | 0, 328, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2962 | 350, 0, 0, 0, 350, 350, 74, 75, 0, 199, |
| 2963 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, |
| 2964 | 218, 0, 88, 20, 0, 21, 0, 0, 0, 338, |
| 2965 | 339, 74, 75, 340, 0, 0, 0, 0, 0, 0, |
| 2966 | 0, 0, 0, 0, 0, 0, 0, 0, 20, 89, |
| 2967 | 21, 0, 341, 342, 343, 0, 0, 0, 0, 0, |
| 2968 | 0, 0, 0, 0, 344, 345, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2969 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2970 | 0, 0, 0, 0, 0, 0, 0, 346, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2971 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2972 | 0, 0, 0, 0, 0, 125, 126, 127, 128, 129, |
| 2973 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2974 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2975 | 319, 0, 0, 0, 0, 0, 320, 0, 321, 0, |
| 2976 | 322, 323, 324, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2977 | 0, 0, 0, 0, 0, 90, 338, 339, 91, 0, |
| 2978 | 340, 92, 0, 93, 465, 163, 164, 165, 166, 167, |
| 2979 | 168, 169, 170, 171, 172, 173, 174, 175, 0, 341, |
| 2980 | 342, 343, 0, 0, 0, 0, 347, 0, 0, 0, |
| 2981 | 0, 344, 345, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2982 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2983 | 0, 0, 0, 0, 346, 0, 0, 0, 0, 0, |
| 2984 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2985 | 0, 0, 125, 126, 127, 128, 129, 130, 131, 132, |
| 2986 | 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, |
| 2987 | 143, 144, 145, 146, 147, 148, 318, 319, 0, 0, |
| 2988 | 0, 0, 0, 320, 0, 321, 0, 322, 323, 324, |
| 2989 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2990 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2991 | 0, 0, 163, 164, 165, 166, 167, 168, 169, 170, |
| 2992 | 171, 172, 173, 174, 175, 0, 0, 0, 0, 0, |
| 2993 | 0, 74, 75, 347, 199, 77, 78, 79, 80, 81, |
| 2994 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 2995 | 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2996 | 0, 0, 0, 302, 0, 0, 0, 0, 0, 0, |
| 2997 | 0, 0, 74, 75, 89, 199, 208, 209, 210, 211, |
| 2998 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 2999 | 0, 21, 74, 75, 0, 199, 77, 78, 79, 80, |
| 3000 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 3001 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 0, |
| 3002 | 0, 0, 0, 0, 413, 0, 0, 0, 0, 0, |
| 3003 | 0, 0, 0, 74, 75, 89, 199, 77, 78, 79, |
| 3004 | 80, 81, 82, 83, 84, 85, 86, 87, 0, 88, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3005 | 20, 0, 21, 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, 451, 0, 0, 0, 0, |
| 3007 | 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, |
| 3008 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
| 3009 | 74, 75, 0, 199, 77, 78, 79, 80, 81, 82, |
| 3010 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
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, 90, 519, 0, 91, 0, 399, 92, 0, 93, |
| 3013 | 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, |
| 3014 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 93, |
| 3015 | 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, |
| 3016 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
| 3017 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3018 | 0, 0, 90, 0, 0, 91, 0, 0, 92, 0, |
| 3019 | 93, 74, 75, 89, 199, 77, 78, 79, 80, 81, |
| 3020 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 3021 | 21, 74, 75, 0, 199, 208, 209, 210, 211, 212, |
| 3022 | 213, 214, 215, 216, 217, 218, 0, 88, 20, 0, |
| 3023 | 21, 0, 0, 0, 89, 0, 0, 0, 0, 90, |
| 3024 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 3025 | 0, 0, 74, 75, 89, 229, 77, 78, 79, 80, |
| 3026 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 3027 | 0, 21, 74, 75, 0, 199, 208, 209, 210, 211, |
| 3028 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 3029 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 90, |
| 3030 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 3031 | 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3032 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3033 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3034 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3035 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3036 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3037 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3038 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3039 | 0, 0, 0, 0, 114, 0, 0, 0, 0, 0, |
| 3040 | 0, 90, 0, 0, 91, 0, 0, 92, 115, 93, |
| 3041 | 0, 0, 0, 0, 0, 0, 0, 0, 116, 117, |
| 3042 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 402, |
| 3043 | 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 3044 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3045 | 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3046 | 147, 148, 149, 150, 151, 152, 153, 0, 0, 154, |
| 3047 | 155, 156, 157, 158, 159, 160, 161, 162, 0, 0, |
| 3048 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3049 | 0, 0, 0, 0, 0, 0, 0, 0, 163, 164, |
| 3050 | 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 3051 | 175 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3052 | }; |
| 3053 | |
| 3054 | static const short int yycheck[] = |
| 3055 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3056 | 45, 120, 115, 63, 120, 118, 107, 274, 4, 23, |
| 3057 | 29, 3, 161, 0, 121, 164, 30, 558, 63, 93, |
| 3058 | 5, 6, 15, 8, 9, 10, 11, 12, 13, 14, |
| 3059 | 15, 16, 17, 18, 19, 15, 21, 22, 579, 24, |
| 3060 | 153, 33, 23, 156, 157, 158, 159, 160, 161, 162, |
| 3061 | 578, 10, 11, 12, 13, 14, 15, 16, 17, 104, |
| 3062 | 105, 106, 590, 48, 57, 152, 179, 180, 306, 307, |
| 3063 | 115, 153, 153, 118, 326, 327, 183, 57, 34, 161, |
| 3064 | 5, 6, 163, 8, 9, 10, 11, 12, 13, 14, |
| 3065 | 15, 16, 17, 18, 19, 347, 21, 22, 336, 24, |
| 3066 | 159, 57, 52, 53, 54, 164, 151, 152, 153, 154, |
| 3067 | 155, 156, 157, 158, 159, 160, 161, 162, 110, 153, |
| 3068 | 22, 71, 24, 48, 198, 9, 153, 161, 153, 203, |
| 3069 | 155, 176, 177, 178, 179, 180, 163, 21, 163, 164, |
| 3070 | 153, 231, 232, 162, 61, 153, 159, 198, 61, 163, |
| 3071 | 402, 159, 203, 243, 10, 11, 12, 13, 14, 15, |
| 3072 | 16, 17, 0, 153, 153, 24, 162, 155, 45, 154, |
| 3073 | 47, 157, 157, 163, 163, 160, 164, 162, 163, 152, |
| 3074 | 293, 47, 48, 49, 244, 152, 276, 25, 32, 33, |
| 3075 | 55, 56, 152, 31, 108, 109, 286, 287, 288, 244, |
| 3076 | 159, 27, 28, 41, 42, 43, 44, 45, 46, 47, |
| 3077 | 255, 3, 4, 3, 4, 3, 4, 455, 152, 486, |
| 3078 | 152, 488, 296, 297, 62, 4, 300, 272, 24, 154, |
| 3079 | 4, 291, 157, 3, 4, 160, 155, 162, 163, 64, |
| 3080 | 65, 66, 67, 68, 69, 70, 291, 292, 293, 3, |
| 3081 | 4, 24, 365, 20, 367, 368, 369, 77, 78, 24, |
| 3082 | 4, 4, 375, 155, 59, 355, 356, 357, 158, 158, |
| 3083 | 4, 4, 4, 363, 41, 42, 43, 44, 45, 46, |
| 3084 | 47, 4, 7, 50, 4, 7, 7, 377, 378, 157, |
| 3085 | 153, 155, 337, 394, 395, 396, 397, 398, 153, 153, |
| 3086 | 153, 153, 153, 159, 153, 153, 407, 408, 409, 410, |
| 3087 | 411, 153, 386, 153, 153, 24, 161, 36, 153, 156, |
| 3088 | 365, 366, 367, 368, 369, 370, 371, 155, 402, 153, |
| 3089 | 375, 376, 155, 155, 155, 24, 426, 155, 428, 155, |
| 3090 | 155, 155, 432, 155, 155, 63, 153, 153, 153, 157, |
| 3091 | 440, 441, 442, 153, 153, 456, 457, 161, 155, 153, |
| 3092 | 153, 24, 463, 21, 222, 156, 155, 153, 226, 21, |
| 3093 | 155, 153, 153, 231, 232, 4, 153, 153, 153, 4, |
| 3094 | 493, 494, 495, 155, 429, 243, 24, 153, 36, 153, |
| 3095 | 153, 481, 482, 153, 484, 485, 153, 153, 153, 161, |
| 3096 | 153, 491, 447, 153, 34, 153, 507, 508, 509, 510, |
| 3097 | 500, 153, 153, 514, 515, 516, 517, 153, 276, 156, |
| 3098 | 533, 161, 414, 153, 153, 57, 24, 153, 286, 287, |
| 3099 | 288, 57, 477, 157, 4, 21, 153, 153, 483, 558, |
| 3100 | 541, 542, 558, 156, 159, 535, 156, 153, 493, 494, |
| 3101 | 495, 156, 156, 156, 499, 156, 27, 28, 156, 156, |
| 3102 | 579, 36, 156, 579, 159, 566, 156, 568, 569, 21, |
| 3103 | 156, 156, 156, 518, 119, 120, 121, 122, 123, 124, |
| 3104 | 125, 126, 127, 128, 153, 21, 576, 153, 533, 10, |
| 3105 | 11, 12, 13, 14, 15, 16, 17, 355, 356, 357, |
| 3106 | 65, 591, 21, 21, 65, 363, 65, 65, 598, 318, |
| 3107 | 65, 33, 602, 603, 25, 478, 319, 44, 108, 377, |
| 3108 | 378, 3, 222, 477, 19, 597, 429, 499, 458, -1, |
| 3109 | -1, -1, -1, -1, 5, 6, -1, 8, 9, 10, |
| 3110 | 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, |
| 3111 | 21, 22, -1, 24, 125, 126, 127, 128, 129, 130, |
| 3112 | 131, 132, 133, 134, 135, 136, 137, 138, 426, -1, |
| 3113 | 428, 5, 6, -1, 432, -1, -1, 48, -1, -1, |
| 3114 | -1, -1, 440, 441, 442, -1, -1, 20, 22, 22, |
| 3115 | 24, 24, 26, -1, -1, -1, -1, -1, 31, 32, |
| 3116 | 33, -1, -1, -1, 38, 39, -1, -1, 41, 42, |
| 3117 | 43, 44, 45, 46, 47, -1, -1, 50, 51, -1, |
| 3118 | -1, -1, -1, 481, 482, 58, 484, 485, -1, 62, |
| 3119 | -1, -1, -1, 491, -1, -1, -1, -1, -1, -1, |
| 3120 | -1, -1, 500, -1, -1, 79, 80, 81, 82, 83, |
| 3121 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3122 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3123 | 104, -1, -1, -1, -1, -1, 110, 535, 112, -1, |
| 3124 | 114, 115, 116, 154, -1, -1, 157, -1, -1, 160, |
| 3125 | -1, 162, 163, -1, -1, -1, -1, -1, -1, -1, |
| 3126 | -1, -1, -1, -1, -1, 139, 140, 141, 142, 143, |
| 3127 | 144, 145, 146, 147, 148, 149, 150, 151, 576, -1, |
| 3128 | -1, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3129 | -1, 165, -1, 591, -1, -1, -1, -1, -1, -1, |
| 3130 | 598, -1, -1, -1, 602, 603, 5, 6, -1, 8, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3131 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3132 | 19, -1, 21, 22, -1, 24, -1, -1, -1, 3, |
| 3133 | 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, |
| 3134 | -1, -1, -1, -1, -1, -1, -1, -1, 22, 48, |
| 3135 | 24, -1, 26, 27, 28, -1, -1, -1, -1, -1, |
| 3136 | -1, -1, -1, -1, 38, 39, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3137 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3138 | -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, |
| 3139 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3140 | -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, |
| 3141 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3142 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3143 | 104, -1, -1, -1, -1, -1, 110, -1, 112, -1, |
| 3144 | 114, 115, 116, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3145 | -1, -1, -1, -1, -1, 154, 3, 4, 157, -1, |
| 3146 | 7, 160, -1, 162, 163, 139, 140, 141, 142, 143, |
| 3147 | 144, 145, 146, 147, 148, 149, 150, 151, -1, 26, |
| 3148 | 27, 28, -1, -1, -1, -1, 160, -1, -1, -1, |
| 3149 | -1, 38, 39, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3150 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3151 | -1, -1, -1, -1, 61, -1, -1, -1, -1, -1, |
| 3152 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3153 | -1, -1, 79, 80, 81, 82, 83, 84, 85, 86, |
| 3154 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 3155 | 97, 98, 99, 100, 101, 102, 103, 104, -1, -1, |
| 3156 | -1, -1, -1, 110, -1, 112, -1, 114, 115, 116, |
| 3157 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3158 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3159 | -1, -1, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3160 | 147, 148, 149, 150, 151, -1, -1, -1, -1, -1, |
| 3161 | -1, 5, 6, 160, 8, 9, 10, 11, 12, 13, |
| 3162 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3163 | 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3164 | -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, |
| 3165 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3166 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3167 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3168 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3169 | -1, 24, -1, -1, -1, 48, -1, -1, -1, -1, |
| 3170 | -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, |
| 3171 | -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3172 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 3173 | 22, -1, 24, -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, 37, -1, -1, -1, -1, |
| 3175 | -1, -1, -1, -1, -1, -1, 48, -1, -1, -1, |
| 3176 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3177 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3178 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 3179 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3180 | -1, 154, 37, -1, 157, -1, 159, 160, -1, 162, |
| 3181 | -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3182 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3183 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3184 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3185 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3186 | -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3187 | 162, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 3188 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3189 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 3190 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3191 | 24, -1, -1, -1, 48, -1, -1, -1, -1, 154, |
| 3192 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3193 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 3194 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3195 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3196 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3197 | -1, 24, -1, -1, -1, 48, -1, -1, -1, 154, |
| 3198 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3199 | -1, -1, -1, -1, -1, 48, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3200 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3201 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3202 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3203 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3204 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3205 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3206 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3207 | -1, -1, -1, -1, 35, -1, -1, -1, -1, -1, |
| 3208 | -1, 154, -1, -1, 157, -1, -1, 160, 49, 162, |
| 3209 | -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, |
| 3210 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 3211 | -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 3212 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 3213 | 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, |
| 3214 | 101, 102, 103, 104, 105, 106, 107, -1, -1, 110, |
| 3215 | 111, 112, 113, 114, 115, 116, 117, 118, -1, -1, |
| 3216 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3217 | -1, -1, -1, -1, -1, -1, -1, -1, 139, 140, |
| 3218 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, |
| 3219 | 151 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3220 | }; |
| 3221 | |
| 3222 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 3223 | symbol of state STATE-NUM. */ |
| 3224 | static const unsigned char yystos[] = |
| 3225 | { |
| 3226 | 0, 200, 201, 202, 0, 25, 31, 41, 42, 43, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3227 | 44, 45, 46, 47, 62, 181, 219, 222, 224, 232, |
| 3228 | 22, 24, 51, 58, 62, 180, 212, 224, 225, 61, |
| 3229 | 220, 23, 233, 234, 30, 163, 221, 233, 52, 53, |
| 3230 | 54, 71, 209, 152, 61, 20, 45, 47, 50, 181, |
| 3231 | 152, 45, 47, 223, 24, 207, 64, 65, 66, 67, |
| 3232 | 68, 69, 70, 182, 217, 180, 238, 152, 152, 152, |
| 3233 | 152, 157, 210, 207, 5, 6, 8, 9, 10, 11, |
| 3234 | 12, 13, 14, 15, 16, 17, 18, 19, 21, 48, |
| 3235 | 154, 157, 160, 162, 167, 189, 190, 191, 192, 193, |
| 3236 | 212, 229, 32, 33, 199, 199, 199, 199, 226, 4, |
| 3237 | 189, 29, 162, 218, 35, 49, 59, 60, 72, 73, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3238 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 3239 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3240 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3241 | 104, 105, 106, 107, 110, 111, 112, 113, 114, 115, |
| 3242 | 116, 117, 118, 139, 140, 141, 142, 143, 144, 145, |
| 3243 | 146, 147, 148, 149, 150, 151, 169, 170, 171, 174, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3244 | 175, 235, 236, 242, 243, 245, 246, 24, 55, 56, |
| 3245 | 208, 4, 24, 24, 211, 4, 4, 4, 162, 8, |
| 3246 | 163, 193, 194, 155, 164, 191, 191, 191, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3247 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 176, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3248 | 177, 179, 191, 196, 217, 212, 191, 231, 59, 8, |
| 3249 | 231, 9, 21, 10, 11, 12, 13, 14, 15, 16, |
| 3250 | 17, 176, 177, 178, 182, 119, 120, 121, 122, 123, |
| 3251 | 124, 125, 126, 127, 128, 172, 27, 28, 125, 126, |
| 3252 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3253 | 137, 138, 173, 191, 191, 231, 191, 191, 239, 231, |
| 3254 | 231, 231, 231, 231, 231, 231, 191, 191, 191, 231, |
| 3255 | 231, 182, 108, 109, 153, 159, 158, 158, 163, 194, |
| 3256 | 153, 163, 37, 194, 195, 205, 206, 204, 27, 28, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3257 | 3, 4, 168, 4, 7, 26, 38, 39, 103, 104, |
| 3258 | 110, 112, 114, 115, 116, 157, 160, 162, 165, 169, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3259 | 170, 171, 174, 175, 197, 229, 203, 155, 3, 4, |
| 3260 | 7, 26, 27, 28, 38, 39, 61, 160, 197, 228, |
| 3261 | 229, 230, 230, 230, 230, 189, 191, 191, 153, 184, |
| 3262 | 153, 184, 230, 157, 153, 153, 153, 153, 153, 153, |
| 3263 | 153, 153, 230, 230, 230, 153, 36, 189, 191, 231, |
| 3264 | 24, 193, 193, 161, 163, 193, 153, 156, 153, 187, |
| 3265 | 187, 187, 172, 173, 155, 155, 155, 155, 155, 159, |
| 3266 | 196, 198, 162, 198, 163, 198, 24, 155, 155, 155, |
| 3267 | 155, 155, 187, 37, 191, 214, 215, 216, 63, 227, |
| 3268 | 198, 153, 153, 230, 230, 230, 15, 57, 15, 153, |
| 3269 | 244, 230, 157, 231, 191, 231, 231, 231, 191, 191, |
| 3270 | 153, 153, 153, 231, 191, 230, 230, 153, 159, 161, |
| 3271 | 161, 37, 34, 57, 185, 188, 155, 155, 196, 196, |
| 3272 | 196, 196, 196, 153, 159, 163, 193, 198, 161, 163, |
| 3273 | 196, 196, 196, 196, 196, 212, 213, 153, 156, 24, |
| 3274 | 161, 21, 21, 155, 153, 153, 230, 4, 230, 231, |
| 3275 | 240, 153, 230, 153, 153, 153, 230, 230, 230, 155, |
| 3276 | 191, 24, 4, 187, 196, 196, 244, 153, 153, 153, |
| 3277 | 153, 196, 161, 163, 153, 153, 153, 153, 36, 37, |
| 3278 | 214, 185, 186, 153, 230, 230, 240, 241, 230, 230, |
| 3279 | 153, 184, 184, 153, 230, 153, 231, 231, 231, 241, |
| 3280 | 230, 153, 153, 156, 196, 196, 196, 196, 161, 196, |
| 3281 | 196, 196, 196, 191, 57, 183, 24, 153, 157, 156, |
| 3282 | 231, 159, 230, 156, 196, 196, 153, 156, 153, 153, |
| 3283 | 156, 156, 156, 156, 156, 4, 21, 159, 178, 237, |
| 3284 | 36, 159, 156, 156, 196, 196, 196, 230, 228, 159, |
| 3285 | 178, 21, 156, 156, 156, 153, 228, 230, 21, 153, |
| 3286 | 235, 230, 21, 21, 230, 230 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3287 | }; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3288 | |
| 3289 | #define yyerrok (yyerrstatus = 0) |
| 3290 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3291 | #define YYEMPTY (-2) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3292 | #define YYEOF 0 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3293 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3294 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3295 | #define YYABORT goto yyabortlab |
| 3296 | #define YYERROR goto yyerrorlab |
| 3297 | |
| 3298 | |
| 3299 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 3300 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3301 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3302 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3303 | #define YYFAIL goto yyerrlab |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3304 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3305 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3306 | |
| 3307 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3308 | do \ |
| 3309 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3310 | { \ |
| 3311 | yychar = (Token); \ |
| 3312 | yylval = (Value); \ |
| 3313 | yytoken = YYTRANSLATE (yychar); \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3314 | YYPOPSTACK; \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3315 | goto yybackup; \ |
| 3316 | } \ |
| 3317 | else \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3318 | { \ |
| 3319 | yyerror (YY_("syntax error: cannot back up")); \ |
| 3320 | YYERROR; \ |
| 3321 | } \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3322 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3323 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3324 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3325 | #define YYTERROR 1 |
| 3326 | #define YYERRCODE 256 |
| 3327 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3328 | |
| 3329 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 3330 | If N is 0, then set CURRENT to the empty location which ends |
| 3331 | the previous symbol: RHS[0] (always defined). */ |
| 3332 | |
| 3333 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 3334 | #ifndef YYLLOC_DEFAULT |
| 3335 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 3336 | do \ |
| 3337 | if (N) \ |
| 3338 | { \ |
| 3339 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 3340 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 3341 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 3342 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 3343 | } \ |
| 3344 | else \ |
| 3345 | { \ |
| 3346 | (Current).first_line = (Current).last_line = \ |
| 3347 | YYRHSLOC (Rhs, 0).last_line; \ |
| 3348 | (Current).first_column = (Current).last_column = \ |
| 3349 | YYRHSLOC (Rhs, 0).last_column; \ |
| 3350 | } \ |
| 3351 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3352 | #endif |
| 3353 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3354 | |
| 3355 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 3356 | This macro was not mandated originally: define only if we know |
| 3357 | we won't break user code: when these are the locations we know. */ |
| 3358 | |
| 3359 | #ifndef YY_LOCATION_PRINT |
| 3360 | # if YYLTYPE_IS_TRIVIAL |
| 3361 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 3362 | fprintf (File, "%d.%d-%d.%d", \ |
| 3363 | (Loc).first_line, (Loc).first_column, \ |
| 3364 | (Loc).last_line, (Loc).last_column) |
| 3365 | # else |
| 3366 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 3367 | # endif |
| 3368 | #endif |
| 3369 | |
| 3370 | |
| 3371 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 3372 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3373 | #ifdef YYLEX_PARAM |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3374 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3375 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3376 | # define YYLEX yylex () |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3377 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3378 | |
| 3379 | /* Enable debugging if requested. */ |
| 3380 | #if YYDEBUG |
| 3381 | |
| 3382 | # ifndef YYFPRINTF |
| 3383 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 3384 | # define YYFPRINTF fprintf |
| 3385 | # endif |
| 3386 | |
| 3387 | # define YYDPRINTF(Args) \ |
| 3388 | do { \ |
| 3389 | if (yydebug) \ |
| 3390 | YYFPRINTF Args; \ |
| 3391 | } while (0) |
| 3392 | |
| 3393 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 3394 | do { \ |
| 3395 | if (yydebug) \ |
| 3396 | { \ |
| 3397 | YYFPRINTF (stderr, "%s ", Title); \ |
| 3398 | yysymprint (stderr, \ |
| 3399 | Type, Value); \ |
| 3400 | YYFPRINTF (stderr, "\n"); \ |
| 3401 | } \ |
| 3402 | } while (0) |
| 3403 | |
| 3404 | /*------------------------------------------------------------------. |
| 3405 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 3406 | | TOP (included). | |
| 3407 | `------------------------------------------------------------------*/ |
| 3408 | |
| 3409 | #if defined (__STDC__) || defined (__cplusplus) |
| 3410 | static void |
| 3411 | yy_stack_print (short int *bottom, short int *top) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3412 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3413 | static void |
| 3414 | yy_stack_print (bottom, top) |
| 3415 | short int *bottom; |
| 3416 | short int *top; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3417 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3418 | { |
| 3419 | YYFPRINTF (stderr, "Stack now"); |
| 3420 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 3421 | YYFPRINTF (stderr, " %d", *bottom); |
| 3422 | YYFPRINTF (stderr, "\n"); |
| 3423 | } |
| 3424 | |
| 3425 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 3426 | do { \ |
| 3427 | if (yydebug) \ |
| 3428 | yy_stack_print ((Bottom), (Top)); \ |
| 3429 | } while (0) |
| 3430 | |
| 3431 | |
| 3432 | /*------------------------------------------------. |
| 3433 | | Report that the YYRULE is going to be reduced. | |
| 3434 | `------------------------------------------------*/ |
| 3435 | |
| 3436 | #if defined (__STDC__) || defined (__cplusplus) |
| 3437 | static void |
| 3438 | yy_reduce_print (int yyrule) |
| 3439 | #else |
| 3440 | static void |
| 3441 | yy_reduce_print (yyrule) |
| 3442 | int yyrule; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3443 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3444 | { |
| 3445 | int yyi; |
| 3446 | unsigned long int yylno = yyrline[yyrule]; |
| 3447 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", |
| 3448 | yyrule - 1, yylno); |
| 3449 | /* Print the symbols being reduced, and their result. */ |
| 3450 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 3451 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
| 3452 | YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); |
| 3453 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3454 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3455 | # define YY_REDUCE_PRINT(Rule) \ |
| 3456 | do { \ |
| 3457 | if (yydebug) \ |
| 3458 | yy_reduce_print (Rule); \ |
| 3459 | } while (0) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3460 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3461 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 3462 | multiple parsers can coexist. */ |
| 3463 | int yydebug; |
| 3464 | #else /* !YYDEBUG */ |
| 3465 | # define YYDPRINTF(Args) |
| 3466 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 3467 | # define YY_STACK_PRINT(Bottom, Top) |
| 3468 | # define YY_REDUCE_PRINT(Rule) |
| 3469 | #endif /* !YYDEBUG */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3470 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3471 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3472 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3473 | #ifndef YYINITDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3474 | # define YYINITDEPTH 200 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3475 | #endif |
| 3476 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3477 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 3478 | if the built-in stack extension method is used). |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3479 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3480 | Do not make this value too large; the results are undefined if |
| 3481 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 3482 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3483 | |
| 3484 | #ifndef YYMAXDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3485 | # define YYMAXDEPTH 10000 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3486 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3487 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3488 | |
| 3489 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3490 | #if YYERROR_VERBOSE |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3491 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3492 | # ifndef yystrlen |
| 3493 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 3494 | # define yystrlen strlen |
| 3495 | # else |
| 3496 | /* Return the length of YYSTR. */ |
| 3497 | static YYSIZE_T |
| 3498 | # if defined (__STDC__) || defined (__cplusplus) |
| 3499 | yystrlen (const char *yystr) |
| 3500 | # else |
| 3501 | yystrlen (yystr) |
| 3502 | const char *yystr; |
| 3503 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3504 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3505 | const char *yys = yystr; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3506 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3507 | while (*yys++ != '\0') |
| 3508 | continue; |
| 3509 | |
| 3510 | return yys - yystr - 1; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3511 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3512 | # endif |
| 3513 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3514 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3515 | # ifndef yystpcpy |
| 3516 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 3517 | # define yystpcpy stpcpy |
| 3518 | # else |
| 3519 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 3520 | YYDEST. */ |
| 3521 | static char * |
| 3522 | # if defined (__STDC__) || defined (__cplusplus) |
| 3523 | yystpcpy (char *yydest, const char *yysrc) |
| 3524 | # else |
| 3525 | yystpcpy (yydest, yysrc) |
| 3526 | char *yydest; |
| 3527 | const char *yysrc; |
| 3528 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3529 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3530 | char *yyd = yydest; |
| 3531 | const char *yys = yysrc; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3532 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3533 | while ((*yyd++ = *yys++) != '\0') |
| 3534 | continue; |
| 3535 | |
| 3536 | return yyd - 1; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3537 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3538 | # endif |
| 3539 | # endif |
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 | # ifndef yytnamerr |
| 3542 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 3543 | quotes and backslashes, so that it's suitable for yyerror. The |
| 3544 | heuristic is that double-quoting is unnecessary unless the string |
| 3545 | contains an apostrophe, a comma, or backslash (other than |
| 3546 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 3547 | null, do not copy; instead, return the length of what the result |
| 3548 | would have been. */ |
| 3549 | static YYSIZE_T |
| 3550 | yytnamerr (char *yyres, const char *yystr) |
| 3551 | { |
| 3552 | if (*yystr == '"') |
| 3553 | { |
| 3554 | size_t yyn = 0; |
| 3555 | char const *yyp = yystr; |
| 3556 | |
| 3557 | for (;;) |
| 3558 | switch (*++yyp) |
| 3559 | { |
| 3560 | case '\'': |
| 3561 | case ',': |
| 3562 | goto do_not_strip_quotes; |
| 3563 | |
| 3564 | case '\\': |
| 3565 | if (*++yyp != '\\') |
| 3566 | goto do_not_strip_quotes; |
| 3567 | /* Fall through. */ |
| 3568 | default: |
| 3569 | if (yyres) |
| 3570 | yyres[yyn] = *yyp; |
| 3571 | yyn++; |
| 3572 | break; |
| 3573 | |
| 3574 | case '"': |
| 3575 | if (yyres) |
| 3576 | yyres[yyn] = '\0'; |
| 3577 | return yyn; |
| 3578 | } |
| 3579 | do_not_strip_quotes: ; |
| 3580 | } |
| 3581 | |
| 3582 | if (! yyres) |
| 3583 | return yystrlen (yystr); |
| 3584 | |
| 3585 | return yystpcpy (yyres, yystr) - yyres; |
| 3586 | } |
| 3587 | # endif |
| 3588 | |
| 3589 | #endif /* YYERROR_VERBOSE */ |
| 3590 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3591 | |
| 3592 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3593 | #if YYDEBUG |
| 3594 | /*--------------------------------. |
| 3595 | | Print this symbol on YYOUTPUT. | |
| 3596 | `--------------------------------*/ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3597 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3598 | #if defined (__STDC__) || defined (__cplusplus) |
| 3599 | static void |
| 3600 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3601 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3602 | static void |
| 3603 | yysymprint (yyoutput, yytype, yyvaluep) |
| 3604 | FILE *yyoutput; |
| 3605 | int yytype; |
| 3606 | YYSTYPE *yyvaluep; |
| 3607 | #endif |
| 3608 | { |
| 3609 | /* Pacify ``unused variable'' warnings. */ |
| 3610 | (void) yyvaluep; |
| 3611 | |
| 3612 | if (yytype < YYNTOKENS) |
| 3613 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 3614 | else |
| 3615 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 3616 | |
| 3617 | |
| 3618 | # ifdef YYPRINT |
| 3619 | if (yytype < YYNTOKENS) |
| 3620 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 3621 | # endif |
| 3622 | switch (yytype) |
| 3623 | { |
| 3624 | default: |
| 3625 | break; |
| 3626 | } |
| 3627 | YYFPRINTF (yyoutput, ")"); |
| 3628 | } |
| 3629 | |
| 3630 | #endif /* ! YYDEBUG */ |
| 3631 | /*-----------------------------------------------. |
| 3632 | | Release the memory associated to this symbol. | |
| 3633 | `-----------------------------------------------*/ |
| 3634 | |
| 3635 | #if defined (__STDC__) || defined (__cplusplus) |
| 3636 | static void |
| 3637 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 3638 | #else |
| 3639 | static void |
| 3640 | yydestruct (yymsg, yytype, yyvaluep) |
| 3641 | const char *yymsg; |
| 3642 | int yytype; |
| 3643 | YYSTYPE *yyvaluep; |
| 3644 | #endif |
| 3645 | { |
| 3646 | /* Pacify ``unused variable'' warnings. */ |
| 3647 | (void) yyvaluep; |
| 3648 | |
| 3649 | if (!yymsg) |
| 3650 | yymsg = "Deleting"; |
| 3651 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 3652 | |
| 3653 | switch (yytype) |
| 3654 | { |
| 3655 | |
| 3656 | default: |
| 3657 | break; |
| 3658 | } |
| 3659 | } |
| 3660 | |
| 3661 | |
| 3662 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 3663 | |
| 3664 | #ifdef YYPARSE_PARAM |
| 3665 | # if defined (__STDC__) || defined (__cplusplus) |
| 3666 | int yyparse (void *YYPARSE_PARAM); |
| 3667 | # else |
| 3668 | int yyparse (); |
| 3669 | # endif |
| 3670 | #else /* ! YYPARSE_PARAM */ |
| 3671 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3672 | int yyparse (void); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3673 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3674 | int yyparse (); |
| 3675 | #endif |
| 3676 | #endif /* ! YYPARSE_PARAM */ |
| 3677 | |
| 3678 | |
| 3679 | |
| 3680 | /* The look-ahead symbol. */ |
| 3681 | int yychar; |
| 3682 | |
| 3683 | /* The semantic value of the look-ahead symbol. */ |
| 3684 | YYSTYPE yylval; |
| 3685 | |
| 3686 | /* Number of syntax errors so far. */ |
| 3687 | int yynerrs; |
| 3688 | |
| 3689 | |
| 3690 | |
| 3691 | /*----------. |
| 3692 | | yyparse. | |
| 3693 | `----------*/ |
| 3694 | |
| 3695 | #ifdef YYPARSE_PARAM |
| 3696 | # if defined (__STDC__) || defined (__cplusplus) |
| 3697 | int yyparse (void *YYPARSE_PARAM) |
| 3698 | # else |
| 3699 | int yyparse (YYPARSE_PARAM) |
| 3700 | void *YYPARSE_PARAM; |
| 3701 | # endif |
| 3702 | #else /* ! YYPARSE_PARAM */ |
| 3703 | #if defined (__STDC__) || defined (__cplusplus) |
| 3704 | int |
| 3705 | yyparse (void) |
| 3706 | #else |
| 3707 | int |
| 3708 | yyparse () |
| 3709 | |
| 3710 | #endif |
| 3711 | #endif |
| 3712 | { |
| 3713 | |
| 3714 | int yystate; |
| 3715 | int yyn; |
| 3716 | int yyresult; |
| 3717 | /* Number of tokens to shift before error messages enabled. */ |
| 3718 | int yyerrstatus; |
| 3719 | /* Look-ahead token as an internal (translated) token number. */ |
| 3720 | int yytoken = 0; |
| 3721 | |
| 3722 | /* Three stacks and their tools: |
| 3723 | `yyss': related to states, |
| 3724 | `yyvs': related to semantic values, |
| 3725 | `yyls': related to locations. |
| 3726 | |
| 3727 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 3728 | to reallocate them elsewhere. */ |
| 3729 | |
| 3730 | /* The state stack. */ |
| 3731 | short int yyssa[YYINITDEPTH]; |
| 3732 | short int *yyss = yyssa; |
| 3733 | short int *yyssp; |
| 3734 | |
| 3735 | /* The semantic value stack. */ |
| 3736 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 3737 | YYSTYPE *yyvs = yyvsa; |
| 3738 | YYSTYPE *yyvsp; |
| 3739 | |
| 3740 | |
| 3741 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3742 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3743 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3744 | YYSIZE_T yystacksize = YYINITDEPTH; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3745 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3746 | /* The variables used to return semantic value and location from the |
| 3747 | action routines. */ |
| 3748 | YYSTYPE yyval; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3749 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3750 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3751 | /* When reducing, the number of symbols on the RHS of the reduced |
| 3752 | rule. */ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3753 | int yylen; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3754 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3755 | YYDPRINTF ((stderr, "Starting parse\n")); |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3756 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3757 | yystate = 0; |
| 3758 | yyerrstatus = 0; |
| 3759 | yynerrs = 0; |
| 3760 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 3761 | |
| 3762 | /* Initialize stack pointers. |
| 3763 | Waste one element of value and location stack |
| 3764 | so that they stay on the same level as the state stack. |
| 3765 | The wasted elements are never initialized. */ |
| 3766 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3767 | yyssp = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3768 | yyvsp = yyvs; |
| 3769 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3770 | goto yysetstate; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3771 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3772 | /*------------------------------------------------------------. |
| 3773 | | yynewstate -- Push a new state, which is found in yystate. | |
| 3774 | `------------------------------------------------------------*/ |
| 3775 | yynewstate: |
| 3776 | /* In all cases, when you get here, the value and location stacks |
| 3777 | have just been pushed. so pushing a state here evens the stacks. |
| 3778 | */ |
| 3779 | yyssp++; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3780 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3781 | yysetstate: |
| 3782 | *yyssp = yystate; |
| 3783 | |
| 3784 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3785 | { |
| 3786 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3787 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3788 | |
| 3789 | #ifdef yyoverflow |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3790 | { |
| 3791 | /* Give user a chance to reallocate the stack. Use copies of |
| 3792 | these so that the &'s don't force the real ones into |
| 3793 | memory. */ |
| 3794 | YYSTYPE *yyvs1 = yyvs; |
| 3795 | short int *yyss1 = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3796 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3797 | |
| 3798 | /* Each stack pointer address is followed by the size of the |
| 3799 | data in use in that stack, in bytes. This used to be a |
| 3800 | conditional around just the two extra args, but that might |
| 3801 | be undefined if yyoverflow is a macro. */ |
| 3802 | yyoverflow (YY_("memory exhausted"), |
| 3803 | &yyss1, yysize * sizeof (*yyssp), |
| 3804 | &yyvs1, yysize * sizeof (*yyvsp), |
| 3805 | |
| 3806 | &yystacksize); |
| 3807 | |
| 3808 | yyss = yyss1; |
| 3809 | yyvs = yyvs1; |
| 3810 | } |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3811 | #else /* no yyoverflow */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3812 | # ifndef YYSTACK_RELOCATE |
| 3813 | goto yyexhaustedlab; |
| 3814 | # else |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3815 | /* Extend the stack our own way. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3816 | if (YYMAXDEPTH <= yystacksize) |
| 3817 | goto yyexhaustedlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3818 | yystacksize *= 2; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3819 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3820 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3821 | |
| 3822 | { |
| 3823 | short int *yyss1 = yyss; |
| 3824 | union yyalloc *yyptr = |
| 3825 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 3826 | if (! yyptr) |
| 3827 | goto yyexhaustedlab; |
| 3828 | YYSTACK_RELOCATE (yyss); |
| 3829 | YYSTACK_RELOCATE (yyvs); |
| 3830 | |
| 3831 | # undef YYSTACK_RELOCATE |
| 3832 | if (yyss1 != yyssa) |
| 3833 | YYSTACK_FREE (yyss1); |
| 3834 | } |
| 3835 | # endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3836 | #endif /* no yyoverflow */ |
| 3837 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3838 | yyssp = yyss + yysize - 1; |
| 3839 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3840 | |
| 3841 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3842 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 3843 | (unsigned long int) yystacksize)); |
| 3844 | |
| 3845 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3846 | YYABORT; |
| 3847 | } |
| 3848 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3849 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3850 | |
| 3851 | goto yybackup; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3852 | |
| 3853 | /*-----------. |
| 3854 | | yybackup. | |
| 3855 | `-----------*/ |
| 3856 | yybackup: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3857 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3858 | /* Do appropriate processing given the current state. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3859 | /* 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] | 3860 | /* yyresume: */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3861 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3862 | /* 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] | 3863 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3864 | yyn = yypact[yystate]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3865 | if (yyn == YYPACT_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3866 | goto yydefault; |
| 3867 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3868 | /* 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] | 3869 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3870 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3871 | if (yychar == YYEMPTY) |
| 3872 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3873 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3874 | yychar = YYLEX; |
| 3875 | } |
| 3876 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3877 | if (yychar <= YYEOF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3878 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3879 | yychar = yytoken = YYEOF; |
| 3880 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3881 | } |
| 3882 | else |
| 3883 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3884 | yytoken = YYTRANSLATE (yychar); |
| 3885 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3886 | } |
| 3887 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3888 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 3889 | detect an error, take that action. */ |
| 3890 | yyn += yytoken; |
| 3891 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3892 | goto yydefault; |
| 3893 | yyn = yytable[yyn]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3894 | if (yyn <= 0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3895 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3896 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3897 | goto yyerrlab; |
| 3898 | yyn = -yyn; |
| 3899 | goto yyreduce; |
| 3900 | } |
| 3901 | |
| 3902 | if (yyn == YYFINAL) |
| 3903 | YYACCEPT; |
| 3904 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3905 | /* Shift the look-ahead token. */ |
| 3906 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3907 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3908 | /* Discard the token being shifted unless it is eof. */ |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3909 | if (yychar != YYEOF) |
| 3910 | yychar = YYEMPTY; |
| 3911 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3912 | *++yyvsp = yylval; |
| 3913 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3914 | |
| 3915 | /* Count tokens shifted since error; after three, turn off error |
| 3916 | status. */ |
| 3917 | if (yyerrstatus) |
| 3918 | yyerrstatus--; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3919 | |
| 3920 | yystate = yyn; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3921 | goto yynewstate; |
| 3922 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3923 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3924 | /*-----------------------------------------------------------. |
| 3925 | | yydefault -- do the default action for the current state. | |
| 3926 | `-----------------------------------------------------------*/ |
| 3927 | yydefault: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3928 | yyn = yydefact[yystate]; |
| 3929 | if (yyn == 0) |
| 3930 | goto yyerrlab; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3931 | goto yyreduce; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3932 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3933 | |
| 3934 | /*-----------------------------. |
| 3935 | | yyreduce -- Do a reduction. | |
| 3936 | `-----------------------------*/ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3937 | yyreduce: |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3938 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3939 | yylen = yyr2[yyn]; |
| 3940 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3941 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3942 | `$$ = $1'. |
| 3943 | |
| 3944 | Otherwise, the following line sets YYVAL to garbage. |
| 3945 | This behavior is undocumented and Bison |
| 3946 | users should not rely upon it. Assigning to YYVAL |
| 3947 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3948 | GCC warning that YYVAL may be used uninitialized. */ |
| 3949 | yyval = yyvsp[1-yylen]; |
| 3950 | |
| 3951 | |
| 3952 | YY_REDUCE_PRINT (yyn); |
| 3953 | switch (yyn) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3954 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3955 | case 3: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 3956 | #line 1882 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3957 | { |
| 3958 | if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3959 | error("Value too large for type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3960 | (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); |
| 3961 | ;} |
| 3962 | break; |
| 3963 | |
| 3964 | case 5: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 3965 | #line 1891 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3966 | { |
| 3967 | if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3968 | error("Value too large for type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3969 | (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val); |
| 3970 | ;} |
| 3971 | break; |
| 3972 | |
| 3973 | case 26: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 3974 | #line 1913 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3975 | { (yyval.IPred) = ICmpInst::ICMP_EQ; ;} |
| 3976 | break; |
| 3977 | |
| 3978 | case 27: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 3979 | #line 1913 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3980 | { (yyval.IPred) = ICmpInst::ICMP_NE; ;} |
| 3981 | break; |
| 3982 | |
| 3983 | case 28: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 3984 | #line 1914 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3985 | { (yyval.IPred) = ICmpInst::ICMP_SLT; ;} |
| 3986 | break; |
| 3987 | |
| 3988 | case 29: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 3989 | #line 1914 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3990 | { (yyval.IPred) = ICmpInst::ICMP_SGT; ;} |
| 3991 | break; |
| 3992 | |
| 3993 | case 30: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 3994 | #line 1915 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3995 | { (yyval.IPred) = ICmpInst::ICMP_SLE; ;} |
| 3996 | break; |
| 3997 | |
| 3998 | case 31: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 3999 | #line 1915 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4000 | { (yyval.IPred) = ICmpInst::ICMP_SGE; ;} |
| 4001 | break; |
| 4002 | |
| 4003 | case 32: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4004 | #line 1916 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4005 | { (yyval.IPred) = ICmpInst::ICMP_ULT; ;} |
| 4006 | break; |
| 4007 | |
| 4008 | case 33: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4009 | #line 1916 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4010 | { (yyval.IPred) = ICmpInst::ICMP_UGT; ;} |
| 4011 | break; |
| 4012 | |
| 4013 | case 34: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4014 | #line 1917 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4015 | { (yyval.IPred) = ICmpInst::ICMP_ULE; ;} |
| 4016 | break; |
| 4017 | |
| 4018 | case 35: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4019 | #line 1917 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4020 | { (yyval.IPred) = ICmpInst::ICMP_UGE; ;} |
| 4021 | break; |
| 4022 | |
| 4023 | case 36: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4024 | #line 1921 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4025 | { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;} |
| 4026 | break; |
| 4027 | |
| 4028 | case 37: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4029 | #line 1921 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4030 | { (yyval.FPred) = FCmpInst::FCMP_ONE; ;} |
| 4031 | break; |
| 4032 | |
| 4033 | case 38: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4034 | #line 1922 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4035 | { (yyval.FPred) = FCmpInst::FCMP_OLT; ;} |
| 4036 | break; |
| 4037 | |
| 4038 | case 39: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4039 | #line 1922 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4040 | { (yyval.FPred) = FCmpInst::FCMP_OGT; ;} |
| 4041 | break; |
| 4042 | |
| 4043 | case 40: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4044 | #line 1923 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4045 | { (yyval.FPred) = FCmpInst::FCMP_OLE; ;} |
| 4046 | break; |
| 4047 | |
| 4048 | case 41: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4049 | #line 1923 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4050 | { (yyval.FPred) = FCmpInst::FCMP_OGE; ;} |
| 4051 | break; |
| 4052 | |
| 4053 | case 42: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4054 | #line 1924 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4055 | { (yyval.FPred) = FCmpInst::FCMP_ORD; ;} |
| 4056 | break; |
| 4057 | |
| 4058 | case 43: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4059 | #line 1924 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4060 | { (yyval.FPred) = FCmpInst::FCMP_UNO; ;} |
| 4061 | break; |
| 4062 | |
| 4063 | case 44: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4064 | #line 1925 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4065 | { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;} |
| 4066 | break; |
| 4067 | |
| 4068 | case 45: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4069 | #line 1925 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4070 | { (yyval.FPred) = FCmpInst::FCMP_UNE; ;} |
| 4071 | break; |
| 4072 | |
| 4073 | case 46: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4074 | #line 1926 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4075 | { (yyval.FPred) = FCmpInst::FCMP_ULT; ;} |
| 4076 | break; |
| 4077 | |
| 4078 | case 47: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4079 | #line 1926 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4080 | { (yyval.FPred) = FCmpInst::FCMP_UGT; ;} |
| 4081 | break; |
| 4082 | |
| 4083 | case 48: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4084 | #line 1927 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4085 | { (yyval.FPred) = FCmpInst::FCMP_ULE; ;} |
| 4086 | break; |
| 4087 | |
| 4088 | case 49: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4089 | #line 1927 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4090 | { (yyval.FPred) = FCmpInst::FCMP_UGE; ;} |
| 4091 | break; |
| 4092 | |
| 4093 | case 50: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4094 | #line 1928 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4095 | { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;} |
| 4096 | break; |
| 4097 | |
| 4098 | case 51: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4099 | #line 1929 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4100 | { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;} |
| 4101 | break; |
| 4102 | |
| 4103 | case 81: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4104 | #line 1960 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4105 | { |
| 4106 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
| 4107 | ;} |
| 4108 | break; |
| 4109 | |
| 4110 | case 82: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4111 | #line 1963 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4112 | { |
| 4113 | (yyval.StrVal) = 0; |
| 4114 | ;} |
| 4115 | break; |
| 4116 | |
| 4117 | case 83: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4118 | #line 1968 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4119 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 4120 | break; |
| 4121 | |
| 4122 | case 84: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4123 | #line 1969 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4124 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 4125 | break; |
| 4126 | |
| 4127 | case 85: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4128 | #line 1970 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4129 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 4130 | break; |
| 4131 | |
| 4132 | case 86: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4133 | #line 1971 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4134 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 4135 | break; |
| 4136 | |
| 4137 | case 87: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4138 | #line 1972 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4139 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 4140 | break; |
| 4141 | |
| 4142 | case 88: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4143 | #line 1973 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4144 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 4145 | break; |
| 4146 | |
| 4147 | case 89: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4148 | #line 1974 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4149 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 4150 | break; |
| 4151 | |
| 4152 | case 90: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4153 | #line 1975 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4154 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 4155 | break; |
| 4156 | |
| 4157 | case 91: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4158 | #line 1979 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4159 | { (yyval.UIntVal) = OldCallingConv::C; ;} |
| 4160 | break; |
| 4161 | |
| 4162 | case 92: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4163 | #line 1980 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4164 | { (yyval.UIntVal) = OldCallingConv::C; ;} |
| 4165 | break; |
| 4166 | |
| 4167 | case 93: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4168 | #line 1981 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4169 | { (yyval.UIntVal) = OldCallingConv::CSRet; ;} |
| 4170 | break; |
| 4171 | |
| 4172 | case 94: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4173 | #line 1982 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4174 | { (yyval.UIntVal) = OldCallingConv::Fast; ;} |
| 4175 | break; |
| 4176 | |
| 4177 | case 95: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4178 | #line 1983 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4179 | { (yyval.UIntVal) = OldCallingConv::Cold; ;} |
| 4180 | break; |
| 4181 | |
| 4182 | case 96: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4183 | #line 1984 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4184 | { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;} |
| 4185 | break; |
| 4186 | |
| 4187 | case 97: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4188 | #line 1985 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4189 | { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;} |
| 4190 | break; |
| 4191 | |
| 4192 | case 98: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4193 | #line 1986 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4194 | { |
| 4195 | if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4196 | error("Calling conv too large"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4197 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 4198 | ;} |
| 4199 | break; |
| 4200 | |
| 4201 | case 99: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4202 | #line 1996 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4203 | { (yyval.UIntVal) = 0; ;} |
| 4204 | break; |
| 4205 | |
| 4206 | case 100: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4207 | #line 1997 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4208 | { |
| 4209 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 4210 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4211 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4212 | ;} |
| 4213 | break; |
| 4214 | |
| 4215 | case 101: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4216 | #line 2005 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4217 | { (yyval.UIntVal) = 0; ;} |
| 4218 | break; |
| 4219 | |
| 4220 | case 102: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4221 | #line 2006 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4222 | { |
| 4223 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 4224 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4225 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4226 | ;} |
| 4227 | break; |
| 4228 | |
| 4229 | case 103: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4230 | #line 2014 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4231 | { |
| 4232 | for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) |
| 4233 | if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4234 | error("Invalid character in section name"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4235 | (yyval.StrVal) = (yyvsp[0].StrVal); |
| 4236 | ;} |
| 4237 | break; |
| 4238 | |
| 4239 | case 104: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4240 | #line 2023 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4241 | { (yyval.StrVal) = 0; ;} |
| 4242 | break; |
| 4243 | |
| 4244 | case 105: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4245 | #line 2024 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4246 | { (yyval.StrVal) = (yyvsp[0].StrVal); ;} |
| 4247 | break; |
| 4248 | |
| 4249 | case 106: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4250 | #line 2031 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4251 | {;} |
| 4252 | break; |
| 4253 | |
| 4254 | case 107: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4255 | #line 2032 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4256 | {;} |
| 4257 | break; |
| 4258 | |
| 4259 | case 108: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4260 | #line 2036 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4261 | { |
| 4262 | CurGV->setSection((yyvsp[0].StrVal)); |
| 4263 | free((yyvsp[0].StrVal)); |
| 4264 | ;} |
| 4265 | break; |
| 4266 | |
| 4267 | case 109: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4268 | #line 2040 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4269 | { |
| 4270 | if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4271 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4272 | CurGV->setAlignment((yyvsp[0].UInt64Val)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4273 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4274 | ;} |
| 4275 | break; |
| 4276 | |
| 4277 | case 111: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4278 | #line 2057 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4279 | { |
| 4280 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4281 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4282 | ;} |
| 4283 | break; |
| 4284 | |
| 4285 | case 113: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4286 | #line 2065 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4287 | { |
| 4288 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4289 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4290 | ;} |
| 4291 | break; |
| 4292 | |
| 4293 | case 114: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4294 | #line 2072 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4295 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4296 | if (!UpRefs.empty()) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4297 | error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription()); |
| 4298 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
| 4299 | ;} |
| 4300 | break; |
| 4301 | |
| 4302 | case 127: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4303 | #line 2086 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4304 | { |
| 4305 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4306 | (yyval.TypeVal).S.copy((yyvsp[0].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4307 | ;} |
| 4308 | break; |
| 4309 | |
| 4310 | case 128: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4311 | #line 2090 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4312 | { |
| 4313 | (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4314 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4315 | ;} |
| 4316 | break; |
| 4317 | |
| 4318 | case 129: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4319 | #line 2094 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4320 | { // Named types are also simple types... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4321 | (yyval.TypeVal).S.copy(getTypeSign((yyvsp[0].ValIDVal))); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4322 | const Type* tmp = getType((yyvsp[0].ValIDVal)); |
| 4323 | (yyval.TypeVal).PAT = new PATypeHolder(tmp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4324 | ;} |
| 4325 | break; |
| 4326 | |
| 4327 | case 130: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4328 | #line 2099 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4329 | { // Type UpReference |
| 4330 | if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4331 | error("Value out of range"); |
| 4332 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4333 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... |
| 4334 | (yyval.TypeVal).PAT = new PATypeHolder(OT); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4335 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4336 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4337 | ;} |
| 4338 | break; |
| 4339 | |
| 4340 | case 131: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4341 | #line 2108 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4342 | { // Function derived type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4343 | (yyval.TypeVal).S.makeComposite((yyvsp[-3].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4344 | std::vector<const Type*> Params; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4345 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 4346 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4347 | Params.push_back(I->PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4348 | (yyval.TypeVal).S.add(I->S); |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4349 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4350 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 4351 | if (isVarArg) Params.pop_back(); |
| 4352 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4353 | const FunctionType *FTy = |
| 4354 | FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg, 0); |
| 4355 | |
| 4356 | (yyval.TypeVal).PAT = new PATypeHolder( HandleUpRefs(FTy, (yyval.TypeVal).S) ); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4357 | delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4358 | delete (yyvsp[-1].TypeList); // Delete the argument list |
| 4359 | ;} |
| 4360 | break; |
| 4361 | |
| 4362 | case 132: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4363 | #line 2126 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4364 | { // Sized array type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4365 | (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4366 | (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] | 4367 | (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4368 | delete (yyvsp[-1].TypeVal).PAT; |
| 4369 | ;} |
| 4370 | break; |
| 4371 | |
| 4372 | case 133: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4373 | #line 2132 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4374 | { // Vector type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4375 | const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get(); |
| 4376 | if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) |
| 4377 | error("Unsigned result not equal to signed result"); |
| 4378 | if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint())) |
| 4379 | error("Elements of a VectorType must be integer or floating point"); |
| 4380 | if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) |
| 4381 | error("VectorType length should be a power of 2"); |
| 4382 | (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
| 4383 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, |
| 4384 | (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S)); |
| 4385 | delete (yyvsp[-1].TypeVal).PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4386 | ;} |
| 4387 | break; |
| 4388 | |
| 4389 | case 134: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4390 | #line 2145 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4391 | { // Structure type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4392 | std::vector<const Type*> Elements; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4393 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4394 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(), |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4395 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4396 | Elements.push_back(I->PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4397 | (yyval.TypeVal).S.add(I->S); |
| 4398 | } |
| 4399 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4400 | delete (yyvsp[-1].TypeList); |
| 4401 | ;} |
| 4402 | break; |
| 4403 | |
| 4404 | case 135: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4405 | #line 2156 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4406 | { // Empty structure type? |
| 4407 | (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4408 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4409 | ;} |
| 4410 | break; |
| 4411 | |
| 4412 | case 136: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4413 | #line 2160 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4414 | { // Packed Structure type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4415 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4416 | std::vector<const Type*> Elements; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4417 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(), |
| 4418 | E = (yyvsp[-2].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4419 | Elements.push_back(I->PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4420 | (yyval.TypeVal).S.add(I->S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4421 | delete I->PAT; |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4422 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4423 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true), |
| 4424 | (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4425 | delete (yyvsp[-2].TypeList); |
| 4426 | ;} |
| 4427 | break; |
| 4428 | |
| 4429 | case 137: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4430 | #line 2173 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4431 | { // Empty packed structure type? |
| 4432 | (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4433 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4434 | ;} |
| 4435 | break; |
| 4436 | |
| 4437 | case 138: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4438 | #line 2177 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4439 | { // Pointer type? |
| 4440 | if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4441 | error("Cannot form a pointer to a basic block"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4442 | (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
| 4443 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get()), |
| 4444 | (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4445 | delete (yyvsp[-1].TypeVal).PAT; |
| 4446 | ;} |
| 4447 | break; |
| 4448 | |
| 4449 | case 139: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4450 | #line 2191 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4451 | { |
| 4452 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
| 4453 | (yyval.TypeList)->push_back((yyvsp[0].TypeVal)); |
| 4454 | ;} |
| 4455 | break; |
| 4456 | |
| 4457 | case 140: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4458 | #line 2195 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4459 | { |
| 4460 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal)); |
| 4461 | ;} |
| 4462 | break; |
| 4463 | |
| 4464 | case 142: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4465 | #line 2203 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4466 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4467 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4468 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4469 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4470 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI); |
| 4471 | ;} |
| 4472 | break; |
| 4473 | |
| 4474 | case 143: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4475 | #line 2209 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4476 | { |
| 4477 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4478 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4479 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4480 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4481 | (yyval.TypeList)->push_back(VoidTI); |
| 4482 | ;} |
| 4483 | break; |
| 4484 | |
| 4485 | case 144: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4486 | #line 2216 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4487 | { |
| 4488 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
| 4489 | ;} |
| 4490 | break; |
| 4491 | |
| 4492 | case 145: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4493 | #line 2228 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4494 | { // Nonempty unsized arr |
| 4495 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4496 | if (ATy == 0) |
| 4497 | error("Cannot make array constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4498 | (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4499 | const Type *ETy = ATy->getElementType(); |
| 4500 | int NumElements = ATy->getNumElements(); |
| 4501 | |
| 4502 | // Verify that we have the correct size... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4503 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4504 | error("Type mismatch: constant sized array initialized with " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4505 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4506 | itostr(NumElements) + ""); |
| 4507 | |
| 4508 | // Verify all elements are correct type! |
| 4509 | std::vector<Constant*> Elems; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4510 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4511 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4512 | const Type* ValTy = C->getType(); |
| 4513 | if (ETy != ValTy) |
| 4514 | error("Element #" + utostr(i) + " is not of type '" + |
| 4515 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4516 | ValTy->getDescription() + "'"); |
| 4517 | Elems.push_back(C); |
| 4518 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4519 | (yyval.ConstVal).C = ConstantArray::get(ATy, Elems); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4520 | (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4521 | delete (yyvsp[-3].TypeVal).PAT; |
| 4522 | delete (yyvsp[-1].ConstVector); |
| 4523 | ;} |
| 4524 | break; |
| 4525 | |
| 4526 | case 146: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4527 | #line 2258 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4528 | { |
| 4529 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4530 | if (ATy == 0) |
| 4531 | error("Cannot make array constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4532 | (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4533 | int NumElements = ATy->getNumElements(); |
| 4534 | if (NumElements != -1 && NumElements != 0) |
| 4535 | error("Type mismatch: constant sized array initialized with 0" |
| 4536 | " arguments, but has size of " + itostr(NumElements) +""); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4537 | (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4538 | (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4539 | delete (yyvsp[-2].TypeVal).PAT; |
| 4540 | ;} |
| 4541 | break; |
| 4542 | |
| 4543 | case 147: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4544 | #line 2271 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4545 | { |
| 4546 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4547 | if (ATy == 0) |
| 4548 | error("Cannot make array constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4549 | (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4550 | int NumElements = ATy->getNumElements(); |
| 4551 | const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType()); |
| 4552 | if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8) |
| 4553 | error("String arrays require type i8, not '" + ETy->getDescription() + |
| 4554 | "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4555 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4556 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4557 | error("Can't build string constant of size " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4558 | itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4559 | itostr(NumElements) + ""); |
| 4560 | std::vector<Constant*> Vals; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4561 | for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4562 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4563 | free((yyvsp[0].StrVal)); |
| 4564 | (yyval.ConstVal).C = ConstantArray::get(ATy, Vals); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4565 | (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4566 | delete (yyvsp[-2].TypeVal).PAT; |
| 4567 | ;} |
| 4568 | break; |
| 4569 | |
| 4570 | case 148: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4571 | #line 2294 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4572 | { // Nonempty unsized arr |
| 4573 | const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4574 | if (PTy == 0) |
| 4575 | error("Cannot make packed constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4576 | (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4577 | const Type *ETy = PTy->getElementType(); |
| 4578 | int NumElements = PTy->getNumElements(); |
| 4579 | // Verify that we have the correct size... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4580 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4581 | error("Type mismatch: constant sized packed initialized with " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4582 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4583 | itostr(NumElements) + ""); |
| 4584 | // Verify all elements are correct type! |
| 4585 | std::vector<Constant*> Elems; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4586 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4587 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4588 | const Type* ValTy = C->getType(); |
| 4589 | if (ETy != ValTy) |
| 4590 | error("Element #" + utostr(i) + " is not of type '" + |
| 4591 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4592 | ValTy->getDescription() + "'"); |
| 4593 | Elems.push_back(C); |
| 4594 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4595 | (yyval.ConstVal).C = ConstantVector::get(PTy, Elems); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4596 | (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4597 | delete (yyvsp[-3].TypeVal).PAT; |
| 4598 | delete (yyvsp[-1].ConstVector); |
| 4599 | ;} |
| 4600 | break; |
| 4601 | |
| 4602 | case 149: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4603 | #line 2322 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4604 | { |
| 4605 | const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4606 | if (STy == 0) |
| 4607 | error("Cannot make struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4608 | (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); |
| 4609 | if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4610 | error("Illegal number of initializers for structure type"); |
| 4611 | |
| 4612 | // Check to ensure that constants are compatible with the type initializer! |
| 4613 | std::vector<Constant*> Fields; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4614 | for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) { |
| 4615 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4616 | if (C->getType() != STy->getElementType(i)) |
| 4617 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4618 | "' for element #" + utostr(i) + " of structure initializer"); |
| 4619 | Fields.push_back(C); |
| 4620 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4621 | (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4622 | (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4623 | delete (yyvsp[-3].TypeVal).PAT; |
| 4624 | delete (yyvsp[-1].ConstVector); |
| 4625 | ;} |
| 4626 | break; |
| 4627 | |
| 4628 | case 150: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4629 | #line 2344 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4630 | { |
| 4631 | const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4632 | if (STy == 0) |
| 4633 | error("Cannot make struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4634 | (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4635 | if (STy->getNumContainedTypes() != 0) |
| 4636 | error("Illegal number of initializers for structure type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4637 | (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4638 | (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4639 | delete (yyvsp[-2].TypeVal).PAT; |
| 4640 | ;} |
| 4641 | break; |
| 4642 | |
| 4643 | case 151: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4644 | #line 2355 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4645 | { |
| 4646 | const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4647 | if (STy == 0) |
| 4648 | error("Cannot make packed struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4649 | (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'"); |
| 4650 | if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4651 | error("Illegal number of initializers for packed structure type"); |
| 4652 | |
| 4653 | // Check to ensure that constants are compatible with the type initializer! |
| 4654 | std::vector<Constant*> Fields; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4655 | for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) { |
| 4656 | Constant *C = (*(yyvsp[-2].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4657 | if (C->getType() != STy->getElementType(i)) |
| 4658 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4659 | "' for element #" + utostr(i) + " of packed struct initializer"); |
| 4660 | Fields.push_back(C); |
| 4661 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4662 | (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4663 | (yyval.ConstVal).S.copy((yyvsp[-5].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4664 | delete (yyvsp[-5].TypeVal).PAT; |
| 4665 | delete (yyvsp[-2].ConstVector); |
| 4666 | ;} |
| 4667 | break; |
| 4668 | |
| 4669 | case 152: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4670 | #line 2377 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4671 | { |
| 4672 | const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4673 | if (STy == 0) |
| 4674 | error("Cannot make packed struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4675 | (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4676 | if (STy->getNumContainedTypes() != 0) |
| 4677 | error("Illegal number of initializers for packed structure type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4678 | (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4679 | (yyval.ConstVal).S.copy((yyvsp[-4].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4680 | delete (yyvsp[-4].TypeVal).PAT; |
| 4681 | ;} |
| 4682 | break; |
| 4683 | |
| 4684 | case 153: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4685 | #line 2388 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4686 | { |
| 4687 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4688 | if (PTy == 0) |
| 4689 | error("Cannot make null pointer constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4690 | (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'"); |
| 4691 | (yyval.ConstVal).C = ConstantPointerNull::get(PTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4692 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4693 | delete (yyvsp[-1].TypeVal).PAT; |
| 4694 | ;} |
| 4695 | break; |
| 4696 | |
| 4697 | case 154: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4698 | #line 2397 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4699 | { |
| 4700 | (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4701 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4702 | delete (yyvsp[-1].TypeVal).PAT; |
| 4703 | ;} |
| 4704 | break; |
| 4705 | |
| 4706 | case 155: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4707 | #line 2402 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4708 | { |
| 4709 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4710 | if (Ty == 0) |
| 4711 | error("Global const reference must be a pointer type, not" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4712 | (yyvsp[-1].TypeVal).PAT->get()->getDescription()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4713 | |
| 4714 | // ConstExprs can exist in the body of a function, thus creating |
| 4715 | // GlobalValues whenever they refer to a variable. Because we are in |
| 4716 | // the context of a function, getExistingValue will search the functions |
| 4717 | // symbol table instead of the module symbol table for the global symbol, |
| 4718 | // which throws things all off. To get around this, we just tell |
| 4719 | // getExistingValue that we are at global scope here. |
| 4720 | // |
| 4721 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 4722 | CurFun.CurrentFunction = 0; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4723 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4724 | Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4725 | CurFun.CurrentFunction = SavedCurFn; |
| 4726 | |
| 4727 | // If this is an initializer for a constant pointer, which is referencing a |
| 4728 | // (currently) undefined variable, create a stub now that shall be replaced |
| 4729 | // in the future with the right type of variable. |
| 4730 | // |
| 4731 | if (V == 0) { |
| 4732 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers"); |
| 4733 | const PointerType *PT = cast<PointerType>(Ty); |
| 4734 | |
| 4735 | // First check to see if the forward references value is already created! |
| 4736 | PerModuleInfo::GlobalRefsType::iterator I = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4737 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4738 | |
| 4739 | if (I != CurModule.GlobalRefs.end()) { |
| 4740 | V = I->second; // Placeholder already exists, use it... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4741 | (yyvsp[0].ValIDVal).destroy(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4742 | } else { |
| 4743 | std::string Name; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4744 | if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4745 | |
| 4746 | // Create the forward referenced global. |
| 4747 | GlobalValue *GV; |
| 4748 | if (const FunctionType *FTy = |
| 4749 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 4750 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 4751 | CurModule.CurrentModule); |
| 4752 | } else { |
| 4753 | GV = new GlobalVariable(PT->getElementType(), false, |
| 4754 | GlobalValue::ExternalLinkage, 0, |
| 4755 | Name, CurModule.CurrentModule); |
| 4756 | } |
| 4757 | |
| 4758 | // 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] | 4759 | 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] | 4760 | V = GV; |
| 4761 | } |
| 4762 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4763 | (yyval.ConstVal).C = cast<GlobalValue>(V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4764 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4765 | delete (yyvsp[-1].TypeVal).PAT; // Free the type handle |
| 4766 | ;} |
| 4767 | break; |
| 4768 | |
| 4769 | case 156: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4770 | #line 2461 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4771 | { |
| 4772 | if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4773 | error("Mismatched types for constant expression"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4774 | (yyval.ConstVal) = (yyvsp[0].ConstVal); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4775 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4776 | delete (yyvsp[-1].TypeVal).PAT; |
| 4777 | ;} |
| 4778 | break; |
| 4779 | |
| 4780 | case 157: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4781 | #line 2468 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4782 | { |
| 4783 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4784 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 4785 | error("Cannot create a null initialized value of this type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4786 | (yyval.ConstVal).C = Constant::getNullValue(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4787 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4788 | delete (yyvsp[-1].TypeVal).PAT; |
| 4789 | ;} |
| 4790 | break; |
| 4791 | |
| 4792 | case 158: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4793 | #line 2476 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4794 | { // integral constants |
| 4795 | const Type *Ty = (yyvsp[-1].PrimType).T; |
| 4796 | if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4797 | error("Constant value doesn't fit in type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4798 | (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4799 | (yyval.ConstVal).S.makeSigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4800 | ;} |
| 4801 | break; |
| 4802 | |
| 4803 | case 159: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4804 | #line 2483 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4805 | { // integral constants |
| 4806 | const Type *Ty = (yyvsp[-1].PrimType).T; |
| 4807 | if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4808 | error("Constant value doesn't fit in type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4809 | (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4810 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4811 | ;} |
| 4812 | break; |
| 4813 | |
| 4814 | case 160: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4815 | #line 2490 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4816 | { // Boolean constants |
| 4817 | (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4818 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4819 | ;} |
| 4820 | break; |
| 4821 | |
| 4822 | case 161: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4823 | #line 2494 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4824 | { // Boolean constants |
| 4825 | (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4826 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4827 | ;} |
| 4828 | break; |
| 4829 | |
| 4830 | case 162: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4831 | #line 2498 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4832 | { // Float & Double constants |
| 4833 | if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4834 | error("Floating point constant invalid for type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4835 | (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4836 | (yyval.ConstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4837 | ;} |
| 4838 | break; |
| 4839 | |
| 4840 | case 163: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4841 | #line 2507 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4842 | { |
| 4843 | const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType(); |
| 4844 | const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4845 | Signedness SrcSign((yyvsp[-3].ConstVal).S); |
| 4846 | Signedness DstSign((yyvsp[-1].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4847 | if (!SrcTy->isFirstClassType()) |
| 4848 | error("cast constant expression from a non-primitive type: '" + |
| 4849 | SrcTy->getDescription() + "'"); |
| 4850 | if (!DstTy->isFirstClassType()) |
| 4851 | error("cast constant expression to a non-primitive type: '" + |
| 4852 | DstTy->getDescription() + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4853 | (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] | 4854 | (yyval.ConstVal).S.copy(DstSign); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4855 | delete (yyvsp[-1].TypeVal).PAT; |
| 4856 | ;} |
| 4857 | break; |
| 4858 | |
| 4859 | case 164: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4860 | #line 2522 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4861 | { |
| 4862 | const Type *Ty = (yyvsp[-2].ConstVal).C->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4863 | if (!isa<PointerType>(Ty)) |
| 4864 | error("GetElementPtr requires a pointer operand"); |
| 4865 | |
| 4866 | std::vector<Value*> VIndices; |
| 4867 | std::vector<Constant*> CIndices; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4868 | upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4869 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4870 | delete (yyvsp[-1].ValueList); |
| 4871 | (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] | 4872 | (yyval.ConstVal).S.copy(getElementSign((yyvsp[-2].ConstVal), CIndices)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4873 | ;} |
| 4874 | break; |
| 4875 | |
| 4876 | case 165: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4877 | #line 2535 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4878 | { |
| 4879 | if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() || |
| 4880 | cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4881 | error("Select condition must be bool type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4882 | if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4883 | error("Select operand types must match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4884 | (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] | 4885 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4886 | ;} |
| 4887 | break; |
| 4888 | |
| 4889 | case 166: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4890 | #line 2544 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4891 | { |
| 4892 | const Type *Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4893 | if (Ty != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4894 | error("Binary operator types must match"); |
| 4895 | // First, make sure we're dealing with the right opcode by upgrading from |
| 4896 | // obsolete versions. |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4897 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4898 | |
| 4899 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 4900 | // To retain backward compatibility with these early compilers, we emit a |
| 4901 | // cast to the appropriate integer type automatically if we are in the |
| 4902 | // broken case. See PR424 for more information. |
| 4903 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4904 | (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] | 4905 | } else { |
| 4906 | const Type *IntPtrTy = 0; |
| 4907 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 4908 | case Module::Pointer32: IntPtrTy = Type::Int32Ty; break; |
| 4909 | case Module::Pointer64: IntPtrTy = Type::Int64Ty; break; |
| 4910 | default: error("invalid pointer binary constant expr"); |
| 4911 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4912 | (yyval.ConstVal).C = ConstantExpr::get(Opcode, |
| 4913 | ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy), |
| 4914 | ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy)); |
| 4915 | (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4916 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4917 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4918 | ;} |
| 4919 | break; |
| 4920 | |
| 4921 | case 167: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4922 | #line 2572 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4923 | { |
| 4924 | const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4925 | if (Ty != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4926 | error("Logical operator types must match"); |
| 4927 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4928 | if (!isa<VectorType>(Ty) || |
| 4929 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4930 | error("Logical operator requires integer operands"); |
| 4931 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4932 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S); |
| 4933 | (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] | 4934 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4935 | ;} |
| 4936 | break; |
| 4937 | |
| 4938 | case 168: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4939 | #line 2585 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4940 | { |
| 4941 | const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4942 | if (Ty != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4943 | error("setcc operand types must match"); |
| 4944 | unsigned short pred; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4945 | Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S); |
| 4946 | (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] | 4947 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4948 | ;} |
| 4949 | break; |
| 4950 | |
| 4951 | case 169: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4952 | #line 2594 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4953 | { |
| 4954 | if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4955 | error("icmp operand types must match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4956 | (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] | 4957 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4958 | ;} |
| 4959 | break; |
| 4960 | |
| 4961 | case 170: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4962 | #line 2600 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4963 | { |
| 4964 | if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4965 | error("fcmp operand types must match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4966 | (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] | 4967 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4968 | ;} |
| 4969 | break; |
| 4970 | |
| 4971 | case 171: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4972 | #line 2606 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4973 | { |
| 4974 | if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() || |
| 4975 | cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4976 | error("Shift count for shift constant must be unsigned byte"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4977 | const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4978 | if (!(yyvsp[-3].ConstVal).C->getType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4979 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4980 | Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty); |
| 4981 | (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] | 4982 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4983 | ;} |
| 4984 | break; |
| 4985 | |
| 4986 | case 172: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4987 | #line 2617 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4988 | { |
| 4989 | if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4990 | error("Invalid extractelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4991 | (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] | 4992 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4993 | ;} |
| 4994 | break; |
| 4995 | |
| 4996 | case 173: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 4997 | #line 2623 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4998 | { |
| 4999 | 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] | 5000 | error("Invalid insertelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5001 | (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] | 5002 | (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5003 | ;} |
| 5004 | break; |
| 5005 | |
| 5006 | case 174: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5007 | #line 2629 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5008 | { |
| 5009 | 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] | 5010 | error("Invalid shufflevector operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5011 | (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] | 5012 | (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5013 | ;} |
| 5014 | break; |
| 5015 | |
| 5016 | case 175: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5017 | #line 2640 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5018 | { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;} |
| 5019 | break; |
| 5020 | |
| 5021 | case 176: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5022 | #line 2641 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5023 | { |
| 5024 | (yyval.ConstVector) = new std::vector<ConstInfo>(); |
| 5025 | (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); |
| 5026 | ;} |
| 5027 | break; |
| 5028 | |
| 5029 | case 177: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5030 | #line 2650 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5031 | { (yyval.BoolVal) = false; ;} |
| 5032 | break; |
| 5033 | |
| 5034 | case 178: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5035 | #line 2651 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5036 | { (yyval.BoolVal) = true; ;} |
| 5037 | break; |
| 5038 | |
| 5039 | case 179: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5040 | #line 2663 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5041 | { |
| 5042 | (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5043 | CurModule.ModuleDone(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5044 | ;} |
| 5045 | break; |
| 5046 | |
| 5047 | case 180: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5048 | #line 2672 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5049 | { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;} |
| 5050 | break; |
| 5051 | |
| 5052 | case 181: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5053 | #line 2673 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5054 | { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;} |
| 5055 | break; |
| 5056 | |
| 5057 | case 182: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5058 | #line 2674 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5059 | { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;} |
| 5060 | break; |
| 5061 | |
| 5062 | case 183: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5063 | #line 2675 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5064 | { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;} |
| 5065 | break; |
| 5066 | |
| 5067 | case 184: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5068 | #line 2676 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5069 | { |
| 5070 | (yyval.ModuleVal) = CurModule.CurrentModule; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5071 | // Emit an error if there are any unresolved types left. |
| 5072 | if (!CurModule.LateResolveTypes.empty()) { |
| 5073 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 5074 | if (DID.Type == ValID::NameVal) { |
| 5075 | error("Reference to an undefined type: '"+DID.getName() + "'"); |
| 5076 | } else { |
| 5077 | error("Reference to an undefined type: #" + itostr(DID.Num)); |
| 5078 | } |
| 5079 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5080 | ;} |
| 5081 | break; |
| 5082 | |
| 5083 | case 185: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5084 | #line 2692 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5085 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5086 | // Eagerly resolve types. This is not an optimization, this is a |
| 5087 | // requirement that is due to the fact that we could have this: |
| 5088 | // |
| 5089 | // %list = type { %list * } |
| 5090 | // %list = type { %list * } ; repeated type decl |
| 5091 | // |
| 5092 | // If types are not resolved eagerly, then the two types will not be |
| 5093 | // determined to be the same type! |
| 5094 | // |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5095 | 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] | 5096 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5097 | if (!setTypeName((yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
| 5098 | // If this is a numbered type that is not a redefinition, add it to the |
| 5099 | // slot table. |
| 5100 | CurModule.Types.push_back((yyvsp[0].TypeVal).PAT->get()); |
| 5101 | CurModule.TypeSigns.push_back((yyvsp[0].TypeVal).S); |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 5102 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5103 | delete (yyvsp[0].TypeVal).PAT; |
| 5104 | ;} |
| 5105 | break; |
| 5106 | |
| 5107 | case 186: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5108 | #line 2712 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5109 | { // Function prototypes can be in const pool |
| 5110 | ;} |
| 5111 | break; |
| 5112 | |
| 5113 | case 187: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5114 | #line 2714 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5115 | { // Asm blocks can be in the const pool |
| 5116 | ;} |
| 5117 | break; |
| 5118 | |
| 5119 | case 188: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5120 | #line 2716 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5121 | { |
| 5122 | if ((yyvsp[0].ConstVal).C == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5123 | error("Global value initializer is not a constant"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5124 | 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] | 5125 | ;} |
| 5126 | break; |
| 5127 | |
| 5128 | case 189: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5129 | #line 2720 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5130 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5131 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5132 | ;} |
| 5133 | break; |
| 5134 | |
| 5135 | case 190: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5136 | #line 2723 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5137 | { |
| 5138 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5139 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0, |
| 5140 | (yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5141 | delete (yyvsp[0].TypeVal).PAT; |
| 5142 | ;} |
| 5143 | break; |
| 5144 | |
| 5145 | case 191: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5146 | #line 2728 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5147 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5148 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5149 | ;} |
| 5150 | break; |
| 5151 | |
| 5152 | case 192: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5153 | #line 2731 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5154 | { |
| 5155 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5156 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0, |
| 5157 | (yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5158 | delete (yyvsp[0].TypeVal).PAT; |
| 5159 | ;} |
| 5160 | break; |
| 5161 | |
| 5162 | case 193: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5163 | #line 2736 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5164 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5165 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5166 | ;} |
| 5167 | break; |
| 5168 | |
| 5169 | case 194: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5170 | #line 2739 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5171 | { |
| 5172 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5173 | CurGV = |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5174 | ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0, |
| 5175 | (yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5176 | delete (yyvsp[0].TypeVal).PAT; |
| 5177 | ;} |
| 5178 | break; |
| 5179 | |
| 5180 | case 195: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5181 | #line 2745 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5182 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5183 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5184 | ;} |
| 5185 | break; |
| 5186 | |
| 5187 | case 196: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5188 | #line 2748 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5189 | { |
| 5190 | ;} |
| 5191 | break; |
| 5192 | |
| 5193 | case 197: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5194 | #line 2750 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5195 | { |
| 5196 | ;} |
| 5197 | break; |
| 5198 | |
| 5199 | case 198: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5200 | #line 2752 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5201 | { |
| 5202 | ;} |
| 5203 | break; |
| 5204 | |
| 5205 | case 199: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5206 | #line 2757 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5207 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5208 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5209 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 5210 | std::string NewAsm((yyvsp[0].StrVal), EndStr); |
| 5211 | free((yyvsp[0].StrVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5212 | |
| 5213 | if (AsmSoFar.empty()) |
| 5214 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 5215 | else |
| 5216 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5217 | ;} |
| 5218 | break; |
| 5219 | |
| 5220 | case 200: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5221 | #line 2771 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5222 | { (yyval.Endianness) = Module::BigEndian; ;} |
| 5223 | break; |
| 5224 | |
| 5225 | case 201: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5226 | #line 2772 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5227 | { (yyval.Endianness) = Module::LittleEndian; ;} |
| 5228 | break; |
| 5229 | |
| 5230 | case 202: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5231 | #line 2776 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5232 | { |
| 5233 | CurModule.setEndianness((yyvsp[0].Endianness)); |
| 5234 | ;} |
| 5235 | break; |
| 5236 | |
| 5237 | case 203: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5238 | #line 2779 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5239 | { |
| 5240 | if ((yyvsp[0].UInt64Val) == 32) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5241 | CurModule.setPointerSize(Module::Pointer32); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5242 | else if ((yyvsp[0].UInt64Val) == 64) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5243 | CurModule.setPointerSize(Module::Pointer64); |
| 5244 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5245 | error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'"); |
| 5246 | ;} |
| 5247 | break; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5248 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5249 | case 204: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5250 | #line 2787 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5251 | { |
| 5252 | CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); |
| 5253 | free((yyvsp[0].StrVal)); |
| 5254 | ;} |
| 5255 | break; |
| 5256 | |
| 5257 | case 205: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5258 | #line 2791 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5259 | { |
| 5260 | CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); |
| 5261 | free((yyvsp[0].StrVal)); |
| 5262 | ;} |
| 5263 | break; |
| 5264 | |
| 5265 | case 207: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5266 | #line 2802 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5267 | { |
| 5268 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 5269 | free((yyvsp[0].StrVal)); |
| 5270 | ;} |
| 5271 | break; |
| 5272 | |
| 5273 | case 208: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5274 | #line 2806 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5275 | { |
| 5276 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 5277 | free((yyvsp[0].StrVal)); |
| 5278 | ;} |
| 5279 | break; |
| 5280 | |
| 5281 | case 209: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5282 | #line 2810 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5283 | { ;} |
| 5284 | break; |
| 5285 | |
| 5286 | case 213: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5287 | #line 2823 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5288 | { (yyval.StrVal) = 0; ;} |
| 5289 | break; |
| 5290 | |
| 5291 | case 214: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5292 | #line 2827 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5293 | { |
| 5294 | if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy) |
| 5295 | error("void typed arguments are invalid"); |
| 5296 | (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal)); |
| 5297 | ;} |
| 5298 | break; |
| 5299 | |
| 5300 | case 215: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5301 | #line 2835 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5302 | { |
| 5303 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 5304 | (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 5305 | delete (yyvsp[0].ArgVal); |
| 5306 | ;} |
| 5307 | break; |
| 5308 | |
| 5309 | case 216: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5310 | #line 2840 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5311 | { |
| 5312 | (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5313 | (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 5314 | delete (yyvsp[0].ArgVal); |
| 5315 | ;} |
| 5316 | break; |
| 5317 | |
| 5318 | case 217: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5319 | #line 2848 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5320 | { (yyval.ArgList) = (yyvsp[0].ArgList); ;} |
| 5321 | break; |
| 5322 | |
| 5323 | case 218: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5324 | #line 2849 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5325 | { |
| 5326 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 5327 | PATypeInfo VoidTI; |
| 5328 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5329 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5330 | (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 5331 | ;} |
| 5332 | break; |
| 5333 | |
| 5334 | case 219: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5335 | #line 2856 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5336 | { |
| 5337 | (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5338 | PATypeInfo VoidTI; |
| 5339 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5340 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5341 | (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 5342 | ;} |
| 5343 | break; |
| 5344 | |
| 5345 | case 220: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5346 | #line 2863 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5347 | { (yyval.ArgList) = 0; ;} |
| 5348 | break; |
| 5349 | |
| 5350 | case 221: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5351 | #line 2867 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5352 | { |
| 5353 | UnEscapeLexed((yyvsp[-5].StrVal)); |
| 5354 | std::string FunctionName((yyvsp[-5].StrVal)); |
| 5355 | free((yyvsp[-5].StrVal)); // Free strdup'd memory! |
| 5356 | |
| 5357 | const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5358 | |
| 5359 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 5360 | error("LLVM functions cannot return aggregate types"); |
| 5361 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5362 | Signedness FTySign; |
| 5363 | FTySign.makeComposite((yyvsp[-6].TypeVal).S); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5364 | std::vector<const Type*> ParamTyList; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5365 | |
| 5366 | // In LLVM 2.0 the signatures of three varargs intrinsics changed to take |
| 5367 | // i8*. We check here for those names and override the parameter list |
| 5368 | // types to ensure the prototype is correct. |
| 5369 | if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5370 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5371 | } else if (FunctionName == "llvm.va_copy") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5372 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
| 5373 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5374 | } else if ((yyvsp[-3].ArgList)) { // If there are arguments... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5375 | for (std::vector<std::pair<PATypeInfo,char*> >::iterator |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5376 | 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] | 5377 | const Type *Ty = I->first.PAT->get(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5378 | ParamTyList.push_back(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5379 | FTySign.add(I->first.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5380 | } |
| 5381 | } |
| 5382 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5383 | bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy; |
| 5384 | if (isVarArg) |
| 5385 | ParamTyList.pop_back(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5386 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5387 | // Convert the CSRet calling convention into the corresponding parameter |
| 5388 | // attribute. |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5389 | ParamAttrsList *ParamAttrs = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5390 | if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) { |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5391 | ParamAttrs = new ParamAttrsList(); |
| 5392 | ParamAttrs->addAttributes(0, NoAttributeSet); // result |
| 5393 | ParamAttrs->addAttributes(1, StructRetAttribute); // first arg |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5394 | } |
| 5395 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5396 | const FunctionType *FT = |
| 5397 | FunctionType::get(RetTy, ParamTyList, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5398 | const PointerType *PFT = PointerType::get(FT); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5399 | delete (yyvsp[-6].TypeVal).PAT; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5400 | |
| 5401 | ValID ID; |
| 5402 | if (!FunctionName.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5403 | ID = ValID::create((char*)FunctionName.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5404 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5405 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5406 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5407 | ID.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5408 | |
| 5409 | Function *Fn = 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5410 | Module* M = CurModule.CurrentModule; |
| 5411 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5412 | // See if this function was forward referenced. If so, recycle the object. |
| 5413 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 5414 | // Move the function to the end of the list, from whereever it was |
| 5415 | // previously inserted. |
| 5416 | Fn = cast<Function>(FWRef); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5417 | M->getFunctionList().remove(Fn); |
| 5418 | M->getFunctionList().push_back(Fn); |
| 5419 | } else if (!FunctionName.empty()) { |
| 5420 | GlobalValue *Conflict = M->getFunction(FunctionName); |
| 5421 | if (!Conflict) |
| 5422 | Conflict = M->getNamedGlobal(FunctionName); |
| 5423 | if (Conflict && PFT == Conflict->getType()) { |
| 5424 | if (!CurFun.isDeclare && !Conflict->isDeclaration()) { |
| 5425 | // We have two function definitions that conflict, same type, same |
| 5426 | // name. We should really check to make sure that this is the result |
| 5427 | // of integer type planes collapsing and generate an error if it is |
| 5428 | // not, but we'll just rename on the assumption that it is. However, |
| 5429 | // let's do it intelligently and rename the internal linkage one |
| 5430 | // if there is one. |
| 5431 | std::string NewName(makeNameUnique(FunctionName)); |
| 5432 | if (Conflict->hasInternalLinkage()) { |
| 5433 | Conflict->setName(NewName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5434 | RenameMapKey Key = |
| 5435 | makeRenameMapKey(FunctionName, Conflict->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5436 | CurModule.RenameMap[Key] = NewName; |
| 5437 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5438 | InsertValue(Fn, CurModule.Values); |
| 5439 | } else { |
| 5440 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5441 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5442 | RenameMapKey Key = |
| 5443 | makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5444 | CurModule.RenameMap[Key] = NewName; |
| 5445 | } |
| 5446 | } else { |
| 5447 | // If they are not both definitions, then just use the function we |
| 5448 | // found since the types are the same. |
| 5449 | Fn = cast<Function>(Conflict); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5450 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5451 | // Make sure to strip off any argument names so we can't get |
| 5452 | // conflicts. |
| 5453 | if (Fn->isDeclaration()) |
| 5454 | for (Function::arg_iterator AI = Fn->arg_begin(), |
| 5455 | AE = Fn->arg_end(); AI != AE; ++AI) |
| 5456 | AI->setName(""); |
| 5457 | } |
| 5458 | } else if (Conflict) { |
| 5459 | // We have two globals with the same name and different types. |
| 5460 | // Previously, this was permitted because the symbol table had |
| 5461 | // "type planes" and names only needed to be distinct within a |
| 5462 | // type plane. After PR411 was fixed, this is no loner the case. |
| 5463 | // To resolve this we must rename one of the two. |
| 5464 | if (Conflict->hasInternalLinkage()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5465 | // We can safely rename the Conflict. |
| 5466 | RenameMapKey Key = |
| 5467 | makeRenameMapKey(Conflict->getName(), Conflict->getType(), |
| 5468 | CurModule.NamedValueSigns[Conflict->getName()]); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5469 | Conflict->setName(makeNameUnique(Conflict->getName())); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5470 | CurModule.RenameMap[Key] = Conflict->getName(); |
| 5471 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5472 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5473 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5474 | // We can't quietly rename either of these things, but we must |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5475 | // rename one of them. Only if the function's linkage is internal can |
| 5476 | // we forgo a warning message about the renamed function. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5477 | std::string NewName = makeNameUnique(FunctionName); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5478 | if (CurFun.Linkage != GlobalValue::InternalLinkage) { |
| 5479 | warning("Renaming function '" + FunctionName + "' as '" + NewName + |
| 5480 | "' may cause linkage errors"); |
| 5481 | } |
| 5482 | // Elect to rename the thing we're now defining. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5483 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5484 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5485 | RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5486 | CurModule.RenameMap[Key] = NewName; |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5487 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5488 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5489 | // There's no conflict, just define the function |
| 5490 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5491 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5492 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5493 | } |
| 5494 | |
| 5495 | CurFun.FunctionStart(Fn); |
| 5496 | |
| 5497 | if (CurFun.isDeclare) { |
| 5498 | // If we have declaration, always overwrite linkage. This will allow us |
| 5499 | // to correctly handle cases, when pointer to function is passed as |
| 5500 | // argument to another function. |
| 5501 | Fn->setLinkage(CurFun.Linkage); |
| 5502 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5503 | Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal))); |
| 5504 | Fn->setAlignment((yyvsp[0].UIntVal)); |
| 5505 | if ((yyvsp[-1].StrVal)) { |
| 5506 | Fn->setSection((yyvsp[-1].StrVal)); |
| 5507 | free((yyvsp[-1].StrVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5508 | } |
| 5509 | |
| 5510 | // Add all of the arguments we parsed to the function... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5511 | if ((yyvsp[-3].ArgList)) { // Is null if empty... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5512 | if (isVarArg) { // Nuke the last entry |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5513 | assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy && |
| 5514 | (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker"); |
| 5515 | delete (yyvsp[-3].ArgList)->back().first.PAT; |
| 5516 | (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5517 | } |
| 5518 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5519 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5520 | std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); |
| 5521 | std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5522 | for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5523 | delete I->first.PAT; // Delete the typeholder... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5524 | ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S); |
| 5525 | setValueName(VI, I->second); // Insert arg into symtab... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5526 | InsertValue(ArgIt); |
| 5527 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5528 | delete (yyvsp[-3].ArgList); // We're now done with the argument list |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5529 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5530 | ;} |
| 5531 | break; |
| 5532 | |
| 5533 | case 224: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5534 | #line 3053 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5535 | { CurFun.Linkage = (yyvsp[0].Linkage); ;} |
| 5536 | break; |
| 5537 | |
| 5538 | case 225: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5539 | #line 3053 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5540 | { |
| 5541 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5542 | |
| 5543 | // Make sure that we keep track of the linkage type even if there was a |
| 5544 | // previous "declare". |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5545 | (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5546 | ;} |
| 5547 | break; |
| 5548 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5549 | case 228: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5550 | #line 3067 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5551 | { |
| 5552 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 5553 | ;} |
| 5554 | break; |
| 5555 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5556 | case 229: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5557 | #line 3072 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5558 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 5559 | break; |
| 5560 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5561 | case 230: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5562 | #line 3073 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5563 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 5564 | break; |
| 5565 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5566 | case 231: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5567 | #line 3074 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5568 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 5569 | break; |
| 5570 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5571 | case 232: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5572 | #line 3078 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5573 | { CurFun.isDeclare = true; ;} |
| 5574 | break; |
| 5575 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5576 | case 233: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5577 | #line 3079 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5578 | { CurFun.Linkage = (yyvsp[0].Linkage); ;} |
| 5579 | break; |
| 5580 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5581 | case 234: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5582 | #line 3079 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5583 | { |
| 5584 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5585 | CurFun.FunctionDone(); |
| 5586 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5587 | ;} |
| 5588 | break; |
| 5589 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5590 | case 235: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5591 | #line 3091 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5592 | { (yyval.BoolVal) = false; ;} |
| 5593 | break; |
| 5594 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5595 | case 236: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5596 | #line 3092 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5597 | { (yyval.BoolVal) = true; ;} |
| 5598 | break; |
| 5599 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5600 | case 237: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5601 | #line 3097 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5602 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5603 | break; |
| 5604 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5605 | case 238: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5606 | #line 3098 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5607 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;} |
| 5608 | break; |
| 5609 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5610 | case 239: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5611 | #line 3099 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5612 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;} |
| 5613 | break; |
| 5614 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5615 | case 240: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5616 | #line 3100 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5617 | { |
| 5618 | (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); |
| 5619 | (yyval.ValIDVal).S.makeUnsigned(); |
| 5620 | ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5621 | break; |
| 5622 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5623 | case 241: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5624 | #line 3104 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5625 | { |
| 5626 | (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); |
| 5627 | (yyval.ValIDVal).S.makeUnsigned(); |
| 5628 | ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5629 | break; |
| 5630 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5631 | case 242: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5632 | #line 3108 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5633 | { (yyval.ValIDVal) = ValID::createNull(); ;} |
| 5634 | break; |
| 5635 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5636 | case 243: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5637 | #line 3109 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5638 | { (yyval.ValIDVal) = ValID::createUndef(); ;} |
| 5639 | break; |
| 5640 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5641 | case 244: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5642 | #line 3110 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5643 | { (yyval.ValIDVal) = ValID::createZeroInit(); ;} |
| 5644 | break; |
| 5645 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5646 | case 245: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5647 | #line 3111 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5648 | { // Nonempty unsized packed vector |
| 5649 | const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType(); |
| 5650 | int NumElements = (yyvsp[-1].ConstVector)->size(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5651 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5652 | (yyval.ValIDVal).S.makeComposite((*(yyvsp[-1].ConstVector))[0].S); |
| 5653 | PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5654 | |
| 5655 | // Verify all elements are correct type! |
| 5656 | std::vector<Constant*> Elems; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5657 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 5658 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5659 | const Type *CTy = C->getType(); |
| 5660 | if (ETy != CTy) |
| 5661 | error("Element #" + utostr(i) + " is not of type '" + |
| 5662 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 5663 | CTy->getDescription() + "'"); |
| 5664 | Elems.push_back(C); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 5665 | } |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5666 | (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5667 | delete PTy; delete (yyvsp[-1].ConstVector); |
| 5668 | ;} |
| 5669 | break; |
| 5670 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5671 | case 246: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5672 | #line 3132 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5673 | { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5674 | (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5675 | (yyval.ValIDVal).S.copy((yyvsp[0].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5676 | ;} |
| 5677 | break; |
| 5678 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5679 | case 247: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5680 | #line 3136 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5681 | { |
| 5682 | char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); |
| 5683 | std::string AsmStr = std::string((yyvsp[-2].StrVal), End); |
| 5684 | End = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 5685 | std::string Constraints = std::string((yyvsp[0].StrVal), End); |
| 5686 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); |
| 5687 | free((yyvsp[-2].StrVal)); |
| 5688 | free((yyvsp[0].StrVal)); |
| 5689 | ;} |
| 5690 | break; |
| 5691 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5692 | case 248: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5693 | #line 3150 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5694 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5695 | break; |
| 5696 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5697 | case 249: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5698 | #line 3151 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5699 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5700 | break; |
| 5701 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5702 | case 252: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5703 | #line 3164 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5704 | { |
| 5705 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5706 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5707 | (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5708 | (yyval.ValueVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5709 | delete (yyvsp[-1].TypeVal).PAT; |
| 5710 | ;} |
| 5711 | break; |
| 5712 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5713 | case 253: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5714 | #line 3174 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5715 | { |
| 5716 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 5717 | ;} |
| 5718 | break; |
| 5719 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5720 | case 254: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5721 | #line 3177 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5722 | { // Do not allow functions with 0 basic blocks |
| 5723 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 5724 | ;} |
| 5725 | break; |
| 5726 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5727 | case 255: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5728 | #line 3186 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5729 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5730 | ValueInfo VI; VI.V = (yyvsp[0].TermInstVal).TI; VI.S.copy((yyvsp[0].TermInstVal).S); |
| 5731 | setValueName(VI, (yyvsp[-1].StrVal)); |
| 5732 | InsertValue((yyvsp[0].TermInstVal).TI); |
| 5733 | (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal).TI); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5734 | InsertValue((yyvsp[-2].BasicBlockVal)); |
| 5735 | (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); |
| 5736 | ;} |
| 5737 | break; |
| 5738 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5739 | case 256: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5740 | #line 3197 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5741 | { |
| 5742 | if ((yyvsp[0].InstVal).I) |
| 5743 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I); |
| 5744 | (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); |
| 5745 | ;} |
| 5746 | break; |
| 5747 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5748 | case 257: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5749 | #line 3202 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5750 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5751 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5752 | // Make sure to move the basic block to the correct location in the |
| 5753 | // function, instead of leaving it inserted wherever it was first |
| 5754 | // referenced. |
| 5755 | Function::BasicBlockListType &BBL = |
| 5756 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5757 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
| 5758 | ;} |
| 5759 | break; |
| 5760 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5761 | case 258: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5762 | #line 3211 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5763 | { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5764 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5765 | // Make sure to move the basic block to the correct location in the |
| 5766 | // function, instead of leaving it inserted wherever it was first |
| 5767 | // referenced. |
| 5768 | Function::BasicBlockListType &BBL = |
| 5769 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5770 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
| 5771 | ;} |
| 5772 | break; |
| 5773 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5774 | case 261: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5775 | #line 3225 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5776 | { // Return with a result... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5777 | (yyval.TermInstVal).TI = new ReturnInst((yyvsp[0].ValueVal).V); |
| 5778 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5779 | ;} |
| 5780 | break; |
| 5781 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5782 | case 262: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5783 | #line 3229 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5784 | { // Return with no result... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5785 | (yyval.TermInstVal).TI = new ReturnInst(); |
| 5786 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5787 | ;} |
| 5788 | break; |
| 5789 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5790 | case 263: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5791 | #line 3233 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5792 | { // Unconditional Branch... |
| 5793 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5794 | (yyval.TermInstVal).TI = new BranchInst(tmpBB); |
| 5795 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5796 | ;} |
| 5797 | break; |
| 5798 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5799 | case 264: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5800 | #line 3238 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5801 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5802 | (yyvsp[-3].ValIDVal).S.makeSignless(); |
| 5803 | (yyvsp[0].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5804 | BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); |
| 5805 | BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5806 | (yyvsp[-6].ValIDVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5807 | Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5808 | (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 5809 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5810 | ;} |
| 5811 | break; |
| 5812 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5813 | case 265: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5814 | #line 3248 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5815 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5816 | (yyvsp[-6].ValIDVal).S.copy((yyvsp[-7].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5817 | Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5818 | (yyvsp[-3].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5819 | BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); |
| 5820 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5821 | (yyval.TermInstVal).TI = S; |
| 5822 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5823 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), |
| 5824 | E = (yyvsp[-1].JumpTable)->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5825 | for (; I != E; ++I) { |
| 5826 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 5827 | S->addCase(CI, I->second); |
| 5828 | else |
| 5829 | error("Switch case is constant, but not a simple integer"); |
| 5830 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5831 | delete (yyvsp[-1].JumpTable); |
| 5832 | ;} |
| 5833 | break; |
| 5834 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5835 | case 266: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5836 | #line 3266 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5837 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5838 | (yyvsp[-5].ValIDVal).S.copy((yyvsp[-6].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5839 | Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5840 | (yyvsp[-2].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5841 | BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5842 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5843 | (yyval.TermInstVal).TI = S; |
| 5844 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5845 | ;} |
| 5846 | break; |
| 5847 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5848 | case 267: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5849 | #line 3276 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5850 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5851 | const PointerType *PFTy; |
| 5852 | const FunctionType *Ty; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5853 | Signedness FTySign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5854 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5855 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5856 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5857 | // Pull out the types of all of the arguments... |
| 5858 | std::vector<const Type*> ParamTypes; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5859 | FTySign.makeComposite((yyvsp[-10].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5860 | if ((yyvsp[-7].ValueList)) { |
| 5861 | 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] | 5862 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5863 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5864 | FTySign.add(I->S); |
| 5865 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5866 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5867 | ParamAttrsList *ParamAttrs = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5868 | if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) { |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5869 | ParamAttrs = new ParamAttrsList(); |
| 5870 | ParamAttrs->addAttributes(0, NoAttributeSet); // Function result |
| 5871 | ParamAttrs->addAttributes(1, StructRetAttribute); // first param |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5872 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5873 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5874 | if (isVarArg) ParamTypes.pop_back(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5875 | Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5876 | PFTy = PointerType::get(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5877 | (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S); |
| 5878 | } else { |
| 5879 | FTySign = (yyvsp[-10].TypeVal).S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 5880 | // Get the signedness of the result type. $3 is the pointer to the |
| 5881 | // function type so we get the 0th element to extract the function type, |
| 5882 | // and then the 0th element again to get the result type. |
| 5883 | (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5884 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5885 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5886 | (yyvsp[-9].ValIDVal).S.makeComposite(FTySign); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5887 | Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling... |
| 5888 | BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); |
| 5889 | BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5890 | |
| 5891 | // Create the call node... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5892 | if (!(yyvsp[-7].ValueList)) { // Has no arguments? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5893 | (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, 0, 0); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5894 | } else { // Has arguments? |
| 5895 | // Loop through FunctionType's arguments and ensure they are specified |
| 5896 | // correctly! |
| 5897 | // |
| 5898 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5899 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5900 | 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] | 5901 | |
| 5902 | std::vector<Value*> Args; |
| 5903 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5904 | if ((*ArgI).V->getType() != *I) |
| 5905 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 5906 | (*I)->getDescription() + "'"); |
| 5907 | Args.push_back((*ArgI).V); |
| 5908 | } |
| 5909 | |
| 5910 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 5911 | error("Invalid number of parameters detected"); |
| 5912 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5913 | (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5914 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5915 | cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal))); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5916 | delete (yyvsp[-10].TypeVal).PAT; |
| 5917 | delete (yyvsp[-7].ValueList); |
| 5918 | ;} |
| 5919 | break; |
| 5920 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5921 | case 268: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5922 | #line 3345 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5923 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5924 | (yyval.TermInstVal).TI = new UnwindInst(); |
| 5925 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5926 | ;} |
| 5927 | break; |
| 5928 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5929 | case 269: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5930 | #line 3349 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5931 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5932 | (yyval.TermInstVal).TI = new UnreachableInst(); |
| 5933 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5934 | ;} |
| 5935 | break; |
| 5936 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5937 | case 270: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5938 | #line 3356 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5939 | { |
| 5940 | (yyval.JumpTable) = (yyvsp[-5].JumpTable); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5941 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5942 | Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5943 | |
| 5944 | if (V == 0) |
| 5945 | error("May only switch on a constant pool value"); |
| 5946 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5947 | (yyvsp[0].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5948 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 5949 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5950 | ;} |
| 5951 | break; |
| 5952 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5953 | case 271: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5954 | #line 3368 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5955 | { |
| 5956 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5957 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5958 | Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5959 | |
| 5960 | if (V == 0) |
| 5961 | error("May only switch on a constant pool value"); |
| 5962 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5963 | (yyvsp[0].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5964 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 5965 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5966 | ;} |
| 5967 | break; |
| 5968 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5969 | case 272: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 5970 | #line 3383 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5971 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5972 | bool omit = false; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5973 | if ((yyvsp[-1].StrVal)) |
| 5974 | if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5975 | if (BCI->getSrcTy() == BCI->getDestTy() && |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5976 | BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5977 | // This is a useless bit cast causing a name redefinition. It is |
| 5978 | // a bit cast from a type to the same type of an operand with the |
| 5979 | // same name as the name we would give this instruction. Since this |
| 5980 | // instruction results in no code generation, it is safe to omit |
| 5981 | // the instruction. This situation can occur because of collapsed |
| 5982 | // type planes. For example: |
| 5983 | // %X = add int %Y, %Z |
| 5984 | // %X = cast int %Y to uint |
| 5985 | // After upgrade, this looks like: |
| 5986 | // %X = add i32 %Y, %Z |
| 5987 | // %X = bitcast i32 to i32 |
| 5988 | // The bitcast is clearly useless so we omit it. |
| 5989 | omit = true; |
| 5990 | if (omit) { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5991 | (yyval.InstVal).I = 0; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5992 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5993 | } else { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5994 | ValueInfo VI; VI.V = (yyvsp[0].InstVal).I; VI.S.copy((yyvsp[0].InstVal).S); |
| 5995 | setValueName(VI, (yyvsp[-1].StrVal)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5996 | InsertValue((yyvsp[0].InstVal).I); |
| 5997 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5998 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5999 | ;} |
| 6000 | break; |
| 6001 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6002 | case 273: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6003 | #line 3413 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6004 | { // Used for PHI nodes |
| 6005 | (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6006 | (yyval.PHIList).S.copy((yyvsp[-5].TypeVal).S); |
| 6007 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-5].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6008 | Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6009 | (yyvsp[-1].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6010 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
| 6011 | (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 6012 | delete (yyvsp[-5].TypeVal).PAT; |
| 6013 | ;} |
| 6014 | break; |
| 6015 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6016 | case 274: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6017 | #line 3423 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6018 | { |
| 6019 | (yyval.PHIList) = (yyvsp[-6].PHIList); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6020 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-6].PHIList).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6021 | 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] | 6022 | (yyvsp[-1].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6023 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
| 6024 | (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 6025 | ;} |
| 6026 | break; |
| 6027 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6028 | case 275: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6029 | #line 3433 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6030 | { // Used for call statements, and memory insts... |
| 6031 | (yyval.ValueList) = new std::vector<ValueInfo>(); |
| 6032 | (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); |
| 6033 | ;} |
| 6034 | break; |
| 6035 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6036 | case 276: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6037 | #line 3437 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6038 | { |
| 6039 | (yyval.ValueList) = (yyvsp[-2].ValueList); |
| 6040 | (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); |
| 6041 | ;} |
| 6042 | break; |
| 6043 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6044 | case 278: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6045 | #line 3445 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6046 | { (yyval.ValueList) = 0; ;} |
| 6047 | break; |
| 6048 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6049 | case 279: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6050 | #line 3449 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6051 | { |
| 6052 | (yyval.BoolVal) = true; |
| 6053 | ;} |
| 6054 | break; |
| 6055 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6056 | case 280: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6057 | #line 3452 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6058 | { |
| 6059 | (yyval.BoolVal) = false; |
| 6060 | ;} |
| 6061 | break; |
| 6062 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6063 | case 281: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6064 | #line 3458 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6065 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6066 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6067 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6068 | const Type* Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6069 | if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6070 | error("Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6071 | if (isa<VectorType>(Ty) && |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6072 | ((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] | 6073 | error("Remainder not supported on vector types"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6074 | // Upgrade the opcode from obsolete versions before we do anything with it. |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6075 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S); |
| 6076 | Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6077 | Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6078 | (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2); |
| 6079 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6080 | error("binary operator returned null"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6081 | (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6082 | delete (yyvsp[-3].TypeVal).PAT; |
| 6083 | ;} |
| 6084 | break; |
| 6085 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6086 | case 282: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6087 | #line 3477 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6088 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6089 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6090 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6091 | const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6092 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6093 | if (!isa<VectorType>(Ty) || |
| 6094 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6095 | error("Logical operator requires integral operands"); |
| 6096 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6097 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S); |
| 6098 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6099 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6100 | (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); |
| 6101 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6102 | error("binary operator returned null"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6103 | (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6104 | delete (yyvsp[-3].TypeVal).PAT; |
| 6105 | ;} |
| 6106 | break; |
| 6107 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6108 | case 283: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6109 | #line 3495 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6110 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6111 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6112 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6113 | const Type* Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6114 | if(isa<VectorType>(Ty)) |
| 6115 | error("VectorTypes currently not supported in setcc instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6116 | unsigned short pred; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6117 | Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S); |
| 6118 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6119 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6120 | (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); |
| 6121 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6122 | error("binary operator returned null"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6123 | (yyval.InstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6124 | delete (yyvsp[-3].TypeVal).PAT; |
| 6125 | ;} |
| 6126 | break; |
| 6127 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6128 | case 284: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6129 | #line 3511 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6130 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6131 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6132 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6133 | const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6134 | if (isa<VectorType>(Ty)) |
| 6135 | error("VectorTypes currently not supported in icmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6136 | else if (!Ty->isInteger() && !isa<PointerType>(Ty)) |
| 6137 | error("icmp requires integer or pointer typed operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6138 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6139 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6140 | (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6141 | (yyval.InstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6142 | delete (yyvsp[-3].TypeVal).PAT; |
| 6143 | ;} |
| 6144 | break; |
| 6145 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6146 | case 285: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6147 | #line 3525 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6148 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6149 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6150 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6151 | const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6152 | if (isa<VectorType>(Ty)) |
| 6153 | error("VectorTypes currently not supported in fcmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6154 | else if (!Ty->isFloatingPoint()) |
| 6155 | error("fcmp instruction requires floating point operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6156 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6157 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6158 | (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6159 | (yyval.InstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6160 | delete (yyvsp[-3].TypeVal).PAT; |
| 6161 | ;} |
| 6162 | break; |
| 6163 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6164 | case 286: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6165 | #line 3539 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6166 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6167 | warning("Use of obsolete 'not' instruction: Replacing with 'xor"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6168 | const Type *Ty = (yyvsp[0].ValueVal).V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6169 | Value *Ones = ConstantInt::getAllOnesValue(Ty); |
| 6170 | if (Ones == 0) |
| 6171 | error("Expected integral type for not instruction"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6172 | (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones); |
| 6173 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6174 | error("Could not create a xor instruction"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6175 | (yyval.InstVal).S.copy((yyvsp[0].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6176 | ;} |
| 6177 | break; |
| 6178 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6179 | case 287: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6180 | #line 3550 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6181 | { |
| 6182 | if (!(yyvsp[0].ValueVal).V->getType()->isInteger() || |
| 6183 | cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6184 | error("Shift amount must be int8"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6185 | const Type* Ty = (yyvsp[-2].ValueVal).V->getType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6186 | if (!Ty->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6187 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6188 | Value* ShiftAmt = 0; |
| 6189 | if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth()) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6190 | if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V)) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6191 | ShiftAmt = ConstantExpr::getZExt(C, Ty); |
| 6192 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6193 | ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6194 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6195 | ShiftAmt = (yyvsp[0].ValueVal).V; |
| 6196 | (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] | 6197 | (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6198 | ;} |
| 6199 | break; |
| 6200 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6201 | case 288: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6202 | #line 3568 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6203 | { |
| 6204 | const Type *DstTy = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6205 | if (!DstTy->isFirstClassType()) |
| 6206 | error("cast instruction to a non-primitive type: '" + |
| 6207 | DstTy->getDescription() + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6208 | (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] | 6209 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6210 | delete (yyvsp[0].TypeVal).PAT; |
| 6211 | ;} |
| 6212 | break; |
| 6213 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6214 | case 289: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6215 | #line 3577 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6216 | { |
| 6217 | if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() || |
| 6218 | cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6219 | error("select condition must be bool"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6220 | if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6221 | error("select value types should match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6222 | (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] | 6223 | (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6224 | ;} |
| 6225 | break; |
| 6226 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6227 | case 290: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6228 | #line 3586 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6229 | { |
| 6230 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6231 | NewVarArgs = true; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6232 | (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6233 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6234 | delete (yyvsp[0].TypeVal).PAT; |
| 6235 | ;} |
| 6236 | break; |
| 6237 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6238 | case 291: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6239 | #line 3593 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6240 | { |
| 6241 | const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType(); |
| 6242 | const Type* DstTy = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6243 | ObsoleteVarArgs = true; |
| 6244 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6245 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6246 | |
| 6247 | //b = vaarg a, t -> |
| 6248 | //foo = alloca 1 of t |
| 6249 | //bar = vacopy a |
| 6250 | //store bar -> foo |
| 6251 | //b = vaarg foo, t |
| 6252 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 6253 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6254 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6255 | CurBB->getInstList().push_back(bar); |
| 6256 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6257 | (yyval.InstVal).I = new VAArgInst(foo, DstTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6258 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6259 | delete (yyvsp[0].TypeVal).PAT; |
| 6260 | ;} |
| 6261 | break; |
| 6262 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6263 | case 292: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6264 | #line 3614 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6265 | { |
| 6266 | const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType(); |
| 6267 | const Type* DstTy = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6268 | ObsoleteVarArgs = true; |
| 6269 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6270 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6271 | |
| 6272 | //b = vanext a, t -> |
| 6273 | //foo = alloca 1 of t |
| 6274 | //bar = vacopy a |
| 6275 | //store bar -> foo |
| 6276 | //tmp = vaarg foo, t |
| 6277 | //b = load foo |
| 6278 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 6279 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6280 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6281 | CurBB->getInstList().push_back(bar); |
| 6282 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 6283 | Instruction* tmp = new VAArgInst(foo, DstTy); |
| 6284 | CurBB->getInstList().push_back(tmp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6285 | (yyval.InstVal).I = new LoadInst(foo); |
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 293: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6292 | #line 3638 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6293 | { |
| 6294 | if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6295 | error("Invalid extractelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6296 | (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] | 6297 | (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6298 | ;} |
| 6299 | break; |
| 6300 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6301 | case 294: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6302 | #line 3644 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6303 | { |
| 6304 | 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] | 6305 | error("Invalid insertelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6306 | (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] | 6307 | (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6308 | ;} |
| 6309 | break; |
| 6310 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6311 | case 295: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6312 | #line 3650 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6313 | { |
| 6314 | 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] | 6315 | error("Invalid shufflevector operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6316 | (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] | 6317 | (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6318 | ;} |
| 6319 | break; |
| 6320 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6321 | case 296: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6322 | #line 3656 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6323 | { |
| 6324 | const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6325 | if (!Ty->isFirstClassType()) |
| 6326 | error("PHI node operands must be of first class type"); |
| 6327 | PHINode *PHI = new PHINode(Ty); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6328 | PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size()); |
| 6329 | while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) { |
| 6330 | if ((yyvsp[0].PHIList).P->front().first->getType() != Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6331 | 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] | 6332 | PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second); |
| 6333 | (yyvsp[0].PHIList).P->pop_front(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6334 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6335 | (yyval.InstVal).I = PHI; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6336 | (yyval.InstVal).S.copy((yyvsp[0].PHIList).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6337 | delete (yyvsp[0].PHIList).P; // Free the list... |
| 6338 | ;} |
| 6339 | break; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6340 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6341 | case 297: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6342 | #line 3672 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6343 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6344 | // Handle the short call syntax |
| 6345 | const PointerType *PFTy; |
| 6346 | const FunctionType *FTy; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6347 | Signedness FTySign; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6348 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6349 | !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 6350 | // Pull out the types of all of the arguments... |
| 6351 | std::vector<const Type*> ParamTypes; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6352 | FTySign.makeComposite((yyvsp[-4].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6353 | if ((yyvsp[-1].ValueList)) { |
| 6354 | 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] | 6355 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6356 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6357 | FTySign.add(I->S); |
| 6358 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6359 | } |
| 6360 | |
| 6361 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 6362 | if (isVarArg) ParamTypes.pop_back(); |
| 6363 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6364 | const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6365 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 6366 | error("Functions cannot return aggregate types"); |
| 6367 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6368 | // Deal with CSRetCC |
| 6369 | ParamAttrsList *ParamAttrs = 0; |
| 6370 | if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) { |
| 6371 | ParamAttrs = new ParamAttrsList(); |
| 6372 | ParamAttrs->addAttributes(0, NoAttributeSet); // function result |
| 6373 | ParamAttrs->addAttributes(1, StructRetAttribute); // first parameter |
| 6374 | } |
| 6375 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 6376 | FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6377 | PFTy = PointerType::get(FTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6378 | (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S); |
| 6379 | } else { |
| 6380 | FTySign = (yyvsp[-4].TypeVal).S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 6381 | // Get the signedness of the result type. $3 is the pointer to the |
| 6382 | // function type so we get the 0th element to extract the function type, |
| 6383 | // and then the 0th element again to get the result type. |
| 6384 | (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6385 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6386 | (yyvsp[-3].ValIDVal).S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6387 | |
| 6388 | // First upgrade any intrinsic calls. |
| 6389 | std::vector<Value*> Args; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6390 | if ((yyvsp[-1].ValueList)) |
| 6391 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i) |
| 6392 | Args.push_back((*(yyvsp[-1].ValueList))[i].V); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 6393 | Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[-3].ValIDVal), Args); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6394 | |
| 6395 | // If we got an upgraded intrinsic |
| 6396 | if (Inst) { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6397 | (yyval.InstVal).I = Inst; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6398 | } else { |
| 6399 | // Get the function we're calling |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6400 | Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6401 | |
| 6402 | // Check the argument values match |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6403 | if (!(yyvsp[-1].ValueList)) { // Has no arguments? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6404 | // Make sure no arguments is a good thing! |
| 6405 | if (FTy->getNumParams() != 0) |
| 6406 | error("No arguments passed to a function that expects arguments"); |
| 6407 | } else { // Has arguments? |
| 6408 | // Loop through FunctionType's arguments and ensure they are specified |
| 6409 | // correctly! |
| 6410 | // |
| 6411 | FunctionType::param_iterator I = FTy->param_begin(); |
| 6412 | FunctionType::param_iterator E = FTy->param_end(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6413 | 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] | 6414 | |
| 6415 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 6416 | if ((*ArgI).V->getType() != *I) |
| 6417 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 6418 | (*I)->getDescription() + "'"); |
| 6419 | |
| 6420 | if (I != E || (ArgI != ArgE && !FTy->isVarArg())) |
| 6421 | error("Invalid number of parameters detected"); |
| 6422 | } |
| 6423 | |
| 6424 | // Create the call instruction |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6425 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6426 | CI->setTailCall((yyvsp[-6].BoolVal)); |
| 6427 | CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal))); |
| 6428 | (yyval.InstVal).I = CI; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6429 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6430 | delete (yyvsp[-4].TypeVal).PAT; |
| 6431 | delete (yyvsp[-1].ValueList); |
| 6432 | ;} |
| 6433 | break; |
| 6434 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6435 | case 298: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6436 | #line 3762 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6437 | { |
| 6438 | (yyval.InstVal) = (yyvsp[0].InstVal); |
| 6439 | ;} |
| 6440 | break; |
| 6441 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6442 | case 299: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6443 | #line 3770 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6444 | { (yyval.ValueList) = (yyvsp[0].ValueList); ;} |
| 6445 | break; |
| 6446 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6447 | case 300: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6448 | #line 3771 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6449 | { (yyval.ValueList) = new std::vector<ValueInfo>(); ;} |
| 6450 | break; |
| 6451 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6452 | case 301: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6453 | #line 3775 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6454 | { (yyval.BoolVal) = true; ;} |
| 6455 | break; |
| 6456 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6457 | case 302: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6458 | #line 3776 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6459 | { (yyval.BoolVal) = false; ;} |
| 6460 | break; |
| 6461 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6462 | case 303: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6463 | #line 3780 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6464 | { |
| 6465 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6466 | (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6467 | (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal)); |
| 6468 | delete (yyvsp[-1].TypeVal).PAT; |
| 6469 | ;} |
| 6470 | break; |
| 6471 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6472 | case 304: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6473 | #line 3786 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6474 | { |
| 6475 | const Type *Ty = (yyvsp[-4].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6476 | (yyvsp[-1].ValIDVal).S.makeUnsigned(); |
| 6477 | (yyval.InstVal).S.makeComposite((yyvsp[-4].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6478 | (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal)); |
| 6479 | delete (yyvsp[-4].TypeVal).PAT; |
| 6480 | ;} |
| 6481 | break; |
| 6482 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6483 | case 305: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6484 | #line 3793 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6485 | { |
| 6486 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6487 | (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6488 | (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal)); |
| 6489 | delete (yyvsp[-1].TypeVal).PAT; |
| 6490 | ;} |
| 6491 | break; |
| 6492 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6493 | case 306: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6494 | #line 3799 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6495 | { |
| 6496 | const Type *Ty = (yyvsp[-4].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6497 | (yyvsp[-1].ValIDVal).S.makeUnsigned(); |
| 6498 | (yyval.InstVal).S.makeComposite((yyvsp[-2].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6499 | (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal)); |
| 6500 | delete (yyvsp[-4].TypeVal).PAT; |
| 6501 | ;} |
| 6502 | break; |
| 6503 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6504 | case 307: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6505 | #line 3806 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6506 | { |
| 6507 | const Type *PTy = (yyvsp[0].ValueVal).V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6508 | if (!isa<PointerType>(PTy)) |
| 6509 | error("Trying to free nonpointer type '" + PTy->getDescription() + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6510 | (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6511 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6512 | ;} |
| 6513 | break; |
| 6514 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6515 | case 308: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6516 | #line 3813 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6517 | { |
| 6518 | const Type* Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6519 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6520 | if (!isa<PointerType>(Ty)) |
| 6521 | error("Can't load from nonpointer type: " + Ty->getDescription()); |
| 6522 | if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType()) |
| 6523 | error("Can't load from pointer of non-first-class type: " + |
| 6524 | Ty->getDescription()); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6525 | Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6526 | (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6527 | (yyval.InstVal).S.copy((yyvsp[-1].TypeVal).S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6528 | delete (yyvsp[-1].TypeVal).PAT; |
| 6529 | ;} |
| 6530 | break; |
| 6531 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6532 | case 309: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6533 | #line 3826 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6534 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6535 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6536 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6537 | if (!PTy) |
| 6538 | error("Can't store to a nonpointer type: " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6539 | (yyvsp[-1].TypeVal).PAT->get()->getDescription()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6540 | const Type *ElTy = PTy->getElementType(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6541 | Value *StoreVal = (yyvsp[-3].ValueVal).V; |
| 6542 | Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal)); |
| 6543 | if (ElTy != (yyvsp[-3].ValueVal).V->getType()) { |
| 6544 | StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6545 | if (!StoreVal) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6546 | error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() + |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6547 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 6548 | else { |
| 6549 | PTy = PointerType::get(StoreVal->getType()); |
| 6550 | if (Constant *C = dyn_cast<Constant>(tmpVal)) |
| 6551 | tmpVal = ConstantExpr::getBitCast(C, PTy); |
| 6552 | else |
| 6553 | tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB); |
| 6554 | } |
| 6555 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6556 | (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6557 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6558 | delete (yyvsp[-1].TypeVal).PAT; |
| 6559 | ;} |
| 6560 | break; |
| 6561 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6562 | case 310: |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6563 | #line 3852 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6564 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6565 | (yyvsp[-1].ValIDVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6566 | const Type* Ty = (yyvsp[-2].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6567 | if (!isa<PointerType>(Ty)) |
| 6568 | error("getelementptr insn requires pointer operand"); |
| 6569 | |
| 6570 | std::vector<Value*> VIndices; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6571 | upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6572 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6573 | Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal)); |
| 6574 | (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6575 | ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[-2].TypeVal).S); |
| 6576 | (yyval.InstVal).S.copy(getElementSign(VI, VIndices)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6577 | delete (yyvsp[-2].TypeVal).PAT; |
| 6578 | delete (yyvsp[0].ValueList); |
| 6579 | ;} |
| 6580 | break; |
| 6581 | |
| 6582 | |
| 6583 | default: break; |
| 6584 | } |
| 6585 | |
| 6586 | /* Line 1126 of yacc.c. */ |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6587 | #line 6588 "UpgradeParser.tab.c" |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6588 | |
| 6589 | yyvsp -= yylen; |
| 6590 | yyssp -= yylen; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 6591 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6592 | |
| 6593 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6594 | |
| 6595 | *++yyvsp = yyval; |
| 6596 | |
| 6597 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6598 | /* Now `shift' the result of the reduction. Determine what state |
| 6599 | that goes to, based on the state we popped back to and the rule |
| 6600 | number reduced by. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6601 | |
| 6602 | yyn = yyr1[yyn]; |
| 6603 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6604 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 6605 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6606 | yystate = yytable[yystate]; |
| 6607 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6608 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6609 | |
| 6610 | goto yynewstate; |
| 6611 | |
| 6612 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6613 | /*------------------------------------. |
| 6614 | | yyerrlab -- here on detecting error | |
| 6615 | `------------------------------------*/ |
| 6616 | yyerrlab: |
| 6617 | /* If not already recovering from an error, report this error. */ |
| 6618 | if (!yyerrstatus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6619 | { |
| 6620 | ++yynerrs; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6621 | #if YYERROR_VERBOSE |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6622 | yyn = yypact[yystate]; |
| 6623 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6624 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6625 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6626 | int yytype = YYTRANSLATE (yychar); |
| 6627 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 6628 | YYSIZE_T yysize = yysize0; |
| 6629 | YYSIZE_T yysize1; |
| 6630 | int yysize_overflow = 0; |
| 6631 | char *yymsg = 0; |
| 6632 | # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 |
| 6633 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 6634 | int yyx; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6635 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6636 | #if 0 |
| 6637 | /* This is so xgettext sees the translatable formats that are |
| 6638 | constructed on the fly. */ |
| 6639 | YY_("syntax error, unexpected %s"); |
| 6640 | YY_("syntax error, unexpected %s, expecting %s"); |
| 6641 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 6642 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 6643 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 6644 | #endif |
| 6645 | char *yyfmt; |
| 6646 | char const *yyf; |
| 6647 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 6648 | static char const yyexpecting[] = ", expecting %s"; |
| 6649 | static char const yyor[] = " or %s"; |
| 6650 | char yyformat[sizeof yyunexpected |
| 6651 | + sizeof yyexpecting - 1 |
| 6652 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 6653 | * (sizeof yyor - 1))]; |
| 6654 | char const *yyprefix = yyexpecting; |
| 6655 | |
| 6656 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 6657 | YYCHECK. */ |
| 6658 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 6659 | |
| 6660 | /* Stay within bounds of both yycheck and yytname. */ |
| 6661 | int yychecklim = YYLAST - yyn; |
| 6662 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 6663 | int yycount = 1; |
| 6664 | |
| 6665 | yyarg[0] = yytname[yytype]; |
| 6666 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 6667 | |
| 6668 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 6669 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 6670 | { |
| 6671 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 6672 | { |
| 6673 | yycount = 1; |
| 6674 | yysize = yysize0; |
| 6675 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 6676 | break; |
| 6677 | } |
| 6678 | yyarg[yycount++] = yytname[yyx]; |
| 6679 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 6680 | yysize_overflow |= yysize1 < yysize; |
| 6681 | yysize = yysize1; |
| 6682 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 6683 | yyprefix = yyor; |
| 6684 | } |
| 6685 | |
| 6686 | yyf = YY_(yyformat); |
| 6687 | yysize1 = yysize + yystrlen (yyf); |
| 6688 | yysize_overflow |= yysize1 < yysize; |
| 6689 | yysize = yysize1; |
| 6690 | |
| 6691 | if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) |
| 6692 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 6693 | if (yymsg) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6694 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6695 | /* Avoid sprintf, as that infringes on the user's name space. |
| 6696 | Don't have undefined behavior even if the translation |
| 6697 | produced a string with the wrong number of "%s"s. */ |
| 6698 | char *yyp = yymsg; |
| 6699 | int yyi = 0; |
| 6700 | while ((*yyp = *yyf)) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6701 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6702 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 6703 | { |
| 6704 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 6705 | yyf += 2; |
| 6706 | } |
| 6707 | else |
| 6708 | { |
| 6709 | yyp++; |
| 6710 | yyf++; |
| 6711 | } |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6712 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6713 | yyerror (yymsg); |
| 6714 | YYSTACK_FREE (yymsg); |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6715 | } |
| 6716 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6717 | { |
| 6718 | yyerror (YY_("syntax error")); |
| 6719 | goto yyexhaustedlab; |
| 6720 | } |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6721 | } |
| 6722 | else |
| 6723 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6724 | yyerror (YY_("syntax error")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6725 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6726 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6727 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6728 | |
| 6729 | if (yyerrstatus == 3) |
| 6730 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6731 | /* If just tried and failed to reuse look-ahead token after an |
| 6732 | error, discard it. */ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6733 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6734 | if (yychar <= YYEOF) |
| 6735 | { |
| 6736 | /* Return failure if at end of input. */ |
| 6737 | if (yychar == YYEOF) |
| 6738 | YYABORT; |
| 6739 | } |
| 6740 | else |
| 6741 | { |
| 6742 | yydestruct ("Error: discarding", yytoken, &yylval); |
| 6743 | yychar = YYEMPTY; |
| 6744 | } |
| 6745 | } |
| 6746 | |
| 6747 | /* Else will try to reuse look-ahead token after shifting the error |
| 6748 | token. */ |
| 6749 | goto yyerrlab1; |
| 6750 | |
| 6751 | |
| 6752 | /*---------------------------------------------------. |
| 6753 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 6754 | `---------------------------------------------------*/ |
| 6755 | yyerrorlab: |
| 6756 | |
| 6757 | /* Pacify compilers like GCC when the user code never invokes |
| 6758 | YYERROR and the label yyerrorlab therefore never appears in user |
| 6759 | code. */ |
| 6760 | if (0) |
| 6761 | goto yyerrorlab; |
| 6762 | |
| 6763 | yyvsp -= yylen; |
| 6764 | yyssp -= yylen; |
| 6765 | yystate = *yyssp; |
| 6766 | goto yyerrlab1; |
| 6767 | |
| 6768 | |
| 6769 | /*-------------------------------------------------------------. |
| 6770 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 6771 | `-------------------------------------------------------------*/ |
| 6772 | yyerrlab1: |
| 6773 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 6774 | |
| 6775 | for (;;) |
| 6776 | { |
| 6777 | yyn = yypact[yystate]; |
| 6778 | if (yyn != YYPACT_NINF) |
| 6779 | { |
| 6780 | yyn += YYTERROR; |
| 6781 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 6782 | { |
| 6783 | yyn = yytable[yyn]; |
| 6784 | if (0 < yyn) |
| 6785 | break; |
| 6786 | } |
| 6787 | } |
| 6788 | |
| 6789 | /* Pop the current state because it cannot handle the error token. */ |
| 6790 | if (yyssp == yyss) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6791 | YYABORT; |
| 6792 | |
| 6793 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6794 | yydestruct ("Error: popping", yystos[yystate], yyvsp); |
| 6795 | YYPOPSTACK; |
| 6796 | yystate = *yyssp; |
| 6797 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6798 | } |
| 6799 | |
| 6800 | if (yyn == YYFINAL) |
| 6801 | YYACCEPT; |
| 6802 | |
| 6803 | *++yyvsp = yylval; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6804 | |
| 6805 | |
| 6806 | /* Shift the error token. */ |
| 6807 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6808 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6809 | yystate = yyn; |
| 6810 | goto yynewstate; |
| 6811 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6812 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6813 | /*-------------------------------------. |
| 6814 | | yyacceptlab -- YYACCEPT comes here. | |
| 6815 | `-------------------------------------*/ |
| 6816 | yyacceptlab: |
| 6817 | yyresult = 0; |
| 6818 | goto yyreturn; |
| 6819 | |
| 6820 | /*-----------------------------------. |
| 6821 | | yyabortlab -- YYABORT comes here. | |
| 6822 | `-----------------------------------*/ |
| 6823 | yyabortlab: |
| 6824 | yyresult = 1; |
| 6825 | goto yyreturn; |
| 6826 | |
| 6827 | #ifndef yyoverflow |
| 6828 | /*-------------------------------------------------. |
| 6829 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 6830 | `-------------------------------------------------*/ |
| 6831 | yyexhaustedlab: |
| 6832 | yyerror (YY_("memory exhausted")); |
| 6833 | yyresult = 2; |
| 6834 | /* Fall through. */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6835 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6836 | |
| 6837 | yyreturn: |
| 6838 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 6839 | yydestruct ("Cleanup: discarding lookahead", |
| 6840 | yytoken, &yylval); |
| 6841 | while (yyssp != yyss) |
| 6842 | { |
| 6843 | yydestruct ("Cleanup: popping", |
| 6844 | yystos[*yyssp], yyvsp); |
| 6845 | YYPOPSTACK; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6846 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6847 | #ifndef yyoverflow |
| 6848 | if (yyss != yyssa) |
| 6849 | YYSTACK_FREE (yyss); |
| 6850 | #endif |
| 6851 | return yyresult; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6852 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6853 | |
| 6854 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame^] | 6855 | #line 3870 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6856 | |
| 6857 | |
| 6858 | int yyerror(const char *ErrorMsg) { |
| 6859 | std::string where |
| 6860 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6861 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6862 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 6863 | if (yychar != YYEMPTY && yychar != 0) |
| 6864 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6865 | "'."; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 6866 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6867 | std::cout << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6868 | exit(1); |
| 6869 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6870 | |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 6871 | void warning(const std::string& ErrorMsg) { |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6872 | std::string where |
| 6873 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6874 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6875 | std::string errMsg = where + "warning: " + std::string(ErrorMsg); |
| 6876 | if (yychar != YYEMPTY && yychar != 0) |
| 6877 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6878 | "'."; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6879 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
| 6880 | } |
| 6881 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6882 | void error(const std::string& ErrorMsg, int LineNo) { |
| 6883 | if (LineNo == -1) LineNo = Upgradelineno; |
| 6884 | Upgradelineno = LineNo; |
| 6885 | yyerror(ErrorMsg.c_str()); |
| 6886 | } |
| 6887 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6888 | |