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 | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 380 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 381 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 382 | #include "llvm/ADT/STLExtras.h" |
| 383 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 384 | #include <algorithm> |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 385 | #include <iostream> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 386 | #include <map> |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 387 | #include <list> |
| 388 | #include <utility> |
| 389 | |
| 390 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 391 | // relating to upreferences in the input stream. |
| 392 | // |
| 393 | //#define DEBUG_UPREFS 1 |
| 394 | #ifdef DEBUG_UPREFS |
| 395 | #define UR_OUT(X) std::cerr << X |
| 396 | #else |
| 397 | #define UR_OUT(X) |
| 398 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 399 | |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 400 | #define YYERROR_VERBOSE 1 |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 401 | #define YYINCLUDED_STDLIB_H |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 402 | #define YYDEBUG 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 403 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 404 | int yylex(); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 405 | int yyparse(); |
| 406 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 407 | int yyerror(const char*); |
| 408 | static void warning(const std::string& WarningMsg); |
| 409 | |
| 410 | namespace llvm { |
| 411 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 412 | std::istream* LexInput; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 413 | static std::string CurFilename; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 414 | |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 415 | // This bool controls whether attributes are ever added to function declarations |
| 416 | // definitions and calls. |
| 417 | static bool AddAttributes = false; |
| 418 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 419 | static Module *ParserResult; |
| 420 | static bool ObsoleteVarArgs; |
| 421 | static bool NewVarArgs; |
| 422 | static BasicBlock *CurBB; |
| 423 | static GlobalVariable *CurGV; |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 424 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 425 | // This contains info used when building the body of a function. It is |
| 426 | // destroyed when the function is completed. |
| 427 | // |
| 428 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 429 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 430 | typedef std::pair<std::string,TypeInfo> RenameMapKey; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 431 | typedef std::map<RenameMapKey,std::string> RenameMapType; |
| 432 | |
| 433 | static void |
| 434 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 435 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 436 | |
| 437 | static struct PerModuleInfo { |
| 438 | Module *CurrentModule; |
| 439 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 440 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 441 | std::vector<PATypeHolder> Types; |
| 442 | std::vector<Signedness> TypeSigns; |
| 443 | std::map<std::string,Signedness> NamedTypeSigns; |
| 444 | std::map<std::string,Signedness> NamedValueSigns; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 445 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 446 | static Module::Endianness Endian; |
| 447 | static Module::PointerSize PointerSize; |
| 448 | RenameMapType RenameMap; |
| 449 | |
| 450 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
| 451 | /// how they were referenced and on which line of the input they came from so |
| 452 | /// that we can resolve them later and print error messages as appropriate. |
| 453 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 454 | |
| 455 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 456 | // references to global values. Global values may be referenced before they |
| 457 | // are defined, and if so, the temporary object that they represent is held |
| 458 | // here. This is used for forward references of GlobalValues. |
| 459 | // |
| 460 | typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*> |
| 461 | GlobalRefsType; |
| 462 | GlobalRefsType GlobalRefs; |
| 463 | |
| 464 | void ModuleDone() { |
| 465 | // If we could not resolve some functions at function compilation time |
| 466 | // (calls to functions before they are defined), resolve them now... Types |
| 467 | // are resolved when the constant pool has been completely parsed. |
| 468 | // |
| 469 | ResolveDefinitions(LateResolveValues); |
| 470 | |
| 471 | // Check to make sure that all global value forward references have been |
| 472 | // resolved! |
| 473 | // |
| 474 | if (!GlobalRefs.empty()) { |
| 475 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 476 | |
| 477 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 478 | I != E; ++I) { |
| 479 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 480 | I->first.second.getName() + "\n"; |
| 481 | } |
| 482 | error(UndefinedReferences); |
| 483 | return; |
| 484 | } |
| 485 | |
| 486 | if (CurrentModule->getDataLayout().empty()) { |
| 487 | std::string dataLayout; |
| 488 | if (Endian != Module::AnyEndianness) |
| 489 | dataLayout.append(Endian == Module::BigEndian ? "E" : "e"); |
| 490 | if (PointerSize != Module::AnyPointerSize) { |
| 491 | if (!dataLayout.empty()) |
| 492 | dataLayout += "-"; |
| 493 | dataLayout.append(PointerSize == Module::Pointer64 ? |
| 494 | "p:64:64" : "p:32:32"); |
| 495 | } |
| 496 | CurrentModule->setDataLayout(dataLayout); |
| 497 | } |
| 498 | |
| 499 | Values.clear(); // Clear out function local definitions |
| 500 | Types.clear(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 501 | TypeSigns.clear(); |
| 502 | NamedTypeSigns.clear(); |
| 503 | NamedValueSigns.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 504 | CurrentModule = 0; |
| 505 | } |
| 506 | |
| 507 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 508 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 509 | // If not, just return null. |
| 510 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 511 | // Check to see if there is a forward reference to this global variable... |
| 512 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 513 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 514 | GlobalValue *Ret = 0; |
| 515 | if (I != GlobalRefs.end()) { |
| 516 | Ret = I->second; |
| 517 | GlobalRefs.erase(I); |
| 518 | } |
| 519 | return Ret; |
| 520 | } |
| 521 | void setEndianness(Module::Endianness E) { Endian = E; } |
| 522 | void setPointerSize(Module::PointerSize sz) { PointerSize = sz; } |
| 523 | } CurModule; |
| 524 | |
| 525 | Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness; |
| 526 | Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize; |
| 527 | |
| 528 | static struct PerFunctionInfo { |
| 529 | Function *CurrentFunction; // Pointer to current function being created |
| 530 | |
| 531 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
| 532 | std::map<const Type*, ValueList> LateResolveValues; |
| 533 | bool isDeclare; // Is this function a forward declararation? |
| 534 | GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration. |
| 535 | |
| 536 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 537 | /// track of them here. |
| 538 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 539 | std::vector<BasicBlock*> NumberedBlocks; |
| 540 | RenameMapType RenameMap; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 541 | unsigned NextBBNum; |
| 542 | |
| 543 | inline PerFunctionInfo() { |
| 544 | CurrentFunction = 0; |
| 545 | isDeclare = false; |
| 546 | Linkage = GlobalValue::ExternalLinkage; |
| 547 | } |
| 548 | |
| 549 | inline void FunctionStart(Function *M) { |
| 550 | CurrentFunction = M; |
| 551 | NextBBNum = 0; |
| 552 | } |
| 553 | |
| 554 | void FunctionDone() { |
| 555 | NumberedBlocks.clear(); |
| 556 | |
| 557 | // Any forward referenced blocks left? |
| 558 | if (!BBForwardRefs.empty()) { |
| 559 | error("Undefined reference to label " + |
| 560 | BBForwardRefs.begin()->first->getName()); |
| 561 | return; |
| 562 | } |
| 563 | |
| 564 | // Resolve all forward references now. |
| 565 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 566 | |
| 567 | Values.clear(); // Clear out function local definitions |
| 568 | RenameMap.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 569 | CurrentFunction = 0; |
| 570 | isDeclare = false; |
| 571 | Linkage = GlobalValue::ExternalLinkage; |
| 572 | } |
| 573 | } CurFun; // Info for the current function... |
| 574 | |
| 575 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 576 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 577 | /// This function is just a utility to make a Key value for the rename map. |
| 578 | /// The Key is a combination of the name, type, Signedness of the original |
| 579 | /// value (global/function). This just constructs the key and ensures that |
| 580 | /// named Signedness values are resolved to the actual Signedness. |
| 581 | /// @brief Make a key for the RenameMaps |
| 582 | static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty, |
| 583 | const Signedness &Sign) { |
| 584 | TypeInfo TI; |
| 585 | TI.T = Ty; |
| 586 | if (Sign.isNamed()) |
| 587 | // Don't allow Named Signedness nodes because they won't match. The actual |
| 588 | // Signedness must be looked up in the NamedTypeSigns map. |
| 589 | TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]); |
| 590 | else |
| 591 | TI.S.copy(Sign); |
| 592 | return std::make_pair(Name, TI); |
| 593 | } |
| 594 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 595 | |
| 596 | //===----------------------------------------------------------------------===// |
| 597 | // Code to handle definitions of all the types |
| 598 | //===----------------------------------------------------------------------===// |
| 599 | |
| 600 | static int InsertValue(Value *V, |
| 601 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 602 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 603 | |
| 604 | // Yes, insert the value into the value table... |
| 605 | ValueList &List = ValueTab[V->getType()]; |
| 606 | List.push_back(V); |
| 607 | return List.size()-1; |
| 608 | } |
| 609 | |
Reid Spencer | d7c4f8c | 2007-01-26 19:59:25 +0000 | [diff] [blame] | 610 | static const Type *getType(const ValID &D, bool DoNotImprovise = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 611 | switch (D.Type) { |
| 612 | case ValID::NumberVal: // Is it a numbered definition? |
| 613 | // Module constants occupy the lowest numbered slots... |
| 614 | if ((unsigned)D.Num < CurModule.Types.size()) { |
| 615 | return CurModule.Types[(unsigned)D.Num]; |
| 616 | } |
| 617 | break; |
| 618 | case ValID::NameVal: // Is it a named definition? |
| 619 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 620 | return N; |
| 621 | } |
| 622 | break; |
| 623 | default: |
| 624 | error("Internal parser error: Invalid symbol type reference"); |
| 625 | return 0; |
| 626 | } |
| 627 | |
| 628 | // If we reached here, we referenced either a symbol that we don't know about |
| 629 | // or an id number that hasn't been read yet. We may be referencing something |
| 630 | // forward, so just create an entry to be resolved later and get to it... |
| 631 | // |
| 632 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 633 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 634 | if (inFunctionScope()) { |
| 635 | if (D.Type == ValID::NameVal) { |
| 636 | error("Reference to an undefined type: '" + D.getName() + "'"); |
| 637 | return 0; |
| 638 | } else { |
| 639 | error("Reference to an undefined type: #" + itostr(D.Num)); |
| 640 | return 0; |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 645 | if (I != CurModule.LateResolveTypes.end()) |
| 646 | return I->second; |
| 647 | |
| 648 | Type *Typ = OpaqueType::get(); |
| 649 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 650 | return Typ; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | /// This is like the getType method except that instead of looking up the type |
| 654 | /// for a given ID, it looks up that type's sign. |
| 655 | /// @brief Get the signedness of a referenced type |
| 656 | static Signedness getTypeSign(const ValID &D) { |
| 657 | switch (D.Type) { |
| 658 | case ValID::NumberVal: // Is it a numbered definition? |
| 659 | // Module constants occupy the lowest numbered slots... |
| 660 | if ((unsigned)D.Num < CurModule.TypeSigns.size()) { |
| 661 | return CurModule.TypeSigns[(unsigned)D.Num]; |
| 662 | } |
| 663 | break; |
| 664 | case ValID::NameVal: { // Is it a named definition? |
| 665 | std::map<std::string,Signedness>::const_iterator I = |
| 666 | CurModule.NamedTypeSigns.find(D.Name); |
| 667 | if (I != CurModule.NamedTypeSigns.end()) |
| 668 | return I->second; |
| 669 | // Perhaps its a named forward .. just cache the name |
| 670 | Signedness S; |
| 671 | S.makeNamed(D.Name); |
| 672 | return S; |
| 673 | } |
| 674 | default: |
| 675 | break; |
| 676 | } |
| 677 | // If we don't find it, its signless |
| 678 | Signedness S; |
| 679 | S.makeSignless(); |
| 680 | return S; |
| 681 | } |
| 682 | |
| 683 | /// This function is analagous to getElementType in LLVM. It provides the same |
| 684 | /// function except that it looks up the Signedness instead of the type. This is |
| 685 | /// used when processing GEP instructions that need to extract the type of an |
| 686 | /// indexed struct/array/ptr member. |
| 687 | /// @brief Look up an element's sign. |
| 688 | static Signedness getElementSign(const ValueInfo& VI, |
| 689 | const std::vector<Value*> &Indices) { |
| 690 | const Type *Ptr = VI.V->getType(); |
| 691 | assert(isa<PointerType>(Ptr) && "Need pointer type"); |
| 692 | |
| 693 | unsigned CurIdx = 0; |
| 694 | Signedness S(VI.S); |
| 695 | while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) { |
| 696 | if (CurIdx == Indices.size()) |
| 697 | break; |
| 698 | |
| 699 | Value *Index = Indices[CurIdx++]; |
| 700 | assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type"); |
| 701 | Ptr = CT->getTypeAtIndex(Index); |
| 702 | if (const Type* Ty = Ptr->getForwardedType()) |
| 703 | Ptr = Ty; |
| 704 | assert(S.isComposite() && "Bad Signedness type"); |
| 705 | if (isa<StructType>(CT)) { |
| 706 | S = S.get(cast<ConstantInt>(Index)->getZExtValue()); |
| 707 | } else { |
| 708 | S = S.get(0UL); |
| 709 | } |
| 710 | if (S.isNamed()) |
| 711 | S = CurModule.NamedTypeSigns[S.getName()]; |
| 712 | } |
| 713 | Signedness Result; |
| 714 | Result.makeComposite(S); |
| 715 | return Result; |
| 716 | } |
| 717 | |
| 718 | /// This function just translates a ConstantInfo into a ValueInfo and calls |
| 719 | /// getElementSign(ValueInfo,...). Its just a convenience. |
| 720 | /// @brief ConstantInfo version of getElementSign. |
| 721 | static Signedness getElementSign(const ConstInfo& CI, |
| 722 | const std::vector<Constant*> &Indices) { |
| 723 | ValueInfo VI; |
| 724 | VI.V = CI.C; |
| 725 | VI.S.copy(CI.S); |
| 726 | std::vector<Value*> Idx; |
| 727 | for (unsigned i = 0; i < Indices.size(); ++i) |
| 728 | Idx.push_back(Indices[i]); |
| 729 | Signedness result = getElementSign(VI, Idx); |
| 730 | VI.destroy(); |
| 731 | return result; |
| 732 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 733 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 734 | /// This function determines if two function types differ only in their use of |
| 735 | /// the sret parameter attribute in the first argument. If they are identical |
| 736 | /// in all other respects, it returns true. Otherwise, it returns false. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 737 | static bool FuncTysDifferOnlyBySRet(const FunctionType *F1, |
| 738 | const FunctionType *F2) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 739 | if (F1->getReturnType() != F2->getReturnType() || |
| 740 | F1->getNumParams() != F2->getNumParams() || |
| 741 | F1->getParamAttrs(0) != F2->getParamAttrs(0)) |
| 742 | return false; |
| 743 | unsigned SRetMask = ~unsigned(FunctionType::StructRetAttribute); |
| 744 | for (unsigned i = 0; i < F1->getNumParams(); ++i) { |
| 745 | if (F1->getParamType(i) != F2->getParamType(i) || |
| 746 | unsigned(F1->getParamAttrs(i+1)) & SRetMask != |
| 747 | unsigned(F2->getParamAttrs(i+1)) & SRetMask) |
| 748 | return false; |
| 749 | } |
| 750 | return true; |
| 751 | } |
| 752 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 753 | /// This function determines if the type of V and Ty differ only by the SRet |
| 754 | /// parameter attribute. This is a more generalized case of |
| 755 | /// FuncTysDIfferOnlyBySRet since it doesn't require FunctionType arguments. |
| 756 | static bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) { |
| 757 | if (V->getType() == Ty) |
| 758 | return true; |
| 759 | const PointerType *PF1 = dyn_cast<PointerType>(Ty); |
| 760 | const PointerType *PF2 = dyn_cast<PointerType>(V->getType()); |
| 761 | if (PF1 && PF2) { |
| 762 | const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType()); |
| 763 | const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType()); |
| 764 | if (FT1 && FT2) |
| 765 | return FuncTysDifferOnlyBySRet(FT1, FT2); |
| 766 | } |
| 767 | return false; |
| 768 | } |
| 769 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 770 | // The upgrade of csretcc to sret param attribute may have caused a function |
| 771 | // to not be found because the param attribute changed the type of the called |
| 772 | // function. This helper function, used in getExistingValue, detects that |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 773 | // situation and bitcasts the function to the correct type. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 774 | static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) { |
| 775 | // Handle degenerate cases |
| 776 | if (!V) |
| 777 | return 0; |
| 778 | if (V->getType() == Ty) |
| 779 | return V; |
| 780 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 781 | const PointerType *PF1 = dyn_cast<PointerType>(Ty); |
| 782 | const PointerType *PF2 = dyn_cast<PointerType>(V->getType()); |
| 783 | if (PF1 && PF2) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 784 | const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType()); |
| 785 | const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 786 | if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2)) |
| 787 | if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 788 | return V; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 789 | else if (Constant *C = dyn_cast<Constant>(V)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 790 | return ConstantExpr::getBitCast(C, PF1); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 791 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 792 | return new BitCastInst(V, PF1, "upgrd.cast", CurBB); |
| 793 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 794 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 795 | return 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 796 | } |
| 797 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 798 | // getExistingValue - Look up the value specified by the provided type and |
| 799 | // the provided ValID. If the value exists and has already been defined, return |
| 800 | // it. Otherwise return null. |
| 801 | // |
| 802 | static Value *getExistingValue(const Type *Ty, const ValID &D) { |
| 803 | if (isa<FunctionType>(Ty)) { |
| 804 | error("Functions are not values and must be referenced as pointers"); |
| 805 | } |
| 806 | |
| 807 | switch (D.Type) { |
| 808 | case ValID::NumberVal: { // Is it a numbered definition? |
| 809 | unsigned Num = (unsigned)D.Num; |
| 810 | |
| 811 | // Module constants occupy the lowest numbered slots... |
| 812 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 813 | if (VI != CurModule.Values.end()) { |
| 814 | if (Num < VI->second.size()) |
| 815 | return VI->second[Num]; |
| 816 | Num -= VI->second.size(); |
| 817 | } |
| 818 | |
| 819 | // Make sure that our type is within bounds |
| 820 | VI = CurFun.Values.find(Ty); |
| 821 | if (VI == CurFun.Values.end()) return 0; |
| 822 | |
| 823 | // Check that the number is within bounds... |
| 824 | if (VI->second.size() <= Num) return 0; |
| 825 | |
| 826 | return VI->second[Num]; |
| 827 | } |
| 828 | |
| 829 | case ValID::NameVal: { // Is it a named definition? |
| 830 | // Get the name out of the ID |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 831 | RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S); |
| 832 | Value *V = 0; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 833 | if (inFunctionScope()) { |
| 834 | // See if the name was renamed |
| 835 | RenameMapType::const_iterator I = CurFun.RenameMap.find(Key); |
| 836 | std::string LookupName; |
| 837 | if (I != CurFun.RenameMap.end()) |
| 838 | LookupName = I->second; |
| 839 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 840 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 841 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 842 | V = SymTab.lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 843 | if (V && V->getType() != Ty) |
| 844 | V = handleSRetFuncTypeMerge(V, Ty); |
| 845 | assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 846 | } |
| 847 | if (!V) { |
| 848 | RenameMapType::const_iterator I = CurModule.RenameMap.find(Key); |
| 849 | std::string LookupName; |
| 850 | if (I != CurModule.RenameMap.end()) |
| 851 | LookupName = I->second; |
| 852 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 853 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 854 | V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 855 | if (V && V->getType() != Ty) |
| 856 | V = handleSRetFuncTypeMerge(V, Ty); |
| 857 | assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 858 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 859 | if (!V) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 860 | return 0; |
| 861 | |
| 862 | D.destroy(); // Free old strdup'd memory... |
| 863 | return V; |
| 864 | } |
| 865 | |
| 866 | // Check to make sure that "Ty" is an integral type, and that our |
| 867 | // value will fit into the specified type... |
| 868 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
| 869 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
| 870 | error("Signed integral constant '" + itostr(D.ConstPool64) + |
| 871 | "' is invalid for type '" + Ty->getDescription() + "'"); |
| 872 | } |
| 873 | return ConstantInt::get(Ty, D.ConstPool64); |
| 874 | |
| 875 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
| 876 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 877 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) |
| 878 | error("Integral constant '" + utostr(D.UConstPool64) + |
| 879 | "' is invalid or out of range"); |
| 880 | else // This is really a signed reference. Transmogrify. |
| 881 | return ConstantInt::get(Ty, D.ConstPool64); |
| 882 | } else |
| 883 | return ConstantInt::get(Ty, D.UConstPool64); |
| 884 | |
| 885 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
| 886 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) |
| 887 | error("FP constant invalid for type"); |
| 888 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 889 | |
| 890 | case ValID::ConstNullVal: // Is it a null value? |
| 891 | if (!isa<PointerType>(Ty)) |
| 892 | error("Cannot create a a non pointer null"); |
| 893 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 894 | |
| 895 | case ValID::ConstUndefVal: // Is it an undef value? |
| 896 | return UndefValue::get(Ty); |
| 897 | |
| 898 | case ValID::ConstZeroVal: // Is it a zero value? |
| 899 | return Constant::getNullValue(Ty); |
| 900 | |
| 901 | case ValID::ConstantVal: // Fully resolved constant? |
| 902 | if (D.ConstantValue->getType() != Ty) |
| 903 | error("Constant expression type different from required type"); |
| 904 | return D.ConstantValue; |
| 905 | |
| 906 | case ValID::InlineAsmVal: { // Inline asm expression |
| 907 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 908 | const FunctionType *FTy = |
| 909 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
| 910 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) |
| 911 | error("Invalid type for asm constraint string"); |
| 912 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 913 | D.IAD->HasSideEffects); |
| 914 | D.destroy(); // Free InlineAsmDescriptor. |
| 915 | return IA; |
| 916 | } |
| 917 | default: |
| 918 | assert(0 && "Unhandled case"); |
| 919 | return 0; |
| 920 | } // End of switch |
| 921 | |
| 922 | assert(0 && "Unhandled case"); |
| 923 | return 0; |
| 924 | } |
| 925 | |
| 926 | // getVal - This function is identical to getExistingValue, except that if a |
| 927 | // value is not already defined, it "improvises" by creating a placeholder var |
| 928 | // that looks and acts just like the requested variable. When the value is |
| 929 | // defined later, all uses of the placeholder variable are replaced with the |
| 930 | // real thing. |
| 931 | // |
| 932 | static Value *getVal(const Type *Ty, const ValID &ID) { |
| 933 | if (Ty == Type::LabelTy) |
| 934 | error("Cannot use a basic block here"); |
| 935 | |
| 936 | // See if the value has already been defined. |
| 937 | Value *V = getExistingValue(Ty, ID); |
| 938 | if (V) return V; |
| 939 | |
| 940 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) |
| 941 | error("Invalid use of a composite type"); |
| 942 | |
| 943 | // If we reached here, we referenced either a symbol that we don't know about |
| 944 | // or an id number that hasn't been read yet. We may be referencing something |
| 945 | // 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] | 946 | V = new Argument(Ty); |
| 947 | |
| 948 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 949 | // to recycle these things?? |
| 950 | CurModule.PlaceHolderInfo.insert( |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 951 | std::make_pair(V, std::make_pair(ID, Upgradelineno))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 952 | |
| 953 | if (inFunctionScope()) |
| 954 | InsertValue(V, CurFun.LateResolveValues); |
| 955 | else |
| 956 | InsertValue(V, CurModule.LateResolveValues); |
| 957 | return V; |
| 958 | } |
| 959 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 960 | /// @brief This just makes any name given to it unique, up to MAX_UINT times. |
| 961 | static std::string makeNameUnique(const std::string& Name) { |
| 962 | static unsigned UniqueNameCounter = 1; |
| 963 | std::string Result(Name); |
| 964 | Result += ".upgrd." + llvm::utostr(UniqueNameCounter++); |
| 965 | return Result; |
| 966 | } |
| 967 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 968 | /// getBBVal - This is used for two purposes: |
| 969 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 970 | /// defined. |
| 971 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 972 | /// or may not be a forward reference. |
| 973 | /// |
| 974 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 975 | assert(inFunctionScope() && "Can't get basic block at global scope"); |
| 976 | |
| 977 | std::string Name; |
| 978 | BasicBlock *BB = 0; |
| 979 | switch (ID.Type) { |
| 980 | default: |
| 981 | error("Illegal label reference " + ID.getName()); |
| 982 | break; |
| 983 | case ValID::NumberVal: // Is it a numbered definition? |
| 984 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 985 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 986 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 987 | break; |
| 988 | case ValID::NameVal: // Is it a named definition? |
| 989 | Name = ID.Name; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 990 | if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 991 | if (N->getType() != Type::LabelTy) { |
| 992 | // Register names didn't use to conflict with basic block names |
| 993 | // because of type planes. Now they all have to be unique. So, we just |
| 994 | // rename the register and treat this name as if no basic block |
| 995 | // had been found. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 996 | RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 997 | N->setName(makeNameUnique(N->getName())); |
| 998 | CurModule.RenameMap[Key] = N->getName(); |
| 999 | BB = 0; |
| 1000 | } else { |
| 1001 | BB = cast<BasicBlock>(N); |
| 1002 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1003 | } |
| 1004 | break; |
| 1005 | } |
| 1006 | |
| 1007 | // See if the block has already been defined. |
| 1008 | if (BB) { |
| 1009 | // If this is the definition of the block, make sure the existing value was |
| 1010 | // just a forward reference. If it was a forward reference, there will be |
| 1011 | // an entry for it in the PlaceHolderInfo map. |
| 1012 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) |
| 1013 | // The existing value was a definition, not a forward reference. |
| 1014 | error("Redefinition of label " + ID.getName()); |
| 1015 | |
| 1016 | ID.destroy(); // Free strdup'd memory. |
| 1017 | return BB; |
| 1018 | } |
| 1019 | |
| 1020 | // Otherwise this block has not been seen before. |
| 1021 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 1022 | if (ID.Type == ValID::NameVal) { |
| 1023 | BB->setName(ID.Name); |
| 1024 | } else { |
| 1025 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 1026 | } |
| 1027 | |
| 1028 | // If this is not a definition, keep track of it so we can use it as a forward |
| 1029 | // reference. |
| 1030 | if (!isDefinition) { |
| 1031 | // Remember where this forward reference came from. |
| 1032 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno); |
| 1033 | } else { |
| 1034 | // The forward declaration could have been inserted anywhere in the |
| 1035 | // function: insert it into the correct place now. |
| 1036 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 1037 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 1038 | } |
| 1039 | ID.destroy(); |
| 1040 | return BB; |
| 1041 | } |
| 1042 | |
| 1043 | |
| 1044 | //===----------------------------------------------------------------------===// |
| 1045 | // Code to handle forward references in instructions |
| 1046 | //===----------------------------------------------------------------------===// |
| 1047 | // |
| 1048 | // This code handles the late binding needed with statements that reference |
| 1049 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 1050 | // a loop body. |
| 1051 | // |
| 1052 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 1053 | // and back patchs after we are done. |
| 1054 | // |
| 1055 | |
| 1056 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 1057 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 1058 | // defs now... |
| 1059 | // |
| 1060 | static void |
| 1061 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 1062 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1063 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1064 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 1065 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 1066 | E = LateResolvers.end(); LRI != E; ++LRI) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1067 | const Type* Ty = LRI->first; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1068 | ValueList &List = LRI->second; |
| 1069 | while (!List.empty()) { |
| 1070 | Value *V = List.back(); |
| 1071 | List.pop_back(); |
| 1072 | |
| 1073 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 1074 | CurModule.PlaceHolderInfo.find(V); |
| 1075 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error"); |
| 1076 | |
| 1077 | ValID &DID = PHI->second.first; |
| 1078 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1079 | Value *TheRealValue = getExistingValue(Ty, DID); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1080 | if (TheRealValue) { |
| 1081 | V->replaceAllUsesWith(TheRealValue); |
| 1082 | delete V; |
| 1083 | CurModule.PlaceHolderInfo.erase(PHI); |
| 1084 | } else if (FutureLateResolvers) { |
| 1085 | // Functions have their unresolved items forwarded to the module late |
| 1086 | // resolver table |
| 1087 | InsertValue(V, *FutureLateResolvers); |
| 1088 | } else { |
| 1089 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1090 | error("Reference to an invalid definition: '" + DID.getName() + |
| 1091 | "' of type '" + V->getType()->getDescription() + "'", |
| 1092 | PHI->second.second); |
Reid Spencer | 7de2e01 | 2007-01-29 19:08:46 +0000 | [diff] [blame] | 1093 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1094 | } else { |
| 1095 | error("Reference to an invalid definition: #" + |
| 1096 | itostr(DID.Num) + " of type '" + |
| 1097 | V->getType()->getDescription() + "'", PHI->second.second); |
| 1098 | return; |
| 1099 | } |
| 1100 | } |
| 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | LateResolvers.clear(); |
| 1105 | } |
| 1106 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1107 | /// This function is used for type resolution and upref handling. When a type |
| 1108 | /// becomes concrete, this function is called to adjust the signedness for the |
| 1109 | /// concrete type. |
| 1110 | static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) { |
| 1111 | std::string TyName = CurModule.CurrentModule->getTypeName(oldTy); |
| 1112 | if (!TyName.empty()) |
| 1113 | CurModule.NamedTypeSigns[TyName] = Sign; |
| 1114 | } |
| 1115 | |
| 1116 | /// ResolveTypeTo - A brand new type was just declared. This means that (if |
| 1117 | /// name is not null) things referencing Name can be resolved. Otherwise, |
| 1118 | /// things refering to the number can be resolved. Do this now. |
| 1119 | static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1120 | ValID D; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1121 | if (Name) |
| 1122 | D = ValID::create(Name); |
| 1123 | else |
| 1124 | D = ValID::create((int)CurModule.Types.size()); |
| 1125 | D.S.copy(Sign); |
| 1126 | |
| 1127 | CurModule.NamedTypeSigns[Name] = Sign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1128 | |
| 1129 | std::map<ValID, PATypeHolder>::iterator I = |
| 1130 | CurModule.LateResolveTypes.find(D); |
| 1131 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1132 | const Type *OldTy = I->second.get(); |
| 1133 | ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1134 | CurModule.LateResolveTypes.erase(I); |
| 1135 | } |
| 1136 | } |
| 1137 | |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1138 | /// This is the implementation portion of TypeHasInteger. It traverses the |
| 1139 | /// type given, avoiding recursive types, and returns true as soon as it finds |
| 1140 | /// an integer type. If no integer type is found, it returns false. |
| 1141 | static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) { |
| 1142 | // Handle some easy cases |
| 1143 | if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID)) |
| 1144 | return false; |
| 1145 | if (Ty->isInteger()) |
| 1146 | return true; |
| 1147 | if (const SequentialType *STy = dyn_cast<SequentialType>(Ty)) |
| 1148 | return STy->getElementType()->isInteger(); |
| 1149 | |
| 1150 | // Avoid type structure recursion |
| 1151 | for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end(); |
| 1152 | I != E; ++I) |
| 1153 | if (Ty == *I) |
| 1154 | return false; |
| 1155 | |
| 1156 | // Push us on the type stack |
| 1157 | Stack.push_back(Ty); |
| 1158 | |
| 1159 | if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) { |
| 1160 | if (TypeHasIntegerI(FTy->getReturnType(), Stack)) |
| 1161 | return true; |
| 1162 | FunctionType::param_iterator I = FTy->param_begin(); |
| 1163 | FunctionType::param_iterator E = FTy->param_end(); |
| 1164 | for (; I != E; ++I) |
| 1165 | if (TypeHasIntegerI(*I, Stack)) |
| 1166 | return true; |
| 1167 | return false; |
| 1168 | } else if (const StructType *STy = dyn_cast<StructType>(Ty)) { |
| 1169 | StructType::element_iterator I = STy->element_begin(); |
| 1170 | StructType::element_iterator E = STy->element_end(); |
| 1171 | for (; I != E; ++I) { |
| 1172 | if (TypeHasIntegerI(*I, Stack)) |
| 1173 | return true; |
| 1174 | } |
| 1175 | return false; |
| 1176 | } |
| 1177 | // There shouldn't be anything else, but its definitely not integer |
| 1178 | assert(0 && "What type is this?"); |
| 1179 | return false; |
| 1180 | } |
| 1181 | |
| 1182 | /// This is the interface to TypeHasIntegerI. It just provides the type stack, |
| 1183 | /// to avoid recursion, and then calls TypeHasIntegerI. |
| 1184 | static inline bool TypeHasInteger(const Type *Ty) { |
| 1185 | std::vector<const Type*> TyStack; |
| 1186 | return TypeHasIntegerI(Ty, TyStack); |
| 1187 | } |
| 1188 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1189 | // setValueName - Set the specified value to the name given. The name may be |
| 1190 | // null potentially, in which case this is a noop. The string passed in is |
| 1191 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 1192 | // |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1193 | static void setValueName(const ValueInfo &V, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1194 | if (NameStr) { |
| 1195 | std::string Name(NameStr); // Copy string |
| 1196 | free(NameStr); // Free old string |
| 1197 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1198 | if (V.V->getType() == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1199 | error("Can't assign name '" + Name + "' to value with void type"); |
| 1200 | return; |
| 1201 | } |
| 1202 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1203 | assert(inFunctionScope() && "Must be in function scope"); |
| 1204 | |
| 1205 | // 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] | 1206 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 1207 | Value* Existing = ST.lookup(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1208 | if (Existing) { |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1209 | // An existing value of the same name was found. This might have happened |
| 1210 | // because of the integer type planes collapsing in LLVM 2.0. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1211 | if (Existing->getType() == V.V->getType() && |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1212 | !TypeHasInteger(Existing->getType())) { |
| 1213 | // If the type does not contain any integers in them then this can't be |
| 1214 | // a type plane collapsing issue. It truly is a redefinition and we |
| 1215 | // should error out as the assembly is invalid. |
| 1216 | error("Redefinition of value named '" + Name + "' of type '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1217 | V.V->getType()->getDescription() + "'"); |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1218 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1219 | } |
| 1220 | // In LLVM 2.0 we don't allow names to be re-used for any values in a |
| 1221 | // function, regardless of Type. Previously re-use of names was okay as |
| 1222 | // long as they were distinct types. With type planes collapsing because |
| 1223 | // of the signedness change and because of PR411, this can no longer be |
| 1224 | // supported. We must search the entire symbol table for a conflicting |
| 1225 | // name and make the name unique. No warning is needed as this can't |
| 1226 | // cause a problem. |
| 1227 | std::string NewName = makeNameUnique(Name); |
| 1228 | // We're changing the name but it will probably be used by other |
| 1229 | // instructions as operands later on. Consequently we have to retain |
| 1230 | // a mapping of the renaming that we're doing. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1231 | RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1232 | CurFun.RenameMap[Key] = NewName; |
| 1233 | Name = NewName; |
| 1234 | } |
| 1235 | |
| 1236 | // Set the name. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1237 | V.V->setName(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 1242 | /// this is a declaration, otherwise it is a definition. |
| 1243 | static GlobalVariable * |
| 1244 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 1245 | bool isConstantGlobal, const Type *Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1246 | Constant *Initializer, |
| 1247 | const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1248 | if (isa<FunctionType>(Ty)) |
| 1249 | error("Cannot declare global vars of function type"); |
| 1250 | |
| 1251 | const PointerType *PTy = PointerType::get(Ty); |
| 1252 | |
| 1253 | std::string Name; |
| 1254 | if (NameStr) { |
| 1255 | Name = NameStr; // Copy string |
| 1256 | free(NameStr); // Free old string |
| 1257 | } |
| 1258 | |
| 1259 | // See if this global value was forward referenced. If so, recycle the |
| 1260 | // object. |
| 1261 | ValID ID; |
| 1262 | if (!Name.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1263 | ID = ValID::create((char*)Name.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1264 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1265 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1266 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1267 | ID.S.makeComposite(Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1268 | |
| 1269 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1270 | // Move the global to the end of the list, from whereever it was |
| 1271 | // previously inserted. |
| 1272 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1273 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1274 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1275 | GV->setInitializer(Initializer); |
| 1276 | GV->setLinkage(Linkage); |
| 1277 | GV->setConstant(isConstantGlobal); |
| 1278 | InsertValue(GV, CurModule.Values); |
| 1279 | return GV; |
| 1280 | } |
| 1281 | |
| 1282 | // If this global has a name, check to see if there is already a definition |
| 1283 | // of this global in the module and emit warnings if there are conflicts. |
| 1284 | if (!Name.empty()) { |
| 1285 | // The global has a name. See if there's an existing one of the same name. |
| 1286 | if (CurModule.CurrentModule->getNamedGlobal(Name)) { |
| 1287 | // We found an existing global ov the same name. This isn't allowed |
| 1288 | // in LLVM 2.0. Consequently, we must alter the name of the global so it |
| 1289 | // can at least compile. This can happen because of type planes |
| 1290 | // There is alread a global of the same name which means there is a |
| 1291 | // conflict. Let's see what we can do about it. |
| 1292 | std::string NewName(makeNameUnique(Name)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1293 | if (Linkage != GlobalValue::InternalLinkage) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1294 | // The linkage of this gval is external so we can't reliably rename |
| 1295 | // it because it could potentially create a linking problem. |
| 1296 | // However, we can't leave the name conflict in the output either or |
| 1297 | // it won't assemble with LLVM 2.0. So, all we can do is rename |
| 1298 | // this one to something unique and emit a warning about the problem. |
| 1299 | warning("Renaming global variable '" + Name + "' to '" + NewName + |
| 1300 | "' may cause linkage errors"); |
| 1301 | } |
| 1302 | |
| 1303 | // Put the renaming in the global rename map |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1304 | RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1305 | CurModule.RenameMap[Key] = NewName; |
| 1306 | |
| 1307 | // Rename it |
| 1308 | Name = NewName; |
| 1309 | } |
| 1310 | } |
| 1311 | |
| 1312 | // Otherwise there is no existing GV to use, create one now. |
| 1313 | GlobalVariable *GV = |
| 1314 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 1315 | CurModule.CurrentModule); |
| 1316 | InsertValue(GV, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1317 | // Remember the sign of this global. |
| 1318 | CurModule.NamedValueSigns[Name] = ID.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1319 | return GV; |
| 1320 | } |
| 1321 | |
| 1322 | // setTypeName - Set the specified type to the name given. The name may be |
| 1323 | // null potentially, in which case this is a noop. The string passed in is |
| 1324 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1325 | // |
| 1326 | // This function returns true if the type has already been defined, but is |
| 1327 | // allowed to be redefined in the specified context. If the name is a new name |
| 1328 | // for the type plane, it is inserted and false is returned. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1329 | static bool setTypeName(const PATypeInfo& TI, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1330 | assert(!inFunctionScope() && "Can't give types function-local names"); |
| 1331 | if (NameStr == 0) return false; |
| 1332 | |
| 1333 | std::string Name(NameStr); // Copy string |
| 1334 | free(NameStr); // Free old string |
| 1335 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1336 | const Type* Ty = TI.PAT->get(); |
| 1337 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1338 | // We don't allow assigning names to void type |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1339 | if (Ty == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1340 | error("Can't assign name '" + Name + "' to the void type"); |
| 1341 | return false; |
| 1342 | } |
| 1343 | |
| 1344 | // Set the type name, checking for conflicts as we do so. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1345 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty); |
| 1346 | |
| 1347 | // Save the sign information for later use |
| 1348 | CurModule.NamedTypeSigns[Name] = TI.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1349 | |
| 1350 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1351 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 1352 | assert(Existing && "Conflict but no matching type?"); |
| 1353 | |
| 1354 | // There is only one case where this is allowed: when we are refining an |
| 1355 | // opaque type. In this case, Existing will be an opaque type. |
| 1356 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1357 | // We ARE replacing an opaque type! |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1358 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1359 | return true; |
| 1360 | } |
| 1361 | |
| 1362 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1363 | // the redefinition is identical to the original. This will be so if |
| 1364 | // Existing and T point to the same Type object. In this one case we |
| 1365 | // allow the equivalent redefinition. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1366 | if (Existing == Ty) return true; // Yes, it's equal. |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1367 | |
| 1368 | // Any other kind of (non-equivalent) redefinition is an error. |
| 1369 | error("Redefinition of type named '" + Name + "' in the '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1370 | Ty->getDescription() + "' type plane"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1371 | } |
| 1372 | |
| 1373 | return false; |
| 1374 | } |
| 1375 | |
| 1376 | //===----------------------------------------------------------------------===// |
| 1377 | // Code for handling upreferences in type names... |
| 1378 | // |
| 1379 | |
| 1380 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1381 | // |
| 1382 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1383 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1384 | E) != Ty->subtype_end(); |
| 1385 | } |
| 1386 | |
| 1387 | namespace { |
| 1388 | struct UpRefRecord { |
| 1389 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1390 | // this type is resolved. |
| 1391 | unsigned NestingLevel; |
| 1392 | |
| 1393 | // LastContainedTy - This is the type at the current binding level for the |
| 1394 | // type. Every time we reduce the nesting level, this gets updated. |
| 1395 | const Type *LastContainedTy; |
| 1396 | |
| 1397 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1398 | // represented with. |
| 1399 | OpaqueType *UpRefTy; |
| 1400 | |
| 1401 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1402 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1403 | }; |
| 1404 | } |
| 1405 | |
| 1406 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1407 | static std::vector<UpRefRecord> UpRefs; |
| 1408 | |
| 1409 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1410 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1411 | /// currently active types. For each type, if the up reference is contained in |
| 1412 | /// the newly completed type, we decrement the level count. When the level |
| 1413 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1414 | /// thus we can complete the cycle. |
| 1415 | /// |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1416 | static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1417 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1418 | // nothing to resolve here. |
| 1419 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1420 | |
| 1421 | PATypeHolder Ty(ty); |
| 1422 | UR_OUT("Type '" << Ty->getDescription() << |
| 1423 | "' newly formed. Resolving upreferences.\n" << |
| 1424 | UpRefs.size() << " upreferences active!\n"); |
| 1425 | |
| 1426 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1427 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1428 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1429 | // this variable. |
| 1430 | OpaqueType *TypeToResolve = 0; |
| 1431 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1432 | unsigned i = 0; |
| 1433 | for (; i != UpRefs.size(); ++i) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1434 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1435 | << UpRefs[i].UpRefTy->getDescription() << ") = " |
| 1436 | << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1437 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1438 | // Decrement level of upreference |
| 1439 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1440 | UpRefs[i].LastContainedTy = Ty; |
| 1441 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1442 | if (Level == 0) { // Upreference should be resolved! |
| 1443 | if (!TypeToResolve) { |
| 1444 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1445 | } else { |
| 1446 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1447 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
| 1448 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1449 | ResolveTypeSign(UpRefs[i].UpRefTy, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1450 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1451 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1452 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1453 | } |
| 1454 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1455 | --i; // Do not skip the next element... |
| 1456 | } |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | if (TypeToResolve) { |
| 1461 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1462 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1463 | std::string OldName = TypeToResolve->getDescription()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1464 | ResolveTypeSign(TypeToResolve, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1465 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1466 | } |
| 1467 | |
| 1468 | return Ty; |
| 1469 | } |
| 1470 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1471 | bool Signedness::operator<(const Signedness &that) const { |
| 1472 | if (isNamed()) { |
| 1473 | if (that.isNamed()) |
| 1474 | return *(this->name) < *(that.name); |
| 1475 | else |
| 1476 | return CurModule.NamedTypeSigns[*name] < that; |
| 1477 | } else if (that.isNamed()) { |
| 1478 | return *this < CurModule.NamedTypeSigns[*that.name]; |
| 1479 | } |
| 1480 | |
| 1481 | if (isComposite() && that.isComposite()) { |
| 1482 | if (sv->size() == that.sv->size()) { |
| 1483 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1484 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1485 | thatE = that.sv->end(); |
| 1486 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1487 | if (*thisI < *thatI) |
| 1488 | return true; |
| 1489 | else if (!(*thisI == *thatI)) |
| 1490 | return false; |
| 1491 | } |
| 1492 | return false; |
| 1493 | } |
| 1494 | return sv->size() < that.sv->size(); |
| 1495 | } |
| 1496 | return kind < that.kind; |
| 1497 | } |
| 1498 | |
| 1499 | bool Signedness::operator==(const Signedness &that) const { |
| 1500 | if (isNamed()) |
| 1501 | if (that.isNamed()) |
| 1502 | return *(this->name) == *(that.name); |
| 1503 | else |
| 1504 | return CurModule.NamedTypeSigns[*(this->name)] == that; |
| 1505 | else if (that.isNamed()) |
| 1506 | return *this == CurModule.NamedTypeSigns[*(that.name)]; |
| 1507 | if (isComposite() && that.isComposite()) { |
| 1508 | if (sv->size() == that.sv->size()) { |
| 1509 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1510 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1511 | thatE = that.sv->end(); |
| 1512 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1513 | if (!(*thisI == *thatI)) |
| 1514 | return false; |
| 1515 | } |
| 1516 | return true; |
| 1517 | } |
| 1518 | return false; |
| 1519 | } |
| 1520 | return kind == that.kind; |
| 1521 | } |
| 1522 | |
| 1523 | void Signedness::copy(const Signedness &that) { |
| 1524 | if (that.isNamed()) { |
| 1525 | kind = Named; |
| 1526 | name = new std::string(*that.name); |
| 1527 | } else if (that.isComposite()) { |
| 1528 | kind = Composite; |
| 1529 | sv = new SignVector(); |
| 1530 | *sv = *that.sv; |
| 1531 | } else { |
| 1532 | kind = that.kind; |
| 1533 | sv = 0; |
| 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | void Signedness::destroy() { |
| 1538 | if (isNamed()) { |
| 1539 | delete name; |
| 1540 | } else if (isComposite()) { |
| 1541 | delete sv; |
| 1542 | } |
| 1543 | } |
| 1544 | |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1545 | #ifndef NDEBUG |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1546 | void Signedness::dump() const { |
| 1547 | if (isComposite()) { |
| 1548 | if (sv->size() == 1) { |
| 1549 | (*sv)[0].dump(); |
| 1550 | std::cerr << "*"; |
| 1551 | } else { |
| 1552 | std::cerr << "{ " ; |
| 1553 | for (unsigned i = 0; i < sv->size(); ++i) { |
| 1554 | if (i != 0) |
| 1555 | std::cerr << ", "; |
| 1556 | (*sv)[i].dump(); |
| 1557 | } |
| 1558 | std::cerr << "} " ; |
| 1559 | } |
| 1560 | } else if (isNamed()) { |
| 1561 | std::cerr << *name; |
| 1562 | } else if (isSigned()) { |
| 1563 | std::cerr << "S"; |
| 1564 | } else if (isUnsigned()) { |
| 1565 | std::cerr << "U"; |
| 1566 | } else |
| 1567 | std::cerr << "."; |
| 1568 | } |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1569 | #endif |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1570 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1571 | static inline Instruction::TermOps |
| 1572 | getTermOp(TermOps op) { |
| 1573 | switch (op) { |
| 1574 | default : assert(0 && "Invalid OldTermOp"); |
| 1575 | case RetOp : return Instruction::Ret; |
| 1576 | case BrOp : return Instruction::Br; |
| 1577 | case SwitchOp : return Instruction::Switch; |
| 1578 | case InvokeOp : return Instruction::Invoke; |
| 1579 | case UnwindOp : return Instruction::Unwind; |
| 1580 | case UnreachableOp: return Instruction::Unreachable; |
| 1581 | } |
| 1582 | } |
| 1583 | |
| 1584 | static inline Instruction::BinaryOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1585 | getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1586 | switch (op) { |
| 1587 | default : assert(0 && "Invalid OldBinaryOps"); |
| 1588 | case SetEQ : |
| 1589 | case SetNE : |
| 1590 | case SetLE : |
| 1591 | case SetGE : |
| 1592 | case SetLT : |
| 1593 | case SetGT : assert(0 && "Should use getCompareOp"); |
| 1594 | case AddOp : return Instruction::Add; |
| 1595 | case SubOp : return Instruction::Sub; |
| 1596 | case MulOp : return Instruction::Mul; |
| 1597 | case DivOp : { |
| 1598 | // This is an obsolete instruction so we must upgrade it based on the |
| 1599 | // types of its operands. |
| 1600 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1601 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1602 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1603 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1604 | if (isFP) |
| 1605 | return Instruction::FDiv; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1606 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1607 | return Instruction::SDiv; |
| 1608 | return Instruction::UDiv; |
| 1609 | } |
| 1610 | case UDivOp : return Instruction::UDiv; |
| 1611 | case SDivOp : return Instruction::SDiv; |
| 1612 | case FDivOp : return Instruction::FDiv; |
| 1613 | case RemOp : { |
| 1614 | // This is an obsolete instruction so we must upgrade it based on the |
| 1615 | // types of its operands. |
| 1616 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1617 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1618 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1619 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1620 | // Select correct opcode |
| 1621 | if (isFP) |
| 1622 | return Instruction::FRem; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1623 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1624 | return Instruction::SRem; |
| 1625 | return Instruction::URem; |
| 1626 | } |
| 1627 | case URemOp : return Instruction::URem; |
| 1628 | case SRemOp : return Instruction::SRem; |
| 1629 | case FRemOp : return Instruction::FRem; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1630 | case LShrOp : return Instruction::LShr; |
| 1631 | case AShrOp : return Instruction::AShr; |
| 1632 | case ShlOp : return Instruction::Shl; |
| 1633 | case ShrOp : |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1634 | if (Sign.isSigned()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1635 | return Instruction::AShr; |
| 1636 | return Instruction::LShr; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1637 | case AndOp : return Instruction::And; |
| 1638 | case OrOp : return Instruction::Or; |
| 1639 | case XorOp : return Instruction::Xor; |
| 1640 | } |
| 1641 | } |
| 1642 | |
| 1643 | static inline Instruction::OtherOps |
| 1644 | getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1645 | const Signedness &Sign) { |
| 1646 | bool isSigned = Sign.isSigned(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1647 | bool isFP = Ty->isFloatingPoint(); |
| 1648 | switch (op) { |
| 1649 | default : assert(0 && "Invalid OldSetCC"); |
| 1650 | case SetEQ : |
| 1651 | if (isFP) { |
| 1652 | predicate = FCmpInst::FCMP_OEQ; |
| 1653 | return Instruction::FCmp; |
| 1654 | } else { |
| 1655 | predicate = ICmpInst::ICMP_EQ; |
| 1656 | return Instruction::ICmp; |
| 1657 | } |
| 1658 | case SetNE : |
| 1659 | if (isFP) { |
| 1660 | predicate = FCmpInst::FCMP_UNE; |
| 1661 | return Instruction::FCmp; |
| 1662 | } else { |
| 1663 | predicate = ICmpInst::ICMP_NE; |
| 1664 | return Instruction::ICmp; |
| 1665 | } |
| 1666 | case SetLE : |
| 1667 | if (isFP) { |
| 1668 | predicate = FCmpInst::FCMP_OLE; |
| 1669 | return Instruction::FCmp; |
| 1670 | } else { |
| 1671 | if (isSigned) |
| 1672 | predicate = ICmpInst::ICMP_SLE; |
| 1673 | else |
| 1674 | predicate = ICmpInst::ICMP_ULE; |
| 1675 | return Instruction::ICmp; |
| 1676 | } |
| 1677 | case SetGE : |
| 1678 | if (isFP) { |
| 1679 | predicate = FCmpInst::FCMP_OGE; |
| 1680 | return Instruction::FCmp; |
| 1681 | } else { |
| 1682 | if (isSigned) |
| 1683 | predicate = ICmpInst::ICMP_SGE; |
| 1684 | else |
| 1685 | predicate = ICmpInst::ICMP_UGE; |
| 1686 | return Instruction::ICmp; |
| 1687 | } |
| 1688 | case SetLT : |
| 1689 | if (isFP) { |
| 1690 | predicate = FCmpInst::FCMP_OLT; |
| 1691 | return Instruction::FCmp; |
| 1692 | } else { |
| 1693 | if (isSigned) |
| 1694 | predicate = ICmpInst::ICMP_SLT; |
| 1695 | else |
| 1696 | predicate = ICmpInst::ICMP_ULT; |
| 1697 | return Instruction::ICmp; |
| 1698 | } |
| 1699 | case SetGT : |
| 1700 | if (isFP) { |
| 1701 | predicate = FCmpInst::FCMP_OGT; |
| 1702 | return Instruction::FCmp; |
| 1703 | } else { |
| 1704 | if (isSigned) |
| 1705 | predicate = ICmpInst::ICMP_SGT; |
| 1706 | else |
| 1707 | predicate = ICmpInst::ICMP_UGT; |
| 1708 | return Instruction::ICmp; |
| 1709 | } |
| 1710 | } |
| 1711 | } |
| 1712 | |
| 1713 | static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) { |
| 1714 | switch (op) { |
| 1715 | default : assert(0 && "Invalid OldMemoryOps"); |
| 1716 | case MallocOp : return Instruction::Malloc; |
| 1717 | case FreeOp : return Instruction::Free; |
| 1718 | case AllocaOp : return Instruction::Alloca; |
| 1719 | case LoadOp : return Instruction::Load; |
| 1720 | case StoreOp : return Instruction::Store; |
| 1721 | case GetElementPtrOp : return Instruction::GetElementPtr; |
| 1722 | } |
| 1723 | } |
| 1724 | |
| 1725 | static inline Instruction::OtherOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1726 | getOtherOp(OtherOps op, const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1727 | switch (op) { |
| 1728 | default : assert(0 && "Invalid OldOtherOps"); |
| 1729 | case PHIOp : return Instruction::PHI; |
| 1730 | case CallOp : return Instruction::Call; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1731 | case SelectOp : return Instruction::Select; |
| 1732 | case UserOp1 : return Instruction::UserOp1; |
| 1733 | case UserOp2 : return Instruction::UserOp2; |
| 1734 | case VAArg : return Instruction::VAArg; |
| 1735 | case ExtractElementOp : return Instruction::ExtractElement; |
| 1736 | case InsertElementOp : return Instruction::InsertElement; |
| 1737 | case ShuffleVectorOp : return Instruction::ShuffleVector; |
| 1738 | case ICmpOp : return Instruction::ICmp; |
| 1739 | case FCmpOp : return Instruction::FCmp; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1740 | }; |
| 1741 | } |
| 1742 | |
| 1743 | static inline Value* |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1744 | getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy, |
| 1745 | const Signedness &DstSign, bool ForceInstruction = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1746 | Instruction::CastOps Opcode; |
| 1747 | const Type* SrcTy = Src->getType(); |
| 1748 | if (op == CastOp) { |
| 1749 | if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) { |
| 1750 | // fp -> ptr cast is no longer supported but we must upgrade this |
| 1751 | // by doing a double cast: fp -> int -> ptr |
| 1752 | SrcTy = Type::Int64Ty; |
| 1753 | Opcode = Instruction::IntToPtr; |
| 1754 | if (isa<Constant>(Src)) { |
| 1755 | Src = ConstantExpr::getCast(Instruction::FPToUI, |
| 1756 | cast<Constant>(Src), SrcTy); |
| 1757 | } else { |
| 1758 | std::string NewName(makeNameUnique(Src->getName())); |
| 1759 | Src = new FPToUIInst(Src, SrcTy, NewName, CurBB); |
| 1760 | } |
| 1761 | } else if (isa<IntegerType>(DstTy) && |
| 1762 | cast<IntegerType>(DstTy)->getBitWidth() == 1) { |
| 1763 | // cast type %x to bool was previously defined as setne type %x, null |
| 1764 | // The cast semantic is now to truncate, not compare so we must retain |
| 1765 | // the original intent by replacing the cast with a setne |
| 1766 | Constant* Null = Constant::getNullValue(SrcTy); |
| 1767 | Instruction::OtherOps Opcode = Instruction::ICmp; |
| 1768 | unsigned short predicate = ICmpInst::ICMP_NE; |
| 1769 | if (SrcTy->isFloatingPoint()) { |
| 1770 | Opcode = Instruction::FCmp; |
| 1771 | predicate = FCmpInst::FCMP_ONE; |
| 1772 | } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) { |
| 1773 | error("Invalid cast to bool"); |
| 1774 | } |
| 1775 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1776 | return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null); |
| 1777 | else |
| 1778 | return CmpInst::create(Opcode, predicate, Src, Null); |
| 1779 | } |
| 1780 | // Determine the opcode to use by calling CastInst::getCastOpcode |
| 1781 | Opcode = |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1782 | CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy, |
| 1783 | DstSign.isSigned()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1784 | |
| 1785 | } else switch (op) { |
| 1786 | default: assert(0 && "Invalid cast token"); |
| 1787 | case TruncOp: Opcode = Instruction::Trunc; break; |
| 1788 | case ZExtOp: Opcode = Instruction::ZExt; break; |
| 1789 | case SExtOp: Opcode = Instruction::SExt; break; |
| 1790 | case FPTruncOp: Opcode = Instruction::FPTrunc; break; |
| 1791 | case FPExtOp: Opcode = Instruction::FPExt; break; |
| 1792 | case FPToUIOp: Opcode = Instruction::FPToUI; break; |
| 1793 | case FPToSIOp: Opcode = Instruction::FPToSI; break; |
| 1794 | case UIToFPOp: Opcode = Instruction::UIToFP; break; |
| 1795 | case SIToFPOp: Opcode = Instruction::SIToFP; break; |
| 1796 | case PtrToIntOp: Opcode = Instruction::PtrToInt; break; |
| 1797 | case IntToPtrOp: Opcode = Instruction::IntToPtr; break; |
| 1798 | case BitCastOp: Opcode = Instruction::BitCast; break; |
| 1799 | } |
| 1800 | |
| 1801 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1802 | return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy); |
| 1803 | return CastInst::create(Opcode, Src, DstTy); |
| 1804 | } |
| 1805 | |
| 1806 | static Instruction * |
| 1807 | upgradeIntrinsicCall(const Type* RetTy, const ValID &ID, |
| 1808 | std::vector<Value*>& Args) { |
| 1809 | |
| 1810 | std::string Name = ID.Type == ValID::NameVal ? ID.Name : ""; |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 1811 | switch (Name[5]) { |
| 1812 | case 'i': |
| 1813 | if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") { |
| 1814 | if (Args.size() != 2) |
| 1815 | error("Invalid prototype for " + Name); |
| 1816 | return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]); |
| 1817 | } |
| 1818 | break; |
| 1819 | case 'b': |
| 1820 | if (Name.length() == 14 && !memcmp(&Name[5], "bswap.i", 7)) { |
| 1821 | const Type* ArgTy = Args[0]->getType(); |
| 1822 | Name += ".i" + utostr(cast<IntegerType>(ArgTy)->getBitWidth()); |
| 1823 | Function *F = cast<Function>( |
| 1824 | CurModule.CurrentModule->getOrInsertFunction(Name, RetTy, ArgTy, |
| 1825 | (void*)0)); |
| 1826 | return new CallInst(F, Args[0]); |
| 1827 | } |
| 1828 | break; |
| 1829 | case 'v' : { |
| 1830 | const Type* PtrTy = PointerType::get(Type::Int8Ty); |
| 1831 | std::vector<const Type*> Params; |
| 1832 | if (Name == "llvm.va_start" || Name == "llvm.va_end") { |
| 1833 | if (Args.size() != 1) |
| 1834 | error("Invalid prototype for " + Name + " prototype"); |
| 1835 | Params.push_back(PtrTy); |
| 1836 | const FunctionType *FTy = |
| 1837 | FunctionType::get(Type::VoidTy, Params, false); |
| 1838 | const PointerType *PFTy = PointerType::get(FTy); |
| 1839 | Value* Func = getVal(PFTy, ID); |
| 1840 | Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB); |
| 1841 | return new CallInst(Func, &Args[0], Args.size()); |
| 1842 | } else if (Name == "llvm.va_copy") { |
| 1843 | if (Args.size() != 2) |
| 1844 | error("Invalid prototype for " + Name + " prototype"); |
| 1845 | Params.push_back(PtrTy); |
| 1846 | Params.push_back(PtrTy); |
| 1847 | const FunctionType *FTy = |
| 1848 | FunctionType::get(Type::VoidTy, Params, false); |
| 1849 | const PointerType *PFTy = PointerType::get(FTy); |
| 1850 | Value* Func = getVal(PFTy, ID); |
| 1851 | std::string InstName0(makeNameUnique("va0")); |
| 1852 | std::string InstName1(makeNameUnique("va1")); |
| 1853 | Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB); |
| 1854 | Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB); |
| 1855 | return new CallInst(Func, &Args[0], Args.size()); |
| 1856 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1857 | } |
| 1858 | } |
| 1859 | return 0; |
| 1860 | } |
| 1861 | |
| 1862 | const Type* upgradeGEPIndices(const Type* PTy, |
| 1863 | std::vector<ValueInfo> *Indices, |
| 1864 | std::vector<Value*> &VIndices, |
| 1865 | std::vector<Constant*> *CIndices = 0) { |
| 1866 | // Traverse the indices with a gep_type_iterator so we can build the list |
| 1867 | // of constant and value indices for use later. Also perform upgrades |
| 1868 | VIndices.clear(); |
| 1869 | if (CIndices) CIndices->clear(); |
| 1870 | for (unsigned i = 0, e = Indices->size(); i != e; ++i) |
| 1871 | VIndices.push_back((*Indices)[i].V); |
| 1872 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
| 1873 | GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()), |
| 1874 | GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end()); |
| 1875 | for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) { |
| 1876 | Value *Index = VIndices[i]; |
| 1877 | if (CIndices && !isa<Constant>(Index)) |
| 1878 | error("Indices to constant getelementptr must be constants"); |
| 1879 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1880 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1881 | else if (isa<StructType>(*GTI)) { // Only change struct indices |
| 1882 | if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index)) |
| 1883 | if (CUI->getType()->getBitWidth() == 8) |
| 1884 | Index = |
| 1885 | ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty); |
| 1886 | } else { |
| 1887 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1888 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1889 | // all indices for SequentialType elements. We must retain the same |
| 1890 | // semantic (zext) for unsigned types. |
| 1891 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1892 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1893 | if (CIndices) |
| 1894 | Index = ConstantExpr::getCast(Instruction::ZExt, |
| 1895 | cast<Constant>(Index), Type::Int64Ty); |
| 1896 | else |
| 1897 | Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty, |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1898 | makeNameUnique("gep"), CurBB); |
Reid Spencer | 38f682b | 2007-01-26 20:31:18 +0000 | [diff] [blame] | 1899 | VIndices[i] = Index; |
| 1900 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1901 | } |
| 1902 | // Add to the CIndices list, if requested. |
| 1903 | if (CIndices) |
| 1904 | CIndices->push_back(cast<Constant>(Index)); |
| 1905 | } |
| 1906 | |
| 1907 | const Type *IdxTy = |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 1908 | GetElementPtrInst::getIndexedType(PTy, &VIndices[0], VIndices.size(), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1909 | if (!IdxTy) |
| 1910 | error("Index list invalid for constant getelementptr"); |
| 1911 | return IdxTy; |
| 1912 | } |
| 1913 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 1914 | unsigned upgradeCallingConv(unsigned CC) { |
| 1915 | switch (CC) { |
| 1916 | case OldCallingConv::C : return CallingConv::C; |
| 1917 | case OldCallingConv::CSRet : return CallingConv::C; |
| 1918 | case OldCallingConv::Fast : return CallingConv::Fast; |
| 1919 | case OldCallingConv::Cold : return CallingConv::Cold; |
| 1920 | case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall; |
| 1921 | case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall; |
| 1922 | default: |
| 1923 | return CC; |
| 1924 | } |
| 1925 | } |
| 1926 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1927 | Module* UpgradeAssembly(const std::string &infile, std::istream& in, |
| 1928 | bool debug, bool addAttrs) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1929 | { |
| 1930 | Upgradelineno = 1; |
| 1931 | CurFilename = infile; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 1932 | LexInput = ∈ |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1933 | yydebug = debug; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 1934 | AddAttributes = addAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1935 | ObsoleteVarArgs = false; |
| 1936 | NewVarArgs = false; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1937 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1938 | CurModule.CurrentModule = new Module(CurFilename); |
| 1939 | |
| 1940 | // Check to make sure the parser succeeded |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1941 | if (yyparse()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1942 | if (ParserResult) |
| 1943 | delete ParserResult; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1944 | std::cerr << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1945 | return 0; |
| 1946 | } |
| 1947 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1948 | // Check to make sure that parsing produced a result |
| 1949 | if (!ParserResult) { |
| 1950 | std::cerr << "llvm-upgrade: no parse result.\n"; |
| 1951 | return 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1952 | } |
| 1953 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1954 | // Reset ParserResult variable while saving its value for the result. |
| 1955 | Module *Result = ParserResult; |
| 1956 | ParserResult = 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1957 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1958 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1959 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1960 | Function* F; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1961 | if ((F = Result->getFunction("llvm.va_start")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1962 | && F->getFunctionType()->getNumParams() == 0) |
| 1963 | ObsoleteVarArgs = true; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1964 | if((F = Result->getFunction("llvm.va_copy")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1965 | && F->getFunctionType()->getNumParams() == 1) |
| 1966 | ObsoleteVarArgs = true; |
Reid Spencer | 280d801 | 2006-12-01 23:40:53 +0000 | [diff] [blame] | 1967 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1968 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1969 | if (ObsoleteVarArgs && NewVarArgs) { |
| 1970 | error("This file is corrupt: it uses both new and old style varargs"); |
| 1971 | return 0; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1972 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1973 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1974 | if(ObsoleteVarArgs) { |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1975 | if(Function* F = Result->getFunction("llvm.va_start")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1976 | if (F->arg_size() != 0) { |
| 1977 | error("Obsolete va_start takes 0 argument"); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1978 | return 0; |
| 1979 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1980 | |
| 1981 | //foo = va_start() |
| 1982 | // -> |
| 1983 | //bar = alloca typeof(foo) |
| 1984 | //va_start(bar) |
| 1985 | //foo = load bar |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1986 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1987 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1988 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1989 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1990 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 1991 | "llvm.va_start", RetTy, ArgTyPtr, (Type *)0)); |
| 1992 | |
| 1993 | while (!F->use_empty()) { |
| 1994 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1995 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 1996 | new CallInst(NF, bar, "", CI); |
| 1997 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 1998 | CI->replaceAllUsesWith(foo); |
| 1999 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2000 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2001 | Result->getFunctionList().erase(F); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2002 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2003 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2004 | if(Function* F = Result->getFunction("llvm.va_end")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2005 | if(F->arg_size() != 1) { |
| 2006 | error("Obsolete va_end takes 1 argument"); |
| 2007 | return 0; |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2008 | } |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2009 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2010 | //vaend foo |
| 2011 | // -> |
| 2012 | //bar = alloca 1 of typeof(foo) |
| 2013 | //vaend bar |
| 2014 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2015 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 2016 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2017 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2018 | "llvm.va_end", RetTy, ArgTyPtr, (Type *)0)); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2019 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2020 | while (!F->use_empty()) { |
| 2021 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2022 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 2023 | new StoreInst(CI->getOperand(1), bar, CI); |
| 2024 | new CallInst(NF, bar, "", CI); |
| 2025 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2026 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2027 | Result->getFunctionList().erase(F); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2028 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2029 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2030 | if(Function* F = Result->getFunction("llvm.va_copy")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2031 | if(F->arg_size() != 1) { |
| 2032 | error("Obsolete va_copy takes 1 argument"); |
| 2033 | return 0; |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2034 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2035 | //foo = vacopy(bar) |
| 2036 | // -> |
| 2037 | //a = alloca 1 of typeof(foo) |
| 2038 | //b = alloca 1 of typeof(foo) |
| 2039 | //store bar -> b |
| 2040 | //vacopy(a, b) |
| 2041 | //foo = load a |
| 2042 | |
| 2043 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2044 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2045 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2046 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2047 | "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0)); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +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* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); |
| 2052 | AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); |
| 2053 | new StoreInst(CI->getOperand(1), b, CI); |
| 2054 | new CallInst(NF, a, b, "", CI); |
| 2055 | Value* foo = new LoadInst(a, "vacopy.fix.3", CI); |
| 2056 | CI->replaceAllUsesWith(foo); |
| 2057 | CI->getParent()->getInstList().erase(CI); |
| 2058 | } |
| 2059 | Result->getFunctionList().erase(F); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2060 | } |
| 2061 | } |
| 2062 | |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 2063 | return Result; |
| 2064 | } |
| 2065 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2066 | } // end llvm namespace |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2067 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2068 | using namespace llvm; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2069 | |
| 2070 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2071 | |
| 2072 | /* Enabling traces. */ |
| 2073 | #ifndef YYDEBUG |
| 2074 | # define YYDEBUG 0 |
| 2075 | #endif |
| 2076 | |
| 2077 | /* Enabling verbose error messages. */ |
| 2078 | #ifdef YYERROR_VERBOSE |
| 2079 | # undef YYERROR_VERBOSE |
| 2080 | # define YYERROR_VERBOSE 1 |
| 2081 | #else |
| 2082 | # define YYERROR_VERBOSE 0 |
| 2083 | #endif |
| 2084 | |
| 2085 | /* Enabling the token table. */ |
| 2086 | #ifndef YYTOKEN_TABLE |
| 2087 | # define YYTOKEN_TABLE 0 |
| 2088 | #endif |
| 2089 | |
| 2090 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 2091 | #line 1712 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2092 | typedef union YYSTYPE { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2093 | llvm::Module *ModuleVal; |
| 2094 | llvm::Function *FunctionVal; |
| 2095 | std::pair<llvm::PATypeInfo, char*> *ArgVal; |
| 2096 | llvm::BasicBlock *BasicBlockVal; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 2097 | llvm::TermInstInfo TermInstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2098 | llvm::InstrInfo InstVal; |
| 2099 | llvm::ConstInfo ConstVal; |
| 2100 | llvm::ValueInfo ValueVal; |
| 2101 | llvm::PATypeInfo TypeVal; |
| 2102 | llvm::TypeInfo PrimType; |
| 2103 | llvm::PHIListInfo PHIList; |
| 2104 | std::list<llvm::PATypeInfo> *TypeList; |
| 2105 | std::vector<llvm::ValueInfo> *ValueList; |
| 2106 | std::vector<llvm::ConstInfo> *ConstVector; |
| 2107 | |
| 2108 | |
| 2109 | std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList; |
| 2110 | // Represent the RHS of PHI node |
| 2111 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 2112 | |
| 2113 | llvm::GlobalValue::LinkageTypes Linkage; |
| 2114 | int64_t SInt64Val; |
| 2115 | uint64_t UInt64Val; |
| 2116 | int SIntVal; |
| 2117 | unsigned UIntVal; |
| 2118 | double FPVal; |
| 2119 | bool BoolVal; |
| 2120 | |
| 2121 | char *StrVal; // This memory is strdup'd! |
| 2122 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 2123 | |
| 2124 | llvm::BinaryOps BinaryOpVal; |
| 2125 | llvm::TermOps TermOpVal; |
| 2126 | llvm::MemoryOps MemOpVal; |
| 2127 | llvm::OtherOps OtherOpVal; |
| 2128 | llvm::CastOps CastOpVal; |
| 2129 | llvm::ICmpInst::Predicate IPred; |
| 2130 | llvm::FCmpInst::Predicate FPred; |
| 2131 | llvm::Module::Endianness Endianness; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2132 | } YYSTYPE; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2133 | /* Line 196 of yacc.c. */ |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 2134 | #line 2135 "UpgradeParser.tab.c" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2135 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 2136 | # define YYSTYPE_IS_DECLARED 1 |
| 2137 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2138 | #endif |
| 2139 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2140 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2141 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2142 | /* Copy the second part of user declarations. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2143 | |
| 2144 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2145 | /* Line 219 of yacc.c. */ |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 2146 | #line 2147 "UpgradeParser.tab.c" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2147 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2148 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 2149 | # define YYSIZE_T __SIZE_TYPE__ |
| 2150 | #endif |
| 2151 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 2152 | # define YYSIZE_T size_t |
| 2153 | #endif |
| 2154 | #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) |
| 2155 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 2156 | # define YYSIZE_T size_t |
| 2157 | #endif |
| 2158 | #if ! defined (YYSIZE_T) |
| 2159 | # define YYSIZE_T unsigned int |
| 2160 | #endif |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2161 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2162 | #ifndef YY_ |
| 2163 | # if YYENABLE_NLS |
| 2164 | # if ENABLE_NLS |
| 2165 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 2166 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 2167 | # endif |
| 2168 | # endif |
| 2169 | # ifndef YY_ |
| 2170 | # define YY_(msgid) msgid |
| 2171 | # endif |
| 2172 | #endif |
| 2173 | |
| 2174 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 2175 | |
| 2176 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 2177 | |
| 2178 | # ifdef YYSTACK_USE_ALLOCA |
| 2179 | # if YYSTACK_USE_ALLOCA |
| 2180 | # ifdef __GNUC__ |
| 2181 | # define YYSTACK_ALLOC __builtin_alloca |
| 2182 | # else |
| 2183 | # define YYSTACK_ALLOC alloca |
| 2184 | # if defined (__STDC__) || defined (__cplusplus) |
| 2185 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 2186 | # define YYINCLUDED_STDLIB_H |
| 2187 | # endif |
| 2188 | # endif |
| 2189 | # endif |
| 2190 | # endif |
| 2191 | |
| 2192 | # ifdef YYSTACK_ALLOC |
| 2193 | /* Pacify GCC's `empty if-body' warning. */ |
| 2194 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 2195 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 2196 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 2197 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 2198 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 2199 | to allow for a few compiler-allocated temporary stack slots. */ |
| 2200 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ |
| 2201 | # endif |
| 2202 | # else |
| 2203 | # define YYSTACK_ALLOC YYMALLOC |
| 2204 | # define YYSTACK_FREE YYFREE |
| 2205 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 2206 | # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) |
| 2207 | # endif |
| 2208 | # ifdef __cplusplus |
| 2209 | extern "C" { |
| 2210 | # endif |
| 2211 | # ifndef YYMALLOC |
| 2212 | # define YYMALLOC malloc |
| 2213 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 2214 | && (defined (__STDC__) || defined (__cplusplus))) |
| 2215 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 2216 | # endif |
| 2217 | # endif |
| 2218 | # ifndef YYFREE |
| 2219 | # define YYFREE free |
| 2220 | # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 2221 | && (defined (__STDC__) || defined (__cplusplus))) |
| 2222 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 2223 | # endif |
| 2224 | # endif |
| 2225 | # ifdef __cplusplus |
| 2226 | } |
| 2227 | # endif |
| 2228 | # endif |
| 2229 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 2230 | |
| 2231 | |
| 2232 | #if (! defined (yyoverflow) \ |
| 2233 | && (! defined (__cplusplus) \ |
| 2234 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 2235 | |
| 2236 | /* A type that is properly aligned for any stack member. */ |
| 2237 | union yyalloc |
| 2238 | { |
| 2239 | short int yyss; |
| 2240 | YYSTYPE yyvs; |
| 2241 | }; |
| 2242 | |
| 2243 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 2244 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 2245 | |
| 2246 | /* The size of an array large to enough to hold all stacks, each with |
| 2247 | N elements. */ |
| 2248 | # define YYSTACK_BYTES(N) \ |
| 2249 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
| 2250 | + YYSTACK_GAP_MAXIMUM) |
| 2251 | |
| 2252 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 2253 | not overlap. */ |
| 2254 | # ifndef YYCOPY |
| 2255 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 2256 | # define YYCOPY(To, From, Count) \ |
| 2257 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 2258 | # else |
| 2259 | # define YYCOPY(To, From, Count) \ |
| 2260 | do \ |
| 2261 | { \ |
| 2262 | YYSIZE_T yyi; \ |
| 2263 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 2264 | (To)[yyi] = (From)[yyi]; \ |
| 2265 | } \ |
| 2266 | while (0) |
| 2267 | # endif |
| 2268 | # endif |
| 2269 | |
| 2270 | /* Relocate STACK from its old location to the new one. The |
| 2271 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 2272 | elements in the stack, and YYPTR gives the new location of the |
| 2273 | stack. Advance YYPTR to a properly aligned location for the next |
| 2274 | stack. */ |
| 2275 | # define YYSTACK_RELOCATE(Stack) \ |
| 2276 | do \ |
| 2277 | { \ |
| 2278 | YYSIZE_T yynewbytes; \ |
| 2279 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 2280 | Stack = &yyptr->Stack; \ |
| 2281 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 2282 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 2283 | } \ |
| 2284 | while (0) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2285 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2286 | #endif |
| 2287 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2288 | #if defined (__STDC__) || defined (__cplusplus) |
| 2289 | typedef signed char yysigned_char; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2290 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2291 | typedef short int yysigned_char; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2292 | #endif |
| 2293 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2294 | /* YYFINAL -- State number of the termination state. */ |
| 2295 | #define YYFINAL 4 |
| 2296 | /* YYLAST -- Last index in YYTABLE. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2297 | #define YYLAST 1630 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2298 | |
| 2299 | /* YYNTOKENS -- Number of terminals. */ |
| 2300 | #define YYNTOKENS 166 |
| 2301 | /* YYNNTS -- Number of nonterminals. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2302 | #define YYNNTS 81 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2303 | /* YYNRULES -- Number of rules. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2304 | #define YYNRULES 310 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2305 | /* YYNRULES -- Number of states. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2306 | #define YYNSTATES 606 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2307 | |
| 2308 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 2309 | #define YYUNDEFTOK 2 |
| 2310 | #define YYMAXUTOK 406 |
| 2311 | |
| 2312 | #define YYTRANSLATE(YYX) \ |
| 2313 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 2314 | |
| 2315 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 2316 | static const unsigned char yytranslate[] = |
| 2317 | { |
| 2318 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2319 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2320 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2321 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2322 | 155, 156, 164, 2, 153, 2, 2, 2, 2, 2, |
| 2323 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2324 | 160, 152, 161, 2, 2, 2, 2, 2, 2, 2, |
| 2325 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2326 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2327 | 2, 157, 154, 159, 2, 2, 2, 2, 2, 165, |
| 2328 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2329 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2330 | 158, 2, 2, 162, 2, 163, 2, 2, 2, 2, |
| 2331 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2332 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2333 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2334 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2335 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2336 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2337 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2338 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2339 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2340 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2341 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2342 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2343 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 2344 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 2345 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 2346 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 2347 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 2348 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 2349 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 2350 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 2351 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2352 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2353 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2354 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 2355 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2356 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
| 2357 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 2358 | 145, 146, 147, 148, 149, 150, 151 |
| 2359 | }; |
| 2360 | |
| 2361 | #if YYDEBUG |
| 2362 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 2363 | YYRHS. */ |
| 2364 | static const unsigned short int yyprhs[] = |
| 2365 | { |
| 2366 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 2367 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 2368 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 2369 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 2370 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 2371 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 2372 | 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, |
| 2373 | 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, |
| 2374 | 159, 161, 164, 165, 167, 169, 171, 173, 175, 177, |
| 2375 | 179, 180, 181, 183, 185, 187, 189, 191, 193, 196, |
| 2376 | 197, 200, 201, 205, 208, 209, 211, 212, 216, 218, |
| 2377 | 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, |
| 2378 | 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, |
| 2379 | 261, 264, 269, 275, 281, 285, 288, 294, 299, 302, |
| 2380 | 304, 308, 310, 314, 316, 317, 322, 326, 330, 335, |
| 2381 | 340, 344, 351, 357, 360, 363, 366, 369, 372, 375, |
| 2382 | 378, 381, 384, 387, 394, 400, 409, 416, 423, 430, |
| 2383 | 438, 446, 453, 460, 469, 478, 482, 484, 486, 488, |
| 2384 | 490, 493, 496, 501, 504, 506, 511, 514, 519, 520, |
| 2385 | 528, 529, 537, 538, 546, 547, 555, 559, 564, 565, |
| 2386 | 567, 569, 571, 575, 579, 583, 587, 591, 595, 597, |
| 2387 | 598, 600, 602, 604, 605, 608, 612, 614, 616, 620, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2388 | 622, 623, 632, 634, 636, 637, 642, 644, 646, 649, |
| 2389 | 650, 652, 654, 655, 656, 662, 663, 665, 667, 669, |
| 2390 | 671, 673, 675, 677, 679, 681, 685, 687, 693, 695, |
| 2391 | 697, 699, 701, 704, 707, 710, 714, 717, 718, 720, |
| 2392 | 722, 724, 727, 730, 734, 744, 754, 763, 777, 779, |
| 2393 | 781, 788, 794, 797, 804, 812, 814, 818, 820, 821, |
| 2394 | 824, 826, 832, 838, 844, 851, 858, 861, 866, 871, |
| 2395 | 878, 883, 888, 893, 898, 905, 912, 915, 923, 925, |
| 2396 | 928, 929, 931, 932, 936, 943, 947, 954, 957, 962, |
| 2397 | 969 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2398 | }; |
| 2399 | |
| 2400 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 2401 | static const short int yyrhs[] = |
| 2402 | { |
| 2403 | 200, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
| 2404 | -1, 79, -1, 80, -1, 81, -1, 82, -1, 83, |
| 2405 | -1, 84, -1, 85, -1, 86, -1, 87, -1, 88, |
| 2406 | -1, 89, -1, 90, -1, 91, -1, 92, -1, 97, |
| 2407 | -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, |
| 2408 | -1, 119, -1, 120, -1, 121, -1, 122, -1, 123, |
| 2409 | -1, 124, -1, 125, -1, 126, -1, 127, -1, 128, |
| 2410 | -1, 129, -1, 130, -1, 131, -1, 132, -1, 133, |
| 2411 | -1, 134, -1, 135, -1, 136, -1, 137, -1, 138, |
| 2412 | -1, 125, -1, 126, -1, 127, -1, 128, -1, 27, |
| 2413 | -1, 28, -1, 93, -1, 94, -1, 95, -1, 96, |
| 2414 | -1, 140, -1, 141, -1, 142, -1, 143, -1, 144, |
| 2415 | -1, 145, -1, 146, -1, 147, -1, 148, -1, 149, |
| 2416 | -1, 150, -1, 151, -1, 139, -1, 16, -1, 14, |
| 2417 | -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, |
| 2418 | -1, 11, -1, 176, -1, 177, -1, 18, -1, 19, |
| 2419 | -1, 212, 152, -1, -1, 41, -1, 42, -1, 43, |
| 2420 | -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, |
| 2421 | -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, |
| 2422 | -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, |
| 2423 | -1, 153, 57, 4, -1, 34, 24, -1, -1, 185, |
| 2424 | -1, -1, 153, 188, 187, -1, 185, -1, 57, 4, |
| 2425 | -1, 191, -1, 8, -1, 193, -1, 8, -1, 193, |
| 2426 | -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, |
| 2427 | -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2428 | -1, 19, -1, 21, -1, 192, -1, 48, -1, 229, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2429 | -1, 154, 4, -1, 190, 155, 195, 156, -1, 157, |
| 2430 | 4, 158, 193, 159, -1, 160, 4, 158, 193, 161, |
| 2431 | -1, 162, 194, 163, -1, 162, 163, -1, 160, 162, |
| 2432 | 194, 163, 161, -1, 160, 162, 163, 161, -1, 193, |
| 2433 | 164, -1, 193, -1, 194, 153, 193, -1, 194, -1, |
| 2434 | 194, 153, 37, -1, 37, -1, -1, 191, 157, 198, |
| 2435 | 159, -1, 191, 157, 159, -1, 191, 165, 24, -1, |
| 2436 | 191, 160, 198, 161, -1, 191, 162, 198, 163, -1, |
| 2437 | 191, 162, 163, -1, 191, 160, 162, 198, 163, 161, |
| 2438 | -1, 191, 160, 162, 163, 161, -1, 191, 38, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2439 | 191, 39, -1, 191, 229, -1, 191, 197, -1, 191, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2440 | 26, -1, 176, 168, -1, 177, 4, -1, 9, 27, |
| 2441 | -1, 9, 28, -1, 179, 7, -1, 175, 155, 196, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2442 | 36, 191, 156, -1, 110, 155, 196, 244, 156, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2443 | 112, 155, 196, 153, 196, 153, 196, 156, -1, 169, |
| 2444 | 155, 196, 153, 196, 156, -1, 170, 155, 196, 153, |
| 2445 | 196, 156, -1, 171, 155, 196, 153, 196, 156, -1, |
| 2446 | 103, 172, 155, 196, 153, 196, 156, -1, 104, 173, |
| 2447 | 155, 196, 153, 196, 156, -1, 174, 155, 196, 153, |
| 2448 | 196, 156, -1, 114, 155, 196, 153, 196, 156, -1, |
| 2449 | 115, 155, 196, 153, 196, 153, 196, 156, -1, 116, |
| 2450 | 155, 196, 153, 196, 153, 196, 156, -1, 198, 153, |
| 2451 | 196, -1, 196, -1, 32, -1, 33, -1, 201, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2452 | 201, 222, -1, 201, 224, -1, 201, 62, 61, 207, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2453 | -1, 201, 25, -1, 202, -1, 202, 180, 20, 189, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2454 | -1, 202, 224, -1, 202, 62, 61, 207, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2455 | 202, 180, 181, 199, 196, 203, 187, -1, -1, 202, |
| 2456 | 180, 50, 199, 191, 204, 187, -1, -1, 202, 180, |
| 2457 | 45, 199, 191, 205, 187, -1, -1, 202, 180, 47, |
| 2458 | 199, 191, 206, 187, -1, 202, 51, 209, -1, 202, |
| 2459 | 58, 152, 210, -1, -1, 24, -1, 56, -1, 55, |
| 2460 | -1, 53, 152, 208, -1, 54, 152, 4, -1, 52, |
| 2461 | 152, 24, -1, 71, 152, 24, -1, 157, 211, 159, |
| 2462 | -1, 211, 153, 24, -1, 24, -1, -1, 22, -1, |
| 2463 | 24, -1, 212, -1, -1, 191, 213, -1, 215, 153, |
| 2464 | 214, -1, 214, -1, 215, -1, 215, 153, 37, -1, |
| 2465 | 37, -1, -1, 182, 189, 212, 155, 216, 156, 186, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2466 | 183, -1, 29, -1, 162, -1, -1, 181, 220, 217, |
| 2467 | 218, -1, 30, -1, 163, -1, 232, 221, -1, -1, |
| 2468 | 45, -1, 47, -1, -1, -1, 31, 225, 223, 226, |
| 2469 | 217, -1, -1, 63, -1, 3, -1, 4, -1, 7, |
| 2470 | -1, 27, -1, 28, -1, 38, -1, 39, -1, 26, |
| 2471 | -1, 160, 198, 161, -1, 197, -1, 61, 227, 24, |
| 2472 | 153, 24, -1, 167, -1, 212, -1, 229, -1, 228, |
| 2473 | -1, 191, 230, -1, 232, 233, -1, 219, 233, -1, |
| 2474 | 234, 180, 236, -1, 234, 238, -1, -1, 23, -1, |
| 2475 | 77, -1, 78, -1, 72, 231, -1, 72, 8, -1, |
| 2476 | 73, 21, 230, -1, 73, 9, 230, 153, 21, 230, |
| 2477 | 153, 21, 230, -1, 74, 178, 230, 153, 21, 230, |
| 2478 | 157, 237, 159, -1, 74, 178, 230, 153, 21, 230, |
| 2479 | 157, 159, -1, 75, 182, 189, 230, 155, 241, 156, |
| 2480 | 36, 21, 230, 235, 21, 230, -1, 235, -1, 76, |
| 2481 | -1, 237, 178, 228, 153, 21, 230, -1, 178, 228, |
| 2482 | 153, 21, 230, -1, 180, 243, -1, 191, 157, 230, |
| 2483 | 153, 230, 159, -1, 239, 153, 157, 230, 153, 230, |
| 2484 | 159, -1, 231, -1, 240, 153, 231, -1, 240, -1, |
| 2485 | -1, 60, 59, -1, 59, -1, 169, 191, 230, 153, |
| 2486 | 230, -1, 170, 191, 230, 153, 230, -1, 171, 191, |
| 2487 | 230, 153, 230, -1, 103, 172, 191, 230, 153, 230, |
| 2488 | -1, 104, 173, 191, 230, 153, 230, -1, 49, 231, |
| 2489 | -1, 174, 231, 153, 231, -1, 175, 231, 36, 191, |
| 2490 | -1, 112, 231, 153, 231, 153, 231, -1, 113, 231, |
| 2491 | 153, 191, -1, 117, 231, 153, 191, -1, 118, 231, |
| 2492 | 153, 191, -1, 114, 231, 153, 231, -1, 115, 231, |
| 2493 | 153, 231, 153, 231, -1, 116, 231, 153, 231, 153, |
| 2494 | 231, -1, 111, 239, -1, 242, 182, 189, 230, 155, |
| 2495 | 241, 156, -1, 246, -1, 153, 240, -1, -1, 35, |
| 2496 | -1, -1, 105, 191, 184, -1, 105, 191, 153, 15, |
| 2497 | 230, 184, -1, 106, 191, 184, -1, 106, 191, 153, |
| 2498 | 15, 230, 184, -1, 107, 231, -1, 245, 108, 191, |
| 2499 | 230, -1, 245, 109, 231, 153, 191, 230, -1, 110, |
| 2500 | 191, 230, 244, -1 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2501 | }; |
| 2502 | |
| 2503 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 2504 | static const unsigned short int yyrline[] = |
| 2505 | { |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 2506 | 0, 1852, 1852, 1853, 1861, 1862, 1872, 1872, 1872, 1872, |
| 2507 | 1872, 1872, 1872, 1872, 1872, 1872, 1872, 1876, 1876, 1876, |
| 2508 | 1880, 1880, 1880, 1880, 1880, 1880, 1884, 1884, 1885, 1885, |
| 2509 | 1886, 1886, 1887, 1887, 1888, 1888, 1892, 1892, 1893, 1893, |
| 2510 | 1894, 1894, 1895, 1895, 1896, 1896, 1897, 1897, 1898, 1898, |
| 2511 | 1899, 1900, 1903, 1903, 1903, 1903, 1907, 1907, 1907, 1907, |
| 2512 | 1907, 1907, 1907, 1908, 1908, 1908, 1908, 1908, 1908, 1914, |
| 2513 | 1914, 1914, 1914, 1918, 1918, 1918, 1918, 1922, 1922, 1926, |
| 2514 | 1926, 1931, 1934, 1939, 1940, 1941, 1942, 1943, 1944, 1945, |
| 2515 | 1946, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1967, |
| 2516 | 1968, 1976, 1977, 1985, 1994, 1995, 2002, 2003, 2007, 2011, |
| 2517 | 2027, 2028, 2035, 2036, 2043, 2051, 2051, 2051, 2051, 2051, |
| 2518 | 2051, 2051, 2052, 2052, 2052, 2052, 2052, 2057, 2061, 2065, |
| 2519 | 2070, 2079, 2097, 2103, 2116, 2127, 2131, 2144, 2148, 2162, |
| 2520 | 2166, 2173, 2174, 2180, 2187, 2199, 2229, 2242, 2265, 2293, |
| 2521 | 2315, 2326, 2348, 2359, 2368, 2373, 2432, 2439, 2447, 2454, |
| 2522 | 2461, 2465, 2469, 2478, 2493, 2506, 2515, 2543, 2556, 2565, |
| 2523 | 2571, 2577, 2588, 2594, 2600, 2611, 2612, 2621, 2622, 2634, |
| 2524 | 2643, 2644, 2645, 2646, 2647, 2663, 2683, 2685, 2687, 2687, |
| 2525 | 2694, 2694, 2702, 2702, 2710, 2710, 2719, 2721, 2723, 2728, |
| 2526 | 2742, 2743, 2747, 2750, 2758, 2762, 2769, 2773, 2777, 2781, |
| 2527 | 2789, 2789, 2793, 2794, 2798, 2806, 2811, 2819, 2820, 2827, |
| 2528 | 2834, 2838, 3019, 3019, 3023, 3023, 3033, 3033, 3037, 3042, |
| 2529 | 3043, 3044, 3048, 3049, 3048, 3061, 3062, 3067, 3068, 3069, |
| 2530 | 3070, 3074, 3078, 3079, 3080, 3081, 3102, 3106, 3120, 3121, |
| 2531 | 3126, 3126, 3134, 3144, 3147, 3156, 3167, 3172, 3181, 3192, |
| 2532 | 3192, 3195, 3199, 3203, 3208, 3218, 3236, 3245, 3310, 3314, |
| 2533 | 3321, 3333, 3348, 3378, 3388, 3398, 3402, 3409, 3410, 3414, |
| 2534 | 3417, 3423, 3442, 3460, 3476, 3490, 3504, 3515, 3533, 3542, |
| 2535 | 3551, 3558, 3579, 3603, 3609, 3615, 3621, 3637, 3721, 3729, |
| 2536 | 3730, 3734, 3735, 3739, 3745, 3752, 3758, 3765, 3772, 3785, |
| 2537 | 3811 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2538 | }; |
| 2539 | #endif |
| 2540 | |
| 2541 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 2542 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 2543 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 2544 | static const char *const yytname[] = |
| 2545 | { |
| 2546 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 2547 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 2548 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 2549 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 2550 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 2551 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 2552 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 2553 | "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 2554 | "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", |
| 2555 | "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", |
| 2556 | "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", |
| 2557 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 2558 | "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT", |
| 2559 | "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM", |
| 2560 | "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR", |
| 2561 | "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP", |
| 2562 | "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", |
| 2563 | "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", |
| 2564 | "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", |
| 2565 | "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", |
| 2566 | "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", |
| 2567 | "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR", |
| 2568 | "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", |
| 2569 | "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL", |
| 2570 | "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates", |
| 2571 | "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType", |
| 2572 | "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", |
| 2573 | "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes", |
| 2574 | "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", |
| 2575 | "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", |
| 2576 | "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", |
| 2577 | "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition", |
| 2578 | "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal", |
| 2579 | "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2580 | "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7", |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2581 | "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", |
| 2582 | "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", |
| 2583 | "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList", |
| 2584 | "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList", |
| 2585 | "OptVolatile", "MemoryInst", 0 |
| 2586 | }; |
| 2587 | #endif |
| 2588 | |
| 2589 | # ifdef YYPRINT |
| 2590 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 2591 | token YYLEX-NUM. */ |
| 2592 | static const unsigned short int yytoknum[] = |
| 2593 | { |
| 2594 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 2595 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 2596 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 2597 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 2598 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 2599 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 2600 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 2601 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 2602 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 2603 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 2604 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 2605 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 2606 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 2607 | 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, |
| 2608 | 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, |
| 2609 | 405, 406, 61, 44, 92, 40, 41, 91, 120, 93, |
| 2610 | 60, 62, 123, 125, 42, 99 |
| 2611 | }; |
| 2612 | # endif |
| 2613 | |
| 2614 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 2615 | static const unsigned char yyr1[] = |
| 2616 | { |
| 2617 | 0, 166, 167, 167, 168, 168, 169, 169, 169, 169, |
| 2618 | 169, 169, 169, 169, 169, 169, 169, 170, 170, 170, |
| 2619 | 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, |
| 2620 | 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, |
| 2621 | 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, |
| 2622 | 173, 173, 174, 174, 174, 174, 175, 175, 175, 175, |
| 2623 | 175, 175, 175, 175, 175, 175, 175, 175, 175, 176, |
| 2624 | 176, 176, 176, 177, 177, 177, 177, 178, 178, 179, |
| 2625 | 179, 180, 180, 181, 181, 181, 181, 181, 181, 181, |
| 2626 | 181, 182, 182, 182, 182, 182, 182, 182, 182, 183, |
| 2627 | 183, 184, 184, 185, 186, 186, 187, 187, 188, 188, |
| 2628 | 189, 189, 190, 190, 191, 192, 192, 192, 192, 192, |
| 2629 | 192, 192, 192, 192, 192, 192, 192, 193, 193, 193, |
| 2630 | 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, |
| 2631 | 194, 195, 195, 195, 195, 196, 196, 196, 196, 196, |
| 2632 | 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, |
| 2633 | 196, 196, 196, 197, 197, 197, 197, 197, 197, 197, |
| 2634 | 197, 197, 197, 197, 197, 198, 198, 199, 199, 200, |
| 2635 | 201, 201, 201, 201, 201, 202, 202, 202, 203, 202, |
| 2636 | 204, 202, 205, 202, 206, 202, 202, 202, 202, 207, |
| 2637 | 208, 208, 209, 209, 209, 209, 210, 211, 211, 211, |
| 2638 | 212, 212, 213, 213, 214, 215, 215, 216, 216, 216, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2639 | 216, 217, 218, 218, 220, 219, 221, 221, 222, 223, |
| 2640 | 223, 223, 225, 226, 224, 227, 227, 228, 228, 228, |
| 2641 | 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, |
| 2642 | 230, 230, 231, 232, 232, 233, 234, 234, 234, 235, |
| 2643 | 235, 236, 236, 236, 236, 236, 236, 236, 236, 236, |
| 2644 | 237, 237, 238, 239, 239, 240, 240, 241, 241, 242, |
| 2645 | 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, |
| 2646 | 243, 243, 243, 243, 243, 243, 243, 243, 243, 244, |
| 2647 | 244, 245, 245, 246, 246, 246, 246, 246, 246, 246, |
| 2648 | 246 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2649 | }; |
| 2650 | |
| 2651 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 2652 | static const unsigned char yyr2[] = |
| 2653 | { |
| 2654 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2655 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2656 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2657 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2658 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2659 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2660 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2661 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2662 | 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, |
| 2663 | 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, |
| 2664 | 2, 0, 3, 2, 0, 1, 0, 3, 1, 2, |
| 2665 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2666 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2667 | 2, 4, 5, 5, 3, 2, 5, 4, 2, 1, |
| 2668 | 3, 1, 3, 1, 0, 4, 3, 3, 4, 4, |
| 2669 | 3, 6, 5, 2, 2, 2, 2, 2, 2, 2, |
| 2670 | 2, 2, 2, 6, 5, 8, 6, 6, 6, 7, |
| 2671 | 7, 6, 6, 8, 8, 3, 1, 1, 1, 1, |
| 2672 | 2, 2, 4, 2, 1, 4, 2, 4, 0, 7, |
| 2673 | 0, 7, 0, 7, 0, 7, 3, 4, 0, 1, |
| 2674 | 1, 1, 3, 3, 3, 3, 3, 3, 1, 0, |
| 2675 | 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2676 | 0, 8, 1, 1, 0, 4, 1, 1, 2, 0, |
| 2677 | 1, 1, 0, 0, 5, 0, 1, 1, 1, 1, |
| 2678 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 2679 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 1, |
| 2680 | 1, 2, 2, 3, 9, 9, 8, 13, 1, 1, |
| 2681 | 6, 5, 2, 6, 7, 1, 3, 1, 0, 2, |
| 2682 | 1, 5, 5, 5, 6, 6, 2, 4, 4, 6, |
| 2683 | 4, 4, 4, 4, 6, 6, 2, 7, 1, 2, |
| 2684 | 0, 1, 0, 3, 6, 3, 6, 2, 4, 6, |
| 2685 | 4 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2686 | }; |
| 2687 | |
| 2688 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 2689 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 2690 | means the default is an error. */ |
| 2691 | static const unsigned short int yydefact[] = |
| 2692 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2693 | 198, 0, 90, 184, 1, 183, 232, 83, 84, 85, |
| 2694 | 86, 87, 88, 89, 0, 224, 257, 180, 181, 257, |
| 2695 | 210, 211, 0, 0, 0, 90, 0, 186, 229, 0, |
| 2696 | 91, 258, 254, 82, 226, 227, 228, 253, 0, 0, |
| 2697 | 0, 0, 196, 0, 0, 0, 0, 0, 0, 0, |
| 2698 | 81, 230, 231, 233, 199, 182, 0, 92, 93, 94, |
| 2699 | 95, 96, 97, 0, 0, 302, 256, 0, 0, 0, |
| 2700 | 0, 209, 197, 187, 2, 3, 111, 115, 116, 117, |
| 2701 | 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, |
| 2702 | 0, 0, 0, 0, 248, 185, 0, 110, 127, 114, |
| 2703 | 249, 129, 177, 178, 0, 0, 0, 0, 91, 98, |
| 2704 | 0, 222, 223, 225, 301, 0, 280, 0, 0, 0, |
| 2705 | 0, 91, 269, 259, 260, 6, 7, 8, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2706 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 52, |
| 2707 | 53, 54, 55, 20, 21, 22, 23, 24, 25, 0, |
| 2708 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2709 | 0, 0, 0, 68, 56, 57, 58, 59, 60, 61, |
| 2710 | 62, 63, 64, 65, 66, 67, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2711 | 0, 268, 255, 91, 272, 0, 298, 204, 201, 200, |
| 2712 | 202, 203, 205, 208, 0, 130, 0, 0, 0, 113, |
| 2713 | 135, 139, 0, 144, 138, 192, 194, 190, 115, 116, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2714 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2715 | 0, 0, 0, 188, 234, 0, 0, 286, 279, 262, |
| 2716 | 261, 0, 0, 72, 76, 71, 75, 70, 74, 69, |
| 2717 | 73, 77, 78, 0, 0, 26, 27, 28, 29, 30, |
| 2718 | 31, 32, 33, 34, 35, 0, 50, 51, 46, 47, |
| 2719 | 48, 49, 36, 37, 38, 39, 40, 41, 42, 43, |
| 2720 | 44, 45, 0, 101, 101, 307, 0, 0, 296, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2721 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2722 | 0, 0, 0, 0, 0, 206, 0, 0, 0, 0, |
| 2723 | 0, 134, 143, 141, 0, 106, 106, 106, 160, 161, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2724 | 4, 5, 158, 159, 162, 157, 153, 154, 0, 0, |
| 2725 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2726 | 0, 0, 0, 0, 156, 155, 106, 220, 237, 238, |
| 2727 | 239, 244, 240, 241, 242, 243, 235, 0, 246, 251, |
| 2728 | 250, 252, 0, 263, 0, 0, 0, 0, 0, 303, |
| 2729 | 0, 305, 300, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2730 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2731 | 207, 112, 112, 137, 0, 140, 0, 131, 0, 193, |
| 2732 | 195, 191, 0, 0, 0, 0, 0, 0, 0, 146, |
| 2733 | 176, 0, 0, 0, 150, 0, 147, 0, 0, 0, |
| 2734 | 0, 0, 189, 219, 213, 216, 217, 0, 236, 0, |
| 2735 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2736 | 310, 0, 0, 0, 290, 293, 0, 0, 291, 292, |
| 2737 | 0, 0, 0, 287, 288, 0, 308, 0, 132, 133, |
| 2738 | 136, 142, 0, 0, 108, 106, 0, 0, 300, 0, |
| 2739 | 0, 0, 0, 0, 145, 135, 114, 0, 148, 149, |
| 2740 | 0, 0, 0, 0, 0, 212, 214, 0, 104, 0, |
| 2741 | 245, 0, 0, 278, 0, 0, 101, 102, 101, 275, |
| 2742 | 299, 0, 0, 0, 0, 0, 281, 282, 283, 278, |
| 2743 | 0, 103, 109, 107, 0, 0, 0, 0, 0, 0, |
| 2744 | 0, 175, 152, 0, 0, 0, 0, 0, 0, 218, |
| 2745 | 215, 105, 99, 0, 0, 0, 277, 0, 284, 285, |
| 2746 | 0, 304, 306, 0, 0, 0, 289, 294, 295, 0, |
| 2747 | 309, 0, 0, 164, 0, 0, 0, 0, 151, 0, |
| 2748 | 0, 0, 0, 0, 0, 221, 247, 0, 0, 0, |
| 2749 | 276, 273, 0, 297, 0, 0, 0, 172, 0, 0, |
| 2750 | 166, 167, 168, 171, 163, 100, 0, 266, 0, 0, |
| 2751 | 0, 274, 169, 170, 0, 0, 0, 264, 0, 265, |
| 2752 | 0, 0, 165, 173, 174, 0, 0, 0, 0, 0, |
| 2753 | 0, 271, 0, 0, 270, 267 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2754 | }; |
| 2755 | |
| 2756 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 2757 | static const short int yydefgoto[] = |
| 2758 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2759 | -1, 94, 312, 329, 330, 331, 255, 272, 332, 333, |
| 2760 | 219, 220, 243, 221, 25, 15, 63, 555, 359, 454, |
| 2761 | 522, 389, 455, 95, 96, 222, 98, 99, 202, 304, |
| 2762 | 400, 348, 401, 104, 1, 2, 3, 336, 307, 305, |
| 2763 | 306, 55, 190, 42, 72, 194, 100, 476, 415, 416, |
| 2764 | 417, 64, 113, 16, 30, 36, 17, 53, 18, 28, |
| 2765 | 108, 419, 349, 101, 351, 489, 19, 32, 33, 181, |
| 2766 | 182, 579, 66, 278, 526, 527, 183, 184, 430, 185, |
| 2767 | 186 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2768 | }; |
| 2769 | |
| 2770 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 2771 | STATE-NUM. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2772 | #define YYPACT_NINF -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2773 | static const short int yypact[] = |
| 2774 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2775 | -542, 13, 162, 567, -542, -542, -542, -542, -542, -542, |
| 2776 | -542, -542, -542, -542, 83, -542, 19, -542, -542, -14, |
| 2777 | -542, -542, 50, -87, 87, 233, 27, -542, 123, 141, |
| 2778 | 175, -542, -542, 98, -542, -542, -542, -542, 33, 40, |
| 2779 | 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156, |
| 2780 | -542, -542, -542, -542, -542, -542, 221, -542, -542, -542, |
| 2781 | -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226, |
| 2782 | 227, 235, -542, -542, -542, -542, 81, -542, -542, -542, |
| 2783 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2784 | 256, 257, 4, 15, -542, -542, 108, -542, -542, 12, |
| 2785 | -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542, |
| 2786 | 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116, |
| 2787 | 479, 175, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2788 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2789 | -542, -542, -542, -542, -542, -542, -542, -542, -542, 355, |
| 2790 | 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, |
| 2791 | 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542, |
| 2792 | -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306, |
| 2793 | 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542, |
| 2794 | -542, -542, -542, -542, -13, -542, 110, 111, 75, -542, |
| 2795 | -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208, |
| 2796 | 266, 210, 267, 212, 268, 230, 277, 275, 278, 246, |
| 2797 | 280, 279, 566, -542, -542, 136, 766, -542, -542, 81, |
| 2798 | -542, 766, 766, -542, -542, -542, -542, -542, -542, -542, |
| 2799 | -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542, |
| 2800 | -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542, |
| 2801 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2802 | -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147, |
| 2803 | 148, 149, 151, 152, 158, 160, 766, 766, 766, 161, |
| 2804 | 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27, |
| 2805 | 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542, |
| 2806 | -542, -542, -542, -542, -542, -542, -542, -542, 355, 429, |
| 2807 | 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184, |
| 2808 | 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542, |
| 2809 | -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542, |
| 2810 | -542, -542, 193, -542, 194, 766, 766, 766, 7, -542, |
| 2811 | 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306, |
| 2812 | 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207, |
| 2813 | -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542, |
| 2814 | -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542, |
| 2815 | -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326, |
| 2816 | 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337, |
| 2817 | -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306, |
| 2818 | -542, 223, 766, 224, -542, -542, 225, 234, -542, -542, |
| 2819 | 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542, |
| 2820 | -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236, |
| 2821 | 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542, |
| 2822 | 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252, |
| 2823 | -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542, |
| 2824 | 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306, |
| 2825 | 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326, |
| 2826 | 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542, |
| 2827 | -542, -542, 368, 402, 274, 276, 259, 287, -542, -542, |
| 2828 | 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290, |
| 2829 | -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296, |
| 2830 | 297, 299, 302, 303, 430, -542, -542, 414, 41, 425, |
| 2831 | -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326, |
| 2832 | -542, -542, -542, -542, -542, -542, 766, -542, 893, 144, |
| 2833 | 448, -542, -542, -542, 314, 315, 316, -542, 331, -542, |
| 2834 | 893, 766, -542, -542, -542, 464, 334, 180, 766, 481, |
| 2835 | 482, -542, 766, 766, -542, -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2836 | }; |
| 2837 | |
| 2838 | /* YYPGOTO[NTERM-NUM]. */ |
| 2839 | static const short int yypgoto[] = |
| 2840 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2841 | -542, -542, -542, 435, 439, 441, 191, 197, 442, 445, |
| 2842 | -119, -116, -541, -542, 478, 489, -107, -542, -267, 37, |
| 2843 | -542, -238, -542, -60, -542, -45, -542, -74, -51, -542, |
| 2844 | -101, 300, -252, 134, -542, -542, -542, -542, -542, -542, |
| 2845 | -542, 473, -542, -542, -542, -542, 8, -542, 46, -542, |
| 2846 | -542, 410, -542, -542, -542, -542, -542, -542, 518, -542, |
| 2847 | -542, -542, -528, 142, -90, -113, -542, 505, -542, -72, |
| 2848 | -542, -542, -542, -542, 97, 28, -542, -542, 70, -542, |
| 2849 | -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2850 | }; |
| 2851 | |
| 2852 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2853 | positive, shift that token. If negative, reduce the rule which |
| 2854 | number is the opposite. If zero, do what YYDEFACT says. |
| 2855 | If YYTABLE_NINF, syntax error. */ |
| 2856 | #define YYTABLE_NINF -180 |
| 2857 | static const short int yytable[] = |
| 2858 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2859 | 97, 241, 227, 110, 242, 230, 223, 361, 197, 31, |
| 2860 | 111, 26, 449, 4, 244, 204, 34, 578, 97, 201, |
| 2861 | 74, 75, 426, 199, 77, 78, 79, 80, 81, 82, |
| 2862 | 83, 84, 85, 86, 87, 428, 88, 20, 590, 21, |
| 2863 | 275, 26, 31, 279, 280, 281, 282, 283, 284, 285, |
| 2864 | 588, 233, 234, 235, 236, 237, 238, 239, 240, 205, |
| 2865 | 206, 207, 596, 89, 427, 43, 289, 290, 390, 391, |
| 2866 | 226, 463, 300, 226, 403, 405, 291, 427, 452, 468, |
| 2867 | 74, 75, 301, 199, 77, 78, 79, 80, 81, 82, |
| 2868 | 83, 84, 85, 86, 87, 420, 88, 20, 412, 21, |
| 2869 | 448, 453, 38, 39, 40, 204, 273, 274, 226, 276, |
| 2870 | 277, 226, 226, 226, 226, 226, 226, 226, 225, 463, |
| 2871 | 20, 41, 21, 89, 201, 231, 300, 480, -139, 201, |
| 2872 | -112, 286, 287, 288, 226, 226, 384, 232, -139, 204, |
| 2873 | 294, 352, 353, 112, 29, 463, 295, 299, 44, 35, |
| 2874 | 467, 464, 303, 354, 233, 234, 235, 236, 237, 238, |
| 2875 | 239, 240, -179, 463, 463, 54, 198, -112, 51, 90, |
| 2876 | 52, 71, 91, 469, 513, 92, 204, 93, 200, 50, |
| 2877 | 379, 105, 106, 107, 355, 67, 362, 5, 102, 103, |
| 2878 | 188, 189, 68, 6, 292, 293, 372, 373, 374, 97, |
| 2879 | 577, 308, 309, 7, 8, 9, 10, 11, 12, 13, |
| 2880 | 356, -72, -72, -71, -71, -70, -70, 503, 69, 531, |
| 2881 | 70, 532, 381, 382, 14, 109, 385, 357, 187, 90, |
| 2882 | 191, 377, 91, -69, -69, 92, -113, 93, 298, 56, |
| 2883 | 57, 58, 59, 60, 61, 62, 97, 378, 226, 310, |
| 2884 | 311, 192, 433, 45, 435, 436, 437, 123, 124, 193, |
| 2885 | 195, 196, 443, 203, 228, 423, 424, 425, 296, 297, |
| 2886 | -76, -75, -74, 431, 7, 8, 9, 10, 46, 12, |
| 2887 | 47, -73, -79, 48, 313, -80, 314, 445, 446, 363, |
| 2888 | 358, 337, 414, 458, 459, 460, 461, 462, 360, 364, |
| 2889 | 365, 366, 367, 589, 368, 369, 470, 471, 472, 473, |
| 2890 | 474, 370, 385, 371, 375, 380, 383, 376, 386, 387, |
| 2891 | 226, 434, 226, 226, 226, 438, 439, 394, 466, 388, |
| 2892 | 226, 444, 395, 396, 397, 406, 486, 398, 488, 407, |
| 2893 | 408, 409, 492, 410, 411, 418, 421, 422, 429, 432, |
| 2894 | 496, 497, 498, 440, 441, 504, 505, 450, 456, 442, |
| 2895 | 447, 479, 511, 481, 335, 478, 457, 477, 350, 482, |
| 2896 | 483, 484, 485, 350, 350, 487, 491, 493, 494, 502, |
| 2897 | 536, 537, 538, 499, 226, 350, 501, 495, 518, 507, |
| 2898 | 508, 524, 525, 509, 528, 529, 510, 514, 515, 512, |
| 2899 | 516, 534, 500, 517, 452, 523, 544, 545, 546, 547, |
| 2900 | 540, 530, 533, 549, 550, 551, 552, 535, 350, 543, |
| 2901 | 560, 548, 475, 541, 542, 554, 556, 557, 350, 350, |
| 2902 | 350, 427, 414, 558, 575, 576, 566, 568, 226, 241, |
| 2903 | 564, 565, 242, 559, 561, 562, 563, 569, 226, 226, |
| 2904 | 226, 567, 570, 571, 226, 572, 256, 257, 573, 574, |
| 2905 | 241, 580, 582, 242, 581, 584, 583, 585, 586, 591, |
| 2906 | 592, 593, 594, 553, 245, 246, 247, 248, 249, 250, |
| 2907 | 251, 252, 253, 254, 595, 598, 587, 599, 226, 233, |
| 2908 | 234, 235, 236, 237, 238, 239, 240, 350, 350, 350, |
| 2909 | 176, 597, 602, 603, 177, 350, 178, 179, 601, 392, |
| 2910 | 180, 65, 604, 605, 49, 521, 393, 73, 224, 350, |
| 2911 | 350, 27, 334, 520, 37, 600, 490, 539, 506, 0, |
| 2912 | 0, 0, 0, 0, 74, 75, 0, 199, 208, 209, |
| 2913 | 210, 211, 212, 213, 214, 215, 216, 217, 218, 0, |
| 2914 | 88, 20, 0, 21, 258, 259, 260, 261, 262, 263, |
| 2915 | 264, 265, 266, 267, 268, 269, 270, 271, 350, 0, |
| 2916 | 350, 74, 75, 0, 350, 0, 0, 89, 0, 0, |
| 2917 | 0, 0, 350, 350, 350, 0, 0, -82, 20, 20, |
| 2918 | 21, 21, 315, 0, 0, 0, 0, 0, 6, -82, |
| 2919 | -82, 0, 0, 0, 316, 317, 0, 0, -82, -82, |
| 2920 | -82, -82, -82, -82, -82, 0, 0, -82, 22, 0, |
| 2921 | 0, 0, 0, 350, 350, 23, 350, 350, 0, 24, |
| 2922 | 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2923 | 0, 0, 350, 0, 0, 125, 126, 127, 128, 129, |
| 2924 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2925 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
| 2926 | 319, 0, 0, 0, 0, 0, 320, 350, 321, 0, |
| 2927 | 322, 323, 324, 90, 0, 0, 91, 0, 0, 92, |
| 2928 | 0, 93, 404, 0, 0, 0, 0, 0, 0, 0, |
| 2929 | 0, 0, 0, 0, 0, 163, 164, 165, 166, 167, |
| 2930 | 168, 169, 170, 171, 172, 173, 174, 175, 350, 0, |
| 2931 | 0, 0, 0, 325, 0, 0, 326, 0, 327, 0, |
| 2932 | 0, 328, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2933 | 350, 0, 0, 0, 350, 350, 74, 75, 0, 199, |
| 2934 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, |
| 2935 | 218, 0, 88, 20, 0, 21, 0, 0, 0, 338, |
| 2936 | 339, 74, 75, 340, 0, 0, 0, 0, 0, 0, |
| 2937 | 0, 0, 0, 0, 0, 0, 0, 0, 20, 89, |
| 2938 | 21, 0, 341, 342, 343, 0, 0, 0, 0, 0, |
| 2939 | 0, 0, 0, 0, 344, 345, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2940 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2941 | 0, 0, 0, 0, 0, 0, 0, 346, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2942 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2943 | 0, 0, 0, 0, 0, 125, 126, 127, 128, 129, |
| 2944 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2945 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2946 | 319, 0, 0, 0, 0, 0, 320, 0, 321, 0, |
| 2947 | 322, 323, 324, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2948 | 0, 0, 0, 0, 0, 90, 338, 339, 91, 0, |
| 2949 | 340, 92, 0, 93, 465, 163, 164, 165, 166, 167, |
| 2950 | 168, 169, 170, 171, 172, 173, 174, 175, 0, 341, |
| 2951 | 342, 343, 0, 0, 0, 0, 347, 0, 0, 0, |
| 2952 | 0, 344, 345, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2953 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2954 | 0, 0, 0, 0, 346, 0, 0, 0, 0, 0, |
| 2955 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2956 | 0, 0, 125, 126, 127, 128, 129, 130, 131, 132, |
| 2957 | 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, |
| 2958 | 143, 144, 145, 146, 147, 148, 318, 319, 0, 0, |
| 2959 | 0, 0, 0, 320, 0, 321, 0, 322, 323, 324, |
| 2960 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2961 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2962 | 0, 0, 163, 164, 165, 166, 167, 168, 169, 170, |
| 2963 | 171, 172, 173, 174, 175, 0, 0, 0, 0, 0, |
| 2964 | 0, 74, 75, 347, 199, 77, 78, 79, 80, 81, |
| 2965 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 2966 | 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2967 | 0, 0, 0, 302, 0, 0, 0, 0, 0, 0, |
| 2968 | 0, 0, 74, 75, 89, 199, 208, 209, 210, 211, |
| 2969 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 2970 | 0, 21, 74, 75, 0, 199, 77, 78, 79, 80, |
| 2971 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 2972 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 0, |
| 2973 | 0, 0, 0, 0, 413, 0, 0, 0, 0, 0, |
| 2974 | 0, 0, 0, 74, 75, 89, 199, 77, 78, 79, |
| 2975 | 80, 81, 82, 83, 84, 85, 86, 87, 0, 88, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2976 | 20, 0, 21, 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, 451, 0, 0, 0, 0, |
| 2978 | 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, |
| 2979 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
| 2980 | 74, 75, 0, 199, 77, 78, 79, 80, 81, 82, |
| 2981 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
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, 90, 519, 0, 91, 0, 399, 92, 0, 93, |
| 2984 | 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, |
| 2985 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 93, |
| 2986 | 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, |
| 2987 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
| 2988 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2989 | 0, 0, 90, 0, 0, 91, 0, 0, 92, 0, |
| 2990 | 93, 74, 75, 89, 199, 77, 78, 79, 80, 81, |
| 2991 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 2992 | 21, 74, 75, 0, 199, 208, 209, 210, 211, 212, |
| 2993 | 213, 214, 215, 216, 217, 218, 0, 88, 20, 0, |
| 2994 | 21, 0, 0, 0, 89, 0, 0, 0, 0, 90, |
| 2995 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 2996 | 0, 0, 74, 75, 89, 229, 77, 78, 79, 80, |
| 2997 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 2998 | 0, 21, 74, 75, 0, 199, 208, 209, 210, 211, |
| 2999 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 3000 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 90, |
| 3001 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 3002 | 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3003 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3004 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3005 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3006 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3007 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3008 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3009 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3010 | 0, 0, 0, 0, 114, 0, 0, 0, 0, 0, |
| 3011 | 0, 90, 0, 0, 91, 0, 0, 92, 115, 93, |
| 3012 | 0, 0, 0, 0, 0, 0, 0, 0, 116, 117, |
| 3013 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 402, |
| 3014 | 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 3015 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3016 | 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3017 | 147, 148, 149, 150, 151, 152, 153, 0, 0, 154, |
| 3018 | 155, 156, 157, 158, 159, 160, 161, 162, 0, 0, |
| 3019 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3020 | 0, 0, 0, 0, 0, 0, 0, 0, 163, 164, |
| 3021 | 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 3022 | 175 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3023 | }; |
| 3024 | |
| 3025 | static const short int yycheck[] = |
| 3026 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3027 | 45, 120, 115, 63, 120, 118, 107, 274, 4, 23, |
| 3028 | 29, 3, 161, 0, 121, 164, 30, 558, 63, 93, |
| 3029 | 5, 6, 15, 8, 9, 10, 11, 12, 13, 14, |
| 3030 | 15, 16, 17, 18, 19, 15, 21, 22, 579, 24, |
| 3031 | 153, 33, 23, 156, 157, 158, 159, 160, 161, 162, |
| 3032 | 578, 10, 11, 12, 13, 14, 15, 16, 17, 104, |
| 3033 | 105, 106, 590, 48, 57, 152, 179, 180, 306, 307, |
| 3034 | 115, 153, 153, 118, 326, 327, 183, 57, 34, 161, |
| 3035 | 5, 6, 163, 8, 9, 10, 11, 12, 13, 14, |
| 3036 | 15, 16, 17, 18, 19, 347, 21, 22, 336, 24, |
| 3037 | 159, 57, 52, 53, 54, 164, 151, 152, 153, 154, |
| 3038 | 155, 156, 157, 158, 159, 160, 161, 162, 110, 153, |
| 3039 | 22, 71, 24, 48, 198, 9, 153, 161, 153, 203, |
| 3040 | 155, 176, 177, 178, 179, 180, 163, 21, 163, 164, |
| 3041 | 153, 231, 232, 162, 61, 153, 159, 198, 61, 163, |
| 3042 | 402, 159, 203, 243, 10, 11, 12, 13, 14, 15, |
| 3043 | 16, 17, 0, 153, 153, 24, 162, 155, 45, 154, |
| 3044 | 47, 157, 157, 163, 163, 160, 164, 162, 163, 152, |
| 3045 | 293, 47, 48, 49, 244, 152, 276, 25, 32, 33, |
| 3046 | 55, 56, 152, 31, 108, 109, 286, 287, 288, 244, |
| 3047 | 159, 27, 28, 41, 42, 43, 44, 45, 46, 47, |
| 3048 | 255, 3, 4, 3, 4, 3, 4, 455, 152, 486, |
| 3049 | 152, 488, 296, 297, 62, 4, 300, 272, 24, 154, |
| 3050 | 4, 291, 157, 3, 4, 160, 155, 162, 163, 64, |
| 3051 | 65, 66, 67, 68, 69, 70, 291, 292, 293, 3, |
| 3052 | 4, 24, 365, 20, 367, 368, 369, 77, 78, 24, |
| 3053 | 4, 4, 375, 155, 59, 355, 356, 357, 158, 158, |
| 3054 | 4, 4, 4, 363, 41, 42, 43, 44, 45, 46, |
| 3055 | 47, 4, 7, 50, 4, 7, 7, 377, 378, 157, |
| 3056 | 153, 155, 337, 394, 395, 396, 397, 398, 153, 153, |
| 3057 | 153, 153, 153, 159, 153, 153, 407, 408, 409, 410, |
| 3058 | 411, 153, 386, 153, 153, 24, 161, 36, 153, 156, |
| 3059 | 365, 366, 367, 368, 369, 370, 371, 155, 402, 153, |
| 3060 | 375, 376, 155, 155, 155, 24, 426, 155, 428, 155, |
| 3061 | 155, 155, 432, 155, 155, 63, 153, 153, 153, 157, |
| 3062 | 440, 441, 442, 153, 153, 456, 457, 161, 155, 153, |
| 3063 | 153, 24, 463, 21, 222, 156, 155, 153, 226, 21, |
| 3064 | 155, 153, 153, 231, 232, 4, 153, 153, 153, 4, |
| 3065 | 493, 494, 495, 155, 429, 243, 24, 153, 36, 153, |
| 3066 | 153, 481, 482, 153, 484, 485, 153, 153, 153, 161, |
| 3067 | 153, 491, 447, 153, 34, 153, 507, 508, 509, 510, |
| 3068 | 500, 153, 153, 514, 515, 516, 517, 153, 276, 156, |
| 3069 | 533, 161, 414, 153, 153, 57, 24, 153, 286, 287, |
| 3070 | 288, 57, 477, 157, 4, 21, 153, 153, 483, 558, |
| 3071 | 541, 542, 558, 156, 159, 535, 156, 153, 493, 494, |
| 3072 | 495, 156, 156, 156, 499, 156, 27, 28, 156, 156, |
| 3073 | 579, 36, 156, 579, 159, 566, 156, 568, 569, 21, |
| 3074 | 156, 156, 156, 518, 119, 120, 121, 122, 123, 124, |
| 3075 | 125, 126, 127, 128, 153, 21, 576, 153, 533, 10, |
| 3076 | 11, 12, 13, 14, 15, 16, 17, 355, 356, 357, |
| 3077 | 65, 591, 21, 21, 65, 363, 65, 65, 598, 318, |
| 3078 | 65, 33, 602, 603, 25, 478, 319, 44, 108, 377, |
| 3079 | 378, 3, 222, 477, 19, 597, 429, 499, 458, -1, |
| 3080 | -1, -1, -1, -1, 5, 6, -1, 8, 9, 10, |
| 3081 | 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, |
| 3082 | 21, 22, -1, 24, 125, 126, 127, 128, 129, 130, |
| 3083 | 131, 132, 133, 134, 135, 136, 137, 138, 426, -1, |
| 3084 | 428, 5, 6, -1, 432, -1, -1, 48, -1, -1, |
| 3085 | -1, -1, 440, 441, 442, -1, -1, 20, 22, 22, |
| 3086 | 24, 24, 26, -1, -1, -1, -1, -1, 31, 32, |
| 3087 | 33, -1, -1, -1, 38, 39, -1, -1, 41, 42, |
| 3088 | 43, 44, 45, 46, 47, -1, -1, 50, 51, -1, |
| 3089 | -1, -1, -1, 481, 482, 58, 484, 485, -1, 62, |
| 3090 | -1, -1, -1, 491, -1, -1, -1, -1, -1, -1, |
| 3091 | -1, -1, 500, -1, -1, 79, 80, 81, 82, 83, |
| 3092 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3093 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3094 | 104, -1, -1, -1, -1, -1, 110, 535, 112, -1, |
| 3095 | 114, 115, 116, 154, -1, -1, 157, -1, -1, 160, |
| 3096 | -1, 162, 163, -1, -1, -1, -1, -1, -1, -1, |
| 3097 | -1, -1, -1, -1, -1, 139, 140, 141, 142, 143, |
| 3098 | 144, 145, 146, 147, 148, 149, 150, 151, 576, -1, |
| 3099 | -1, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3100 | -1, 165, -1, 591, -1, -1, -1, -1, -1, -1, |
| 3101 | 598, -1, -1, -1, 602, 603, 5, 6, -1, 8, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3102 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3103 | 19, -1, 21, 22, -1, 24, -1, -1, -1, 3, |
| 3104 | 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, |
| 3105 | -1, -1, -1, -1, -1, -1, -1, -1, 22, 48, |
| 3106 | 24, -1, 26, 27, 28, -1, -1, -1, -1, -1, |
| 3107 | -1, -1, -1, -1, 38, 39, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3108 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3109 | -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, |
| 3110 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3111 | -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, |
| 3112 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3113 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3114 | 104, -1, -1, -1, -1, -1, 110, -1, 112, -1, |
| 3115 | 114, 115, 116, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3116 | -1, -1, -1, -1, -1, 154, 3, 4, 157, -1, |
| 3117 | 7, 160, -1, 162, 163, 139, 140, 141, 142, 143, |
| 3118 | 144, 145, 146, 147, 148, 149, 150, 151, -1, 26, |
| 3119 | 27, 28, -1, -1, -1, -1, 160, -1, -1, -1, |
| 3120 | -1, 38, 39, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3121 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3122 | -1, -1, -1, -1, 61, -1, -1, -1, -1, -1, |
| 3123 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3124 | -1, -1, 79, 80, 81, 82, 83, 84, 85, 86, |
| 3125 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 3126 | 97, 98, 99, 100, 101, 102, 103, 104, -1, -1, |
| 3127 | -1, -1, -1, 110, -1, 112, -1, 114, 115, 116, |
| 3128 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3129 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3130 | -1, -1, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3131 | 147, 148, 149, 150, 151, -1, -1, -1, -1, -1, |
| 3132 | -1, 5, 6, 160, 8, 9, 10, 11, 12, 13, |
| 3133 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3134 | 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3135 | -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, |
| 3136 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3137 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3138 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3139 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3140 | -1, 24, -1, -1, -1, 48, -1, -1, -1, -1, |
| 3141 | -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, |
| 3142 | -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3143 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 3144 | 22, -1, 24, -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, 37, -1, -1, -1, -1, |
| 3146 | -1, -1, -1, -1, -1, -1, 48, -1, -1, -1, |
| 3147 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3148 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3149 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 3150 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3151 | -1, 154, 37, -1, 157, -1, 159, 160, -1, 162, |
| 3152 | -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3153 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3154 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3155 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3156 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3157 | -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3158 | 162, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 3159 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3160 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 3161 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3162 | 24, -1, -1, -1, 48, -1, -1, -1, -1, 154, |
| 3163 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3164 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 3165 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3166 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3167 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3168 | -1, 24, -1, -1, -1, 48, -1, -1, -1, 154, |
| 3169 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3170 | -1, -1, -1, -1, -1, 48, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3171 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3172 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3173 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3174 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3175 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3176 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3177 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3178 | -1, -1, -1, -1, 35, -1, -1, -1, -1, -1, |
| 3179 | -1, 154, -1, -1, 157, -1, -1, 160, 49, 162, |
| 3180 | -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, |
| 3181 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 3182 | -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 3183 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 3184 | 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, |
| 3185 | 101, 102, 103, 104, 105, 106, 107, -1, -1, 110, |
| 3186 | 111, 112, 113, 114, 115, 116, 117, 118, -1, -1, |
| 3187 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3188 | -1, -1, -1, -1, -1, -1, -1, -1, 139, 140, |
| 3189 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, |
| 3190 | 151 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3191 | }; |
| 3192 | |
| 3193 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 3194 | symbol of state STATE-NUM. */ |
| 3195 | static const unsigned char yystos[] = |
| 3196 | { |
| 3197 | 0, 200, 201, 202, 0, 25, 31, 41, 42, 43, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3198 | 44, 45, 46, 47, 62, 181, 219, 222, 224, 232, |
| 3199 | 22, 24, 51, 58, 62, 180, 212, 224, 225, 61, |
| 3200 | 220, 23, 233, 234, 30, 163, 221, 233, 52, 53, |
| 3201 | 54, 71, 209, 152, 61, 20, 45, 47, 50, 181, |
| 3202 | 152, 45, 47, 223, 24, 207, 64, 65, 66, 67, |
| 3203 | 68, 69, 70, 182, 217, 180, 238, 152, 152, 152, |
| 3204 | 152, 157, 210, 207, 5, 6, 8, 9, 10, 11, |
| 3205 | 12, 13, 14, 15, 16, 17, 18, 19, 21, 48, |
| 3206 | 154, 157, 160, 162, 167, 189, 190, 191, 192, 193, |
| 3207 | 212, 229, 32, 33, 199, 199, 199, 199, 226, 4, |
| 3208 | 189, 29, 162, 218, 35, 49, 59, 60, 72, 73, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3209 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 3210 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3211 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3212 | 104, 105, 106, 107, 110, 111, 112, 113, 114, 115, |
| 3213 | 116, 117, 118, 139, 140, 141, 142, 143, 144, 145, |
| 3214 | 146, 147, 148, 149, 150, 151, 169, 170, 171, 174, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3215 | 175, 235, 236, 242, 243, 245, 246, 24, 55, 56, |
| 3216 | 208, 4, 24, 24, 211, 4, 4, 4, 162, 8, |
| 3217 | 163, 193, 194, 155, 164, 191, 191, 191, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3218 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 176, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3219 | 177, 179, 191, 196, 217, 212, 191, 231, 59, 8, |
| 3220 | 231, 9, 21, 10, 11, 12, 13, 14, 15, 16, |
| 3221 | 17, 176, 177, 178, 182, 119, 120, 121, 122, 123, |
| 3222 | 124, 125, 126, 127, 128, 172, 27, 28, 125, 126, |
| 3223 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3224 | 137, 138, 173, 191, 191, 231, 191, 191, 239, 231, |
| 3225 | 231, 231, 231, 231, 231, 231, 191, 191, 191, 231, |
| 3226 | 231, 182, 108, 109, 153, 159, 158, 158, 163, 194, |
| 3227 | 153, 163, 37, 194, 195, 205, 206, 204, 27, 28, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3228 | 3, 4, 168, 4, 7, 26, 38, 39, 103, 104, |
| 3229 | 110, 112, 114, 115, 116, 157, 160, 162, 165, 169, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3230 | 170, 171, 174, 175, 197, 229, 203, 155, 3, 4, |
| 3231 | 7, 26, 27, 28, 38, 39, 61, 160, 197, 228, |
| 3232 | 229, 230, 230, 230, 230, 189, 191, 191, 153, 184, |
| 3233 | 153, 184, 230, 157, 153, 153, 153, 153, 153, 153, |
| 3234 | 153, 153, 230, 230, 230, 153, 36, 189, 191, 231, |
| 3235 | 24, 193, 193, 161, 163, 193, 153, 156, 153, 187, |
| 3236 | 187, 187, 172, 173, 155, 155, 155, 155, 155, 159, |
| 3237 | 196, 198, 162, 198, 163, 198, 24, 155, 155, 155, |
| 3238 | 155, 155, 187, 37, 191, 214, 215, 216, 63, 227, |
| 3239 | 198, 153, 153, 230, 230, 230, 15, 57, 15, 153, |
| 3240 | 244, 230, 157, 231, 191, 231, 231, 231, 191, 191, |
| 3241 | 153, 153, 153, 231, 191, 230, 230, 153, 159, 161, |
| 3242 | 161, 37, 34, 57, 185, 188, 155, 155, 196, 196, |
| 3243 | 196, 196, 196, 153, 159, 163, 193, 198, 161, 163, |
| 3244 | 196, 196, 196, 196, 196, 212, 213, 153, 156, 24, |
| 3245 | 161, 21, 21, 155, 153, 153, 230, 4, 230, 231, |
| 3246 | 240, 153, 230, 153, 153, 153, 230, 230, 230, 155, |
| 3247 | 191, 24, 4, 187, 196, 196, 244, 153, 153, 153, |
| 3248 | 153, 196, 161, 163, 153, 153, 153, 153, 36, 37, |
| 3249 | 214, 185, 186, 153, 230, 230, 240, 241, 230, 230, |
| 3250 | 153, 184, 184, 153, 230, 153, 231, 231, 231, 241, |
| 3251 | 230, 153, 153, 156, 196, 196, 196, 196, 161, 196, |
| 3252 | 196, 196, 196, 191, 57, 183, 24, 153, 157, 156, |
| 3253 | 231, 159, 230, 156, 196, 196, 153, 156, 153, 153, |
| 3254 | 156, 156, 156, 156, 156, 4, 21, 159, 178, 237, |
| 3255 | 36, 159, 156, 156, 196, 196, 196, 230, 228, 159, |
| 3256 | 178, 21, 156, 156, 156, 153, 228, 230, 21, 153, |
| 3257 | 235, 230, 21, 21, 230, 230 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3258 | }; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3259 | |
| 3260 | #define yyerrok (yyerrstatus = 0) |
| 3261 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3262 | #define YYEMPTY (-2) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3263 | #define YYEOF 0 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3264 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3265 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3266 | #define YYABORT goto yyabortlab |
| 3267 | #define YYERROR goto yyerrorlab |
| 3268 | |
| 3269 | |
| 3270 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 3271 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3272 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3273 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3274 | #define YYFAIL goto yyerrlab |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3275 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3276 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3277 | |
| 3278 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3279 | do \ |
| 3280 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3281 | { \ |
| 3282 | yychar = (Token); \ |
| 3283 | yylval = (Value); \ |
| 3284 | yytoken = YYTRANSLATE (yychar); \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3285 | YYPOPSTACK; \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3286 | goto yybackup; \ |
| 3287 | } \ |
| 3288 | else \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3289 | { \ |
| 3290 | yyerror (YY_("syntax error: cannot back up")); \ |
| 3291 | YYERROR; \ |
| 3292 | } \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3293 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3294 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3295 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3296 | #define YYTERROR 1 |
| 3297 | #define YYERRCODE 256 |
| 3298 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3299 | |
| 3300 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 3301 | If N is 0, then set CURRENT to the empty location which ends |
| 3302 | the previous symbol: RHS[0] (always defined). */ |
| 3303 | |
| 3304 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 3305 | #ifndef YYLLOC_DEFAULT |
| 3306 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 3307 | do \ |
| 3308 | if (N) \ |
| 3309 | { \ |
| 3310 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 3311 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 3312 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 3313 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 3314 | } \ |
| 3315 | else \ |
| 3316 | { \ |
| 3317 | (Current).first_line = (Current).last_line = \ |
| 3318 | YYRHSLOC (Rhs, 0).last_line; \ |
| 3319 | (Current).first_column = (Current).last_column = \ |
| 3320 | YYRHSLOC (Rhs, 0).last_column; \ |
| 3321 | } \ |
| 3322 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3323 | #endif |
| 3324 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3325 | |
| 3326 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 3327 | This macro was not mandated originally: define only if we know |
| 3328 | we won't break user code: when these are the locations we know. */ |
| 3329 | |
| 3330 | #ifndef YY_LOCATION_PRINT |
| 3331 | # if YYLTYPE_IS_TRIVIAL |
| 3332 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 3333 | fprintf (File, "%d.%d-%d.%d", \ |
| 3334 | (Loc).first_line, (Loc).first_column, \ |
| 3335 | (Loc).last_line, (Loc).last_column) |
| 3336 | # else |
| 3337 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 3338 | # endif |
| 3339 | #endif |
| 3340 | |
| 3341 | |
| 3342 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 3343 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3344 | #ifdef YYLEX_PARAM |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3345 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3346 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3347 | # define YYLEX yylex () |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3348 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3349 | |
| 3350 | /* Enable debugging if requested. */ |
| 3351 | #if YYDEBUG |
| 3352 | |
| 3353 | # ifndef YYFPRINTF |
| 3354 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 3355 | # define YYFPRINTF fprintf |
| 3356 | # endif |
| 3357 | |
| 3358 | # define YYDPRINTF(Args) \ |
| 3359 | do { \ |
| 3360 | if (yydebug) \ |
| 3361 | YYFPRINTF Args; \ |
| 3362 | } while (0) |
| 3363 | |
| 3364 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 3365 | do { \ |
| 3366 | if (yydebug) \ |
| 3367 | { \ |
| 3368 | YYFPRINTF (stderr, "%s ", Title); \ |
| 3369 | yysymprint (stderr, \ |
| 3370 | Type, Value); \ |
| 3371 | YYFPRINTF (stderr, "\n"); \ |
| 3372 | } \ |
| 3373 | } while (0) |
| 3374 | |
| 3375 | /*------------------------------------------------------------------. |
| 3376 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 3377 | | TOP (included). | |
| 3378 | `------------------------------------------------------------------*/ |
| 3379 | |
| 3380 | #if defined (__STDC__) || defined (__cplusplus) |
| 3381 | static void |
| 3382 | yy_stack_print (short int *bottom, short int *top) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3383 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3384 | static void |
| 3385 | yy_stack_print (bottom, top) |
| 3386 | short int *bottom; |
| 3387 | short int *top; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3388 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3389 | { |
| 3390 | YYFPRINTF (stderr, "Stack now"); |
| 3391 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 3392 | YYFPRINTF (stderr, " %d", *bottom); |
| 3393 | YYFPRINTF (stderr, "\n"); |
| 3394 | } |
| 3395 | |
| 3396 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 3397 | do { \ |
| 3398 | if (yydebug) \ |
| 3399 | yy_stack_print ((Bottom), (Top)); \ |
| 3400 | } while (0) |
| 3401 | |
| 3402 | |
| 3403 | /*------------------------------------------------. |
| 3404 | | Report that the YYRULE is going to be reduced. | |
| 3405 | `------------------------------------------------*/ |
| 3406 | |
| 3407 | #if defined (__STDC__) || defined (__cplusplus) |
| 3408 | static void |
| 3409 | yy_reduce_print (int yyrule) |
| 3410 | #else |
| 3411 | static void |
| 3412 | yy_reduce_print (yyrule) |
| 3413 | int yyrule; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3414 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3415 | { |
| 3416 | int yyi; |
| 3417 | unsigned long int yylno = yyrline[yyrule]; |
| 3418 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", |
| 3419 | yyrule - 1, yylno); |
| 3420 | /* Print the symbols being reduced, and their result. */ |
| 3421 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 3422 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
| 3423 | YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); |
| 3424 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3425 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3426 | # define YY_REDUCE_PRINT(Rule) \ |
| 3427 | do { \ |
| 3428 | if (yydebug) \ |
| 3429 | yy_reduce_print (Rule); \ |
| 3430 | } while (0) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3431 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3432 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 3433 | multiple parsers can coexist. */ |
| 3434 | int yydebug; |
| 3435 | #else /* !YYDEBUG */ |
| 3436 | # define YYDPRINTF(Args) |
| 3437 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 3438 | # define YY_STACK_PRINT(Bottom, Top) |
| 3439 | # define YY_REDUCE_PRINT(Rule) |
| 3440 | #endif /* !YYDEBUG */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3441 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3442 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3443 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3444 | #ifndef YYINITDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3445 | # define YYINITDEPTH 200 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3446 | #endif |
| 3447 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3448 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 3449 | if the built-in stack extension method is used). |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3450 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3451 | Do not make this value too large; the results are undefined if |
| 3452 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 3453 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3454 | |
| 3455 | #ifndef YYMAXDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3456 | # define YYMAXDEPTH 10000 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3457 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3458 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3459 | |
| 3460 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3461 | #if YYERROR_VERBOSE |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3462 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3463 | # ifndef yystrlen |
| 3464 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 3465 | # define yystrlen strlen |
| 3466 | # else |
| 3467 | /* Return the length of YYSTR. */ |
| 3468 | static YYSIZE_T |
| 3469 | # if defined (__STDC__) || defined (__cplusplus) |
| 3470 | yystrlen (const char *yystr) |
| 3471 | # else |
| 3472 | yystrlen (yystr) |
| 3473 | const char *yystr; |
| 3474 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3475 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3476 | const char *yys = yystr; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3477 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3478 | while (*yys++ != '\0') |
| 3479 | continue; |
| 3480 | |
| 3481 | return yys - yystr - 1; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3482 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3483 | # endif |
| 3484 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3485 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3486 | # ifndef yystpcpy |
| 3487 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 3488 | # define yystpcpy stpcpy |
| 3489 | # else |
| 3490 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 3491 | YYDEST. */ |
| 3492 | static char * |
| 3493 | # if defined (__STDC__) || defined (__cplusplus) |
| 3494 | yystpcpy (char *yydest, const char *yysrc) |
| 3495 | # else |
| 3496 | yystpcpy (yydest, yysrc) |
| 3497 | char *yydest; |
| 3498 | const char *yysrc; |
| 3499 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3500 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3501 | char *yyd = yydest; |
| 3502 | const char *yys = yysrc; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3503 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3504 | while ((*yyd++ = *yys++) != '\0') |
| 3505 | continue; |
| 3506 | |
| 3507 | return yyd - 1; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3508 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3509 | # endif |
| 3510 | # endif |
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 | # ifndef yytnamerr |
| 3513 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 3514 | quotes and backslashes, so that it's suitable for yyerror. The |
| 3515 | heuristic is that double-quoting is unnecessary unless the string |
| 3516 | contains an apostrophe, a comma, or backslash (other than |
| 3517 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 3518 | null, do not copy; instead, return the length of what the result |
| 3519 | would have been. */ |
| 3520 | static YYSIZE_T |
| 3521 | yytnamerr (char *yyres, const char *yystr) |
| 3522 | { |
| 3523 | if (*yystr == '"') |
| 3524 | { |
| 3525 | size_t yyn = 0; |
| 3526 | char const *yyp = yystr; |
| 3527 | |
| 3528 | for (;;) |
| 3529 | switch (*++yyp) |
| 3530 | { |
| 3531 | case '\'': |
| 3532 | case ',': |
| 3533 | goto do_not_strip_quotes; |
| 3534 | |
| 3535 | case '\\': |
| 3536 | if (*++yyp != '\\') |
| 3537 | goto do_not_strip_quotes; |
| 3538 | /* Fall through. */ |
| 3539 | default: |
| 3540 | if (yyres) |
| 3541 | yyres[yyn] = *yyp; |
| 3542 | yyn++; |
| 3543 | break; |
| 3544 | |
| 3545 | case '"': |
| 3546 | if (yyres) |
| 3547 | yyres[yyn] = '\0'; |
| 3548 | return yyn; |
| 3549 | } |
| 3550 | do_not_strip_quotes: ; |
| 3551 | } |
| 3552 | |
| 3553 | if (! yyres) |
| 3554 | return yystrlen (yystr); |
| 3555 | |
| 3556 | return yystpcpy (yyres, yystr) - yyres; |
| 3557 | } |
| 3558 | # endif |
| 3559 | |
| 3560 | #endif /* YYERROR_VERBOSE */ |
| 3561 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3562 | |
| 3563 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3564 | #if YYDEBUG |
| 3565 | /*--------------------------------. |
| 3566 | | Print this symbol on YYOUTPUT. | |
| 3567 | `--------------------------------*/ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3568 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3569 | #if defined (__STDC__) || defined (__cplusplus) |
| 3570 | static void |
| 3571 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3572 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3573 | static void |
| 3574 | yysymprint (yyoutput, yytype, yyvaluep) |
| 3575 | FILE *yyoutput; |
| 3576 | int yytype; |
| 3577 | YYSTYPE *yyvaluep; |
| 3578 | #endif |
| 3579 | { |
| 3580 | /* Pacify ``unused variable'' warnings. */ |
| 3581 | (void) yyvaluep; |
| 3582 | |
| 3583 | if (yytype < YYNTOKENS) |
| 3584 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 3585 | else |
| 3586 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 3587 | |
| 3588 | |
| 3589 | # ifdef YYPRINT |
| 3590 | if (yytype < YYNTOKENS) |
| 3591 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 3592 | # endif |
| 3593 | switch (yytype) |
| 3594 | { |
| 3595 | default: |
| 3596 | break; |
| 3597 | } |
| 3598 | YYFPRINTF (yyoutput, ")"); |
| 3599 | } |
| 3600 | |
| 3601 | #endif /* ! YYDEBUG */ |
| 3602 | /*-----------------------------------------------. |
| 3603 | | Release the memory associated to this symbol. | |
| 3604 | `-----------------------------------------------*/ |
| 3605 | |
| 3606 | #if defined (__STDC__) || defined (__cplusplus) |
| 3607 | static void |
| 3608 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 3609 | #else |
| 3610 | static void |
| 3611 | yydestruct (yymsg, yytype, yyvaluep) |
| 3612 | const char *yymsg; |
| 3613 | int yytype; |
| 3614 | YYSTYPE *yyvaluep; |
| 3615 | #endif |
| 3616 | { |
| 3617 | /* Pacify ``unused variable'' warnings. */ |
| 3618 | (void) yyvaluep; |
| 3619 | |
| 3620 | if (!yymsg) |
| 3621 | yymsg = "Deleting"; |
| 3622 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 3623 | |
| 3624 | switch (yytype) |
| 3625 | { |
| 3626 | |
| 3627 | default: |
| 3628 | break; |
| 3629 | } |
| 3630 | } |
| 3631 | |
| 3632 | |
| 3633 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 3634 | |
| 3635 | #ifdef YYPARSE_PARAM |
| 3636 | # if defined (__STDC__) || defined (__cplusplus) |
| 3637 | int yyparse (void *YYPARSE_PARAM); |
| 3638 | # else |
| 3639 | int yyparse (); |
| 3640 | # endif |
| 3641 | #else /* ! YYPARSE_PARAM */ |
| 3642 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3643 | int yyparse (void); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3644 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3645 | int yyparse (); |
| 3646 | #endif |
| 3647 | #endif /* ! YYPARSE_PARAM */ |
| 3648 | |
| 3649 | |
| 3650 | |
| 3651 | /* The look-ahead symbol. */ |
| 3652 | int yychar; |
| 3653 | |
| 3654 | /* The semantic value of the look-ahead symbol. */ |
| 3655 | YYSTYPE yylval; |
| 3656 | |
| 3657 | /* Number of syntax errors so far. */ |
| 3658 | int yynerrs; |
| 3659 | |
| 3660 | |
| 3661 | |
| 3662 | /*----------. |
| 3663 | | yyparse. | |
| 3664 | `----------*/ |
| 3665 | |
| 3666 | #ifdef YYPARSE_PARAM |
| 3667 | # if defined (__STDC__) || defined (__cplusplus) |
| 3668 | int yyparse (void *YYPARSE_PARAM) |
| 3669 | # else |
| 3670 | int yyparse (YYPARSE_PARAM) |
| 3671 | void *YYPARSE_PARAM; |
| 3672 | # endif |
| 3673 | #else /* ! YYPARSE_PARAM */ |
| 3674 | #if defined (__STDC__) || defined (__cplusplus) |
| 3675 | int |
| 3676 | yyparse (void) |
| 3677 | #else |
| 3678 | int |
| 3679 | yyparse () |
| 3680 | |
| 3681 | #endif |
| 3682 | #endif |
| 3683 | { |
| 3684 | |
| 3685 | int yystate; |
| 3686 | int yyn; |
| 3687 | int yyresult; |
| 3688 | /* Number of tokens to shift before error messages enabled. */ |
| 3689 | int yyerrstatus; |
| 3690 | /* Look-ahead token as an internal (translated) token number. */ |
| 3691 | int yytoken = 0; |
| 3692 | |
| 3693 | /* Three stacks and their tools: |
| 3694 | `yyss': related to states, |
| 3695 | `yyvs': related to semantic values, |
| 3696 | `yyls': related to locations. |
| 3697 | |
| 3698 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 3699 | to reallocate them elsewhere. */ |
| 3700 | |
| 3701 | /* The state stack. */ |
| 3702 | short int yyssa[YYINITDEPTH]; |
| 3703 | short int *yyss = yyssa; |
| 3704 | short int *yyssp; |
| 3705 | |
| 3706 | /* The semantic value stack. */ |
| 3707 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 3708 | YYSTYPE *yyvs = yyvsa; |
| 3709 | YYSTYPE *yyvsp; |
| 3710 | |
| 3711 | |
| 3712 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3713 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3714 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3715 | YYSIZE_T yystacksize = YYINITDEPTH; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3716 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3717 | /* The variables used to return semantic value and location from the |
| 3718 | action routines. */ |
| 3719 | YYSTYPE yyval; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3720 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3721 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3722 | /* When reducing, the number of symbols on the RHS of the reduced |
| 3723 | rule. */ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3724 | int yylen; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3725 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3726 | YYDPRINTF ((stderr, "Starting parse\n")); |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3727 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3728 | yystate = 0; |
| 3729 | yyerrstatus = 0; |
| 3730 | yynerrs = 0; |
| 3731 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 3732 | |
| 3733 | /* Initialize stack pointers. |
| 3734 | Waste one element of value and location stack |
| 3735 | so that they stay on the same level as the state stack. |
| 3736 | The wasted elements are never initialized. */ |
| 3737 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3738 | yyssp = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3739 | yyvsp = yyvs; |
| 3740 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3741 | goto yysetstate; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3742 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3743 | /*------------------------------------------------------------. |
| 3744 | | yynewstate -- Push a new state, which is found in yystate. | |
| 3745 | `------------------------------------------------------------*/ |
| 3746 | yynewstate: |
| 3747 | /* In all cases, when you get here, the value and location stacks |
| 3748 | have just been pushed. so pushing a state here evens the stacks. |
| 3749 | */ |
| 3750 | yyssp++; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3751 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3752 | yysetstate: |
| 3753 | *yyssp = yystate; |
| 3754 | |
| 3755 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3756 | { |
| 3757 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3758 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3759 | |
| 3760 | #ifdef yyoverflow |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3761 | { |
| 3762 | /* Give user a chance to reallocate the stack. Use copies of |
| 3763 | these so that the &'s don't force the real ones into |
| 3764 | memory. */ |
| 3765 | YYSTYPE *yyvs1 = yyvs; |
| 3766 | short int *yyss1 = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3767 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3768 | |
| 3769 | /* Each stack pointer address is followed by the size of the |
| 3770 | data in use in that stack, in bytes. This used to be a |
| 3771 | conditional around just the two extra args, but that might |
| 3772 | be undefined if yyoverflow is a macro. */ |
| 3773 | yyoverflow (YY_("memory exhausted"), |
| 3774 | &yyss1, yysize * sizeof (*yyssp), |
| 3775 | &yyvs1, yysize * sizeof (*yyvsp), |
| 3776 | |
| 3777 | &yystacksize); |
| 3778 | |
| 3779 | yyss = yyss1; |
| 3780 | yyvs = yyvs1; |
| 3781 | } |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3782 | #else /* no yyoverflow */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3783 | # ifndef YYSTACK_RELOCATE |
| 3784 | goto yyexhaustedlab; |
| 3785 | # else |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3786 | /* Extend the stack our own way. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3787 | if (YYMAXDEPTH <= yystacksize) |
| 3788 | goto yyexhaustedlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3789 | yystacksize *= 2; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3790 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3791 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3792 | |
| 3793 | { |
| 3794 | short int *yyss1 = yyss; |
| 3795 | union yyalloc *yyptr = |
| 3796 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 3797 | if (! yyptr) |
| 3798 | goto yyexhaustedlab; |
| 3799 | YYSTACK_RELOCATE (yyss); |
| 3800 | YYSTACK_RELOCATE (yyvs); |
| 3801 | |
| 3802 | # undef YYSTACK_RELOCATE |
| 3803 | if (yyss1 != yyssa) |
| 3804 | YYSTACK_FREE (yyss1); |
| 3805 | } |
| 3806 | # endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3807 | #endif /* no yyoverflow */ |
| 3808 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3809 | yyssp = yyss + yysize - 1; |
| 3810 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3811 | |
| 3812 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3813 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 3814 | (unsigned long int) yystacksize)); |
| 3815 | |
| 3816 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3817 | YYABORT; |
| 3818 | } |
| 3819 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3820 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3821 | |
| 3822 | goto yybackup; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3823 | |
| 3824 | /*-----------. |
| 3825 | | yybackup. | |
| 3826 | `-----------*/ |
| 3827 | yybackup: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3828 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3829 | /* Do appropriate processing given the current state. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3830 | /* 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] | 3831 | /* yyresume: */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3832 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3833 | /* 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] | 3834 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3835 | yyn = yypact[yystate]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3836 | if (yyn == YYPACT_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3837 | goto yydefault; |
| 3838 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3839 | /* 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] | 3840 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3841 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3842 | if (yychar == YYEMPTY) |
| 3843 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3844 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3845 | yychar = YYLEX; |
| 3846 | } |
| 3847 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3848 | if (yychar <= YYEOF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3849 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3850 | yychar = yytoken = YYEOF; |
| 3851 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3852 | } |
| 3853 | else |
| 3854 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3855 | yytoken = YYTRANSLATE (yychar); |
| 3856 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3857 | } |
| 3858 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3859 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 3860 | detect an error, take that action. */ |
| 3861 | yyn += yytoken; |
| 3862 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3863 | goto yydefault; |
| 3864 | yyn = yytable[yyn]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3865 | if (yyn <= 0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3866 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3867 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3868 | goto yyerrlab; |
| 3869 | yyn = -yyn; |
| 3870 | goto yyreduce; |
| 3871 | } |
| 3872 | |
| 3873 | if (yyn == YYFINAL) |
| 3874 | YYACCEPT; |
| 3875 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3876 | /* Shift the look-ahead token. */ |
| 3877 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3878 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3879 | /* Discard the token being shifted unless it is eof. */ |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3880 | if (yychar != YYEOF) |
| 3881 | yychar = YYEMPTY; |
| 3882 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3883 | *++yyvsp = yylval; |
| 3884 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3885 | |
| 3886 | /* Count tokens shifted since error; after three, turn off error |
| 3887 | status. */ |
| 3888 | if (yyerrstatus) |
| 3889 | yyerrstatus--; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3890 | |
| 3891 | yystate = yyn; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3892 | goto yynewstate; |
| 3893 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3894 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3895 | /*-----------------------------------------------------------. |
| 3896 | | yydefault -- do the default action for the current state. | |
| 3897 | `-----------------------------------------------------------*/ |
| 3898 | yydefault: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3899 | yyn = yydefact[yystate]; |
| 3900 | if (yyn == 0) |
| 3901 | goto yyerrlab; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3902 | goto yyreduce; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3903 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3904 | |
| 3905 | /*-----------------------------. |
| 3906 | | yyreduce -- Do a reduction. | |
| 3907 | `-----------------------------*/ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3908 | yyreduce: |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3909 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3910 | yylen = yyr2[yyn]; |
| 3911 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3912 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3913 | `$$ = $1'. |
| 3914 | |
| 3915 | Otherwise, the following line sets YYVAL to garbage. |
| 3916 | This behavior is undocumented and Bison |
| 3917 | users should not rely upon it. Assigning to YYVAL |
| 3918 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3919 | GCC warning that YYVAL may be used uninitialized. */ |
| 3920 | yyval = yyvsp[1-yylen]; |
| 3921 | |
| 3922 | |
| 3923 | YY_REDUCE_PRINT (yyn); |
| 3924 | switch (yyn) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3925 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3926 | case 3: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3927 | #line 1853 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3928 | { |
| 3929 | if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3930 | error("Value too large for type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3931 | (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); |
| 3932 | ;} |
| 3933 | break; |
| 3934 | |
| 3935 | case 5: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3936 | #line 1862 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3937 | { |
| 3938 | if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3939 | error("Value too large for type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3940 | (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val); |
| 3941 | ;} |
| 3942 | break; |
| 3943 | |
| 3944 | case 26: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3945 | #line 1884 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3946 | { (yyval.IPred) = ICmpInst::ICMP_EQ; ;} |
| 3947 | break; |
| 3948 | |
| 3949 | case 27: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3950 | #line 1884 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3951 | { (yyval.IPred) = ICmpInst::ICMP_NE; ;} |
| 3952 | break; |
| 3953 | |
| 3954 | case 28: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3955 | #line 1885 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3956 | { (yyval.IPred) = ICmpInst::ICMP_SLT; ;} |
| 3957 | break; |
| 3958 | |
| 3959 | case 29: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3960 | #line 1885 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3961 | { (yyval.IPred) = ICmpInst::ICMP_SGT; ;} |
| 3962 | break; |
| 3963 | |
| 3964 | case 30: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3965 | #line 1886 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3966 | { (yyval.IPred) = ICmpInst::ICMP_SLE; ;} |
| 3967 | break; |
| 3968 | |
| 3969 | case 31: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3970 | #line 1886 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3971 | { (yyval.IPred) = ICmpInst::ICMP_SGE; ;} |
| 3972 | break; |
| 3973 | |
| 3974 | case 32: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3975 | #line 1887 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3976 | { (yyval.IPred) = ICmpInst::ICMP_ULT; ;} |
| 3977 | break; |
| 3978 | |
| 3979 | case 33: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3980 | #line 1887 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3981 | { (yyval.IPred) = ICmpInst::ICMP_UGT; ;} |
| 3982 | break; |
| 3983 | |
| 3984 | case 34: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3985 | #line 1888 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3986 | { (yyval.IPred) = ICmpInst::ICMP_ULE; ;} |
| 3987 | break; |
| 3988 | |
| 3989 | case 35: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3990 | #line 1888 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3991 | { (yyval.IPred) = ICmpInst::ICMP_UGE; ;} |
| 3992 | break; |
| 3993 | |
| 3994 | case 36: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 3995 | #line 1892 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3996 | { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;} |
| 3997 | break; |
| 3998 | |
| 3999 | case 37: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4000 | #line 1892 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4001 | { (yyval.FPred) = FCmpInst::FCMP_ONE; ;} |
| 4002 | break; |
| 4003 | |
| 4004 | case 38: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4005 | #line 1893 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4006 | { (yyval.FPred) = FCmpInst::FCMP_OLT; ;} |
| 4007 | break; |
| 4008 | |
| 4009 | case 39: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4010 | #line 1893 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4011 | { (yyval.FPred) = FCmpInst::FCMP_OGT; ;} |
| 4012 | break; |
| 4013 | |
| 4014 | case 40: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4015 | #line 1894 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4016 | { (yyval.FPred) = FCmpInst::FCMP_OLE; ;} |
| 4017 | break; |
| 4018 | |
| 4019 | case 41: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4020 | #line 1894 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4021 | { (yyval.FPred) = FCmpInst::FCMP_OGE; ;} |
| 4022 | break; |
| 4023 | |
| 4024 | case 42: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4025 | #line 1895 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4026 | { (yyval.FPred) = FCmpInst::FCMP_ORD; ;} |
| 4027 | break; |
| 4028 | |
| 4029 | case 43: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4030 | #line 1895 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4031 | { (yyval.FPred) = FCmpInst::FCMP_UNO; ;} |
| 4032 | break; |
| 4033 | |
| 4034 | case 44: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4035 | #line 1896 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4036 | { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;} |
| 4037 | break; |
| 4038 | |
| 4039 | case 45: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4040 | #line 1896 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4041 | { (yyval.FPred) = FCmpInst::FCMP_UNE; ;} |
| 4042 | break; |
| 4043 | |
| 4044 | case 46: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4045 | #line 1897 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4046 | { (yyval.FPred) = FCmpInst::FCMP_ULT; ;} |
| 4047 | break; |
| 4048 | |
| 4049 | case 47: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4050 | #line 1897 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4051 | { (yyval.FPred) = FCmpInst::FCMP_UGT; ;} |
| 4052 | break; |
| 4053 | |
| 4054 | case 48: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4055 | #line 1898 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4056 | { (yyval.FPred) = FCmpInst::FCMP_ULE; ;} |
| 4057 | break; |
| 4058 | |
| 4059 | case 49: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4060 | #line 1898 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4061 | { (yyval.FPred) = FCmpInst::FCMP_UGE; ;} |
| 4062 | break; |
| 4063 | |
| 4064 | case 50: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4065 | #line 1899 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4066 | { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;} |
| 4067 | break; |
| 4068 | |
| 4069 | case 51: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4070 | #line 1900 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4071 | { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;} |
| 4072 | break; |
| 4073 | |
| 4074 | case 81: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4075 | #line 1931 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4076 | { |
| 4077 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
| 4078 | ;} |
| 4079 | break; |
| 4080 | |
| 4081 | case 82: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4082 | #line 1934 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4083 | { |
| 4084 | (yyval.StrVal) = 0; |
| 4085 | ;} |
| 4086 | break; |
| 4087 | |
| 4088 | case 83: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4089 | #line 1939 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4090 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 4091 | break; |
| 4092 | |
| 4093 | case 84: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4094 | #line 1940 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4095 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 4096 | break; |
| 4097 | |
| 4098 | case 85: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4099 | #line 1941 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4100 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 4101 | break; |
| 4102 | |
| 4103 | case 86: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4104 | #line 1942 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4105 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 4106 | break; |
| 4107 | |
| 4108 | case 87: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4109 | #line 1943 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4110 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 4111 | break; |
| 4112 | |
| 4113 | case 88: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4114 | #line 1944 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4115 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 4116 | break; |
| 4117 | |
| 4118 | case 89: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4119 | #line 1945 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4120 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 4121 | break; |
| 4122 | |
| 4123 | case 90: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4124 | #line 1946 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4125 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 4126 | break; |
| 4127 | |
| 4128 | case 91: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4129 | #line 1950 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4130 | { (yyval.UIntVal) = OldCallingConv::C; ;} |
| 4131 | break; |
| 4132 | |
| 4133 | case 92: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4134 | #line 1951 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4135 | { (yyval.UIntVal) = OldCallingConv::C; ;} |
| 4136 | break; |
| 4137 | |
| 4138 | case 93: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4139 | #line 1952 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4140 | { (yyval.UIntVal) = OldCallingConv::CSRet; ;} |
| 4141 | break; |
| 4142 | |
| 4143 | case 94: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4144 | #line 1953 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4145 | { (yyval.UIntVal) = OldCallingConv::Fast; ;} |
| 4146 | break; |
| 4147 | |
| 4148 | case 95: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4149 | #line 1954 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4150 | { (yyval.UIntVal) = OldCallingConv::Cold; ;} |
| 4151 | break; |
| 4152 | |
| 4153 | case 96: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4154 | #line 1955 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4155 | { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;} |
| 4156 | break; |
| 4157 | |
| 4158 | case 97: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4159 | #line 1956 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4160 | { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;} |
| 4161 | break; |
| 4162 | |
| 4163 | case 98: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4164 | #line 1957 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4165 | { |
| 4166 | if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4167 | error("Calling conv too large"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4168 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 4169 | ;} |
| 4170 | break; |
| 4171 | |
| 4172 | case 99: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4173 | #line 1967 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4174 | { (yyval.UIntVal) = 0; ;} |
| 4175 | break; |
| 4176 | |
| 4177 | case 100: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4178 | #line 1968 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4179 | { |
| 4180 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 4181 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4182 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4183 | ;} |
| 4184 | break; |
| 4185 | |
| 4186 | case 101: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4187 | #line 1976 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4188 | { (yyval.UIntVal) = 0; ;} |
| 4189 | break; |
| 4190 | |
| 4191 | case 102: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4192 | #line 1977 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4193 | { |
| 4194 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 4195 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4196 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4197 | ;} |
| 4198 | break; |
| 4199 | |
| 4200 | case 103: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4201 | #line 1985 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4202 | { |
| 4203 | for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) |
| 4204 | if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4205 | error("Invalid character in section name"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4206 | (yyval.StrVal) = (yyvsp[0].StrVal); |
| 4207 | ;} |
| 4208 | break; |
| 4209 | |
| 4210 | case 104: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4211 | #line 1994 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4212 | { (yyval.StrVal) = 0; ;} |
| 4213 | break; |
| 4214 | |
| 4215 | case 105: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4216 | #line 1995 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4217 | { (yyval.StrVal) = (yyvsp[0].StrVal); ;} |
| 4218 | break; |
| 4219 | |
| 4220 | case 106: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4221 | #line 2002 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4222 | {;} |
| 4223 | break; |
| 4224 | |
| 4225 | case 107: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4226 | #line 2003 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4227 | {;} |
| 4228 | break; |
| 4229 | |
| 4230 | case 108: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4231 | #line 2007 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4232 | { |
| 4233 | CurGV->setSection((yyvsp[0].StrVal)); |
| 4234 | free((yyvsp[0].StrVal)); |
| 4235 | ;} |
| 4236 | break; |
| 4237 | |
| 4238 | case 109: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4239 | #line 2011 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4240 | { |
| 4241 | if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4242 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4243 | CurGV->setAlignment((yyvsp[0].UInt64Val)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4244 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4245 | ;} |
| 4246 | break; |
| 4247 | |
| 4248 | case 111: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4249 | #line 2028 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4250 | { |
| 4251 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4252 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4253 | ;} |
| 4254 | break; |
| 4255 | |
| 4256 | case 113: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4257 | #line 2036 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4258 | { |
| 4259 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4260 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4261 | ;} |
| 4262 | break; |
| 4263 | |
| 4264 | case 114: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4265 | #line 2043 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4266 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4267 | if (!UpRefs.empty()) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4268 | error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription()); |
| 4269 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
| 4270 | ;} |
| 4271 | break; |
| 4272 | |
| 4273 | case 127: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4274 | #line 2057 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4275 | { |
| 4276 | (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4277 | (yyval.TypeVal).S.copy((yyvsp[0].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4278 | ;} |
| 4279 | break; |
| 4280 | |
| 4281 | case 128: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4282 | #line 2061 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4283 | { |
| 4284 | (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4285 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4286 | ;} |
| 4287 | break; |
| 4288 | |
| 4289 | case 129: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4290 | #line 2065 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4291 | { // Named types are also simple types... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4292 | (yyval.TypeVal).S.copy(getTypeSign((yyvsp[0].ValIDVal))); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4293 | const Type* tmp = getType((yyvsp[0].ValIDVal)); |
| 4294 | (yyval.TypeVal).PAT = new PATypeHolder(tmp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4295 | ;} |
| 4296 | break; |
| 4297 | |
| 4298 | case 130: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4299 | #line 2070 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4300 | { // Type UpReference |
| 4301 | if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4302 | error("Value out of range"); |
| 4303 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4304 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... |
| 4305 | (yyval.TypeVal).PAT = new PATypeHolder(OT); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4306 | (yyval.TypeVal).S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4307 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4308 | ;} |
| 4309 | break; |
| 4310 | |
| 4311 | case 131: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4312 | #line 2079 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4313 | { // Function derived type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4314 | (yyval.TypeVal).S.makeComposite((yyvsp[-3].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4315 | std::vector<const Type*> Params; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4316 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 4317 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4318 | Params.push_back(I->PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4319 | (yyval.TypeVal).S.add(I->S); |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4320 | } |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 4321 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4322 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 4323 | if (isVarArg) Params.pop_back(); |
| 4324 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4325 | (yyval.TypeVal).PAT = new PATypeHolder( |
| 4326 | HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4327 | ParamAttrs), (yyval.TypeVal).S)); |
| 4328 | delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4329 | delete (yyvsp[-1].TypeList); // Delete the argument list |
| 4330 | ;} |
| 4331 | break; |
| 4332 | |
| 4333 | case 132: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4334 | #line 2097 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4335 | { // Sized array type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4336 | (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4337 | (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] | 4338 | (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4339 | delete (yyvsp[-1].TypeVal).PAT; |
| 4340 | ;} |
| 4341 | break; |
| 4342 | |
| 4343 | case 133: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4344 | #line 2103 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4345 | { // Vector type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4346 | const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get(); |
| 4347 | if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) |
| 4348 | error("Unsigned result not equal to signed result"); |
| 4349 | if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint())) |
| 4350 | error("Elements of a VectorType must be integer or floating point"); |
| 4351 | if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) |
| 4352 | error("VectorType length should be a power of 2"); |
| 4353 | (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
| 4354 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, |
| 4355 | (unsigned)(yyvsp[-3].UInt64Val)), (yyval.TypeVal).S)); |
| 4356 | delete (yyvsp[-1].TypeVal).PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4357 | ;} |
| 4358 | break; |
| 4359 | |
| 4360 | case 134: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4361 | #line 2116 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4362 | { // Structure type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4363 | std::vector<const Type*> Elements; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4364 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4365 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(), |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4366 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4367 | Elements.push_back(I->PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4368 | (yyval.TypeVal).S.add(I->S); |
| 4369 | } |
| 4370 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4371 | delete (yyvsp[-1].TypeList); |
| 4372 | ;} |
| 4373 | break; |
| 4374 | |
| 4375 | case 135: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4376 | #line 2127 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4377 | { // Empty structure type? |
| 4378 | (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4379 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4380 | ;} |
| 4381 | break; |
| 4382 | |
| 4383 | case 136: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4384 | #line 2131 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4385 | { // Packed Structure type? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4386 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4387 | std::vector<const Type*> Elements; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4388 | for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[-2].TypeList)->begin(), |
| 4389 | E = (yyvsp[-2].TypeList)->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4390 | Elements.push_back(I->PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4391 | (yyval.TypeVal).S.add(I->S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4392 | delete I->PAT; |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4393 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4394 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true), |
| 4395 | (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4396 | delete (yyvsp[-2].TypeList); |
| 4397 | ;} |
| 4398 | break; |
| 4399 | |
| 4400 | case 137: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4401 | #line 2144 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4402 | { // Empty packed structure type? |
| 4403 | (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4404 | (yyval.TypeVal).S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4405 | ;} |
| 4406 | break; |
| 4407 | |
| 4408 | case 138: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4409 | #line 2148 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4410 | { // Pointer type? |
| 4411 | if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4412 | error("Cannot form a pointer to a basic block"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4413 | (yyval.TypeVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
| 4414 | (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get()), |
| 4415 | (yyval.TypeVal).S)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4416 | delete (yyvsp[-1].TypeVal).PAT; |
| 4417 | ;} |
| 4418 | break; |
| 4419 | |
| 4420 | case 139: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4421 | #line 2162 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4422 | { |
| 4423 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
| 4424 | (yyval.TypeList)->push_back((yyvsp[0].TypeVal)); |
| 4425 | ;} |
| 4426 | break; |
| 4427 | |
| 4428 | case 140: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4429 | #line 2166 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4430 | { |
| 4431 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal)); |
| 4432 | ;} |
| 4433 | break; |
| 4434 | |
| 4435 | case 142: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4436 | #line 2174 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4437 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4438 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4439 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4440 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4441 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI); |
| 4442 | ;} |
| 4443 | break; |
| 4444 | |
| 4445 | case 143: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4446 | #line 2180 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4447 | { |
| 4448 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4449 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4450 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4451 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4452 | (yyval.TypeList)->push_back(VoidTI); |
| 4453 | ;} |
| 4454 | break; |
| 4455 | |
| 4456 | case 144: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4457 | #line 2187 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4458 | { |
| 4459 | (yyval.TypeList) = new std::list<PATypeInfo>(); |
| 4460 | ;} |
| 4461 | break; |
| 4462 | |
| 4463 | case 145: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4464 | #line 2199 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4465 | { // Nonempty unsized arr |
| 4466 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4467 | if (ATy == 0) |
| 4468 | error("Cannot make array constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4469 | (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4470 | const Type *ETy = ATy->getElementType(); |
| 4471 | int NumElements = ATy->getNumElements(); |
| 4472 | |
| 4473 | // Verify that we have the correct size... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4474 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4475 | error("Type mismatch: constant sized array initialized with " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4476 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4477 | itostr(NumElements) + ""); |
| 4478 | |
| 4479 | // Verify all elements are correct type! |
| 4480 | std::vector<Constant*> Elems; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4481 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4482 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4483 | const Type* ValTy = C->getType(); |
| 4484 | if (ETy != ValTy) |
| 4485 | error("Element #" + utostr(i) + " is not of type '" + |
| 4486 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4487 | ValTy->getDescription() + "'"); |
| 4488 | Elems.push_back(C); |
| 4489 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4490 | (yyval.ConstVal).C = ConstantArray::get(ATy, Elems); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4491 | (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4492 | delete (yyvsp[-3].TypeVal).PAT; |
| 4493 | delete (yyvsp[-1].ConstVector); |
| 4494 | ;} |
| 4495 | break; |
| 4496 | |
| 4497 | case 146: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4498 | #line 2229 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4499 | { |
| 4500 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4501 | if (ATy == 0) |
| 4502 | error("Cannot make array constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4503 | (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4504 | int NumElements = ATy->getNumElements(); |
| 4505 | if (NumElements != -1 && NumElements != 0) |
| 4506 | error("Type mismatch: constant sized array initialized with 0" |
| 4507 | " arguments, but has size of " + itostr(NumElements) +""); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4508 | (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4509 | (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4510 | delete (yyvsp[-2].TypeVal).PAT; |
| 4511 | ;} |
| 4512 | break; |
| 4513 | |
| 4514 | case 147: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4515 | #line 2242 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4516 | { |
| 4517 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4518 | if (ATy == 0) |
| 4519 | error("Cannot make array constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4520 | (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4521 | int NumElements = ATy->getNumElements(); |
| 4522 | const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType()); |
| 4523 | if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8) |
| 4524 | error("String arrays require type i8, not '" + ETy->getDescription() + |
| 4525 | "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4526 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4527 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4528 | error("Can't build string constant of size " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4529 | itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4530 | itostr(NumElements) + ""); |
| 4531 | std::vector<Constant*> Vals; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4532 | for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4533 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4534 | free((yyvsp[0].StrVal)); |
| 4535 | (yyval.ConstVal).C = ConstantArray::get(ATy, Vals); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4536 | (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4537 | delete (yyvsp[-2].TypeVal).PAT; |
| 4538 | ;} |
| 4539 | break; |
| 4540 | |
| 4541 | case 148: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4542 | #line 2265 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4543 | { // Nonempty unsized arr |
| 4544 | const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4545 | if (PTy == 0) |
| 4546 | error("Cannot make packed constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4547 | (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4548 | const Type *ETy = PTy->getElementType(); |
| 4549 | int NumElements = PTy->getNumElements(); |
| 4550 | // Verify that we have the correct size... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4551 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4552 | error("Type mismatch: constant sized packed initialized with " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4553 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4554 | itostr(NumElements) + ""); |
| 4555 | // Verify all elements are correct type! |
| 4556 | std::vector<Constant*> Elems; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4557 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4558 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4559 | const Type* ValTy = C->getType(); |
| 4560 | if (ETy != ValTy) |
| 4561 | error("Element #" + utostr(i) + " is not of type '" + |
| 4562 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4563 | ValTy->getDescription() + "'"); |
| 4564 | Elems.push_back(C); |
| 4565 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4566 | (yyval.ConstVal).C = ConstantVector::get(PTy, Elems); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4567 | (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4568 | delete (yyvsp[-3].TypeVal).PAT; |
| 4569 | delete (yyvsp[-1].ConstVector); |
| 4570 | ;} |
| 4571 | break; |
| 4572 | |
| 4573 | case 149: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4574 | #line 2293 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4575 | { |
| 4576 | const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4577 | if (STy == 0) |
| 4578 | error("Cannot make struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4579 | (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); |
| 4580 | if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4581 | error("Illegal number of initializers for structure type"); |
| 4582 | |
| 4583 | // Check to ensure that constants are compatible with the type initializer! |
| 4584 | std::vector<Constant*> Fields; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4585 | for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) { |
| 4586 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4587 | if (C->getType() != STy->getElementType(i)) |
| 4588 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4589 | "' for element #" + utostr(i) + " of structure initializer"); |
| 4590 | Fields.push_back(C); |
| 4591 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4592 | (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4593 | (yyval.ConstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4594 | delete (yyvsp[-3].TypeVal).PAT; |
| 4595 | delete (yyvsp[-1].ConstVector); |
| 4596 | ;} |
| 4597 | break; |
| 4598 | |
| 4599 | case 150: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4600 | #line 2315 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4601 | { |
| 4602 | const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4603 | if (STy == 0) |
| 4604 | error("Cannot make struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4605 | (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4606 | if (STy->getNumContainedTypes() != 0) |
| 4607 | error("Illegal number of initializers for structure type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4608 | (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4609 | (yyval.ConstVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4610 | delete (yyvsp[-2].TypeVal).PAT; |
| 4611 | ;} |
| 4612 | break; |
| 4613 | |
| 4614 | case 151: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4615 | #line 2326 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4616 | { |
| 4617 | const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4618 | if (STy == 0) |
| 4619 | error("Cannot make packed struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4620 | (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'"); |
| 4621 | if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4622 | error("Illegal number of initializers for packed structure type"); |
| 4623 | |
| 4624 | // Check to ensure that constants are compatible with the type initializer! |
| 4625 | std::vector<Constant*> Fields; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4626 | for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) { |
| 4627 | Constant *C = (*(yyvsp[-2].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4628 | if (C->getType() != STy->getElementType(i)) |
| 4629 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4630 | "' for element #" + utostr(i) + " of packed struct initializer"); |
| 4631 | Fields.push_back(C); |
| 4632 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4633 | (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4634 | (yyval.ConstVal).S.copy((yyvsp[-5].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4635 | delete (yyvsp[-5].TypeVal).PAT; |
| 4636 | delete (yyvsp[-2].ConstVector); |
| 4637 | ;} |
| 4638 | break; |
| 4639 | |
| 4640 | case 152: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4641 | #line 2348 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4642 | { |
| 4643 | const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4644 | if (STy == 0) |
| 4645 | error("Cannot make packed struct constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4646 | (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4647 | if (STy->getNumContainedTypes() != 0) |
| 4648 | error("Illegal number of initializers for packed structure type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4649 | (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4650 | (yyval.ConstVal).S.copy((yyvsp[-4].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4651 | delete (yyvsp[-4].TypeVal).PAT; |
| 4652 | ;} |
| 4653 | break; |
| 4654 | |
| 4655 | case 153: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4656 | #line 2359 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4657 | { |
| 4658 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4659 | if (PTy == 0) |
| 4660 | error("Cannot make null pointer constant with type: '" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4661 | (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'"); |
| 4662 | (yyval.ConstVal).C = ConstantPointerNull::get(PTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4663 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4664 | delete (yyvsp[-1].TypeVal).PAT; |
| 4665 | ;} |
| 4666 | break; |
| 4667 | |
| 4668 | case 154: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4669 | #line 2368 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4670 | { |
| 4671 | (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4672 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4673 | delete (yyvsp[-1].TypeVal).PAT; |
| 4674 | ;} |
| 4675 | break; |
| 4676 | |
| 4677 | case 155: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4678 | #line 2373 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4679 | { |
| 4680 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4681 | if (Ty == 0) |
| 4682 | error("Global const reference must be a pointer type, not" + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4683 | (yyvsp[-1].TypeVal).PAT->get()->getDescription()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4684 | |
| 4685 | // ConstExprs can exist in the body of a function, thus creating |
| 4686 | // GlobalValues whenever they refer to a variable. Because we are in |
| 4687 | // the context of a function, getExistingValue will search the functions |
| 4688 | // symbol table instead of the module symbol table for the global symbol, |
| 4689 | // which throws things all off. To get around this, we just tell |
| 4690 | // getExistingValue that we are at global scope here. |
| 4691 | // |
| 4692 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 4693 | CurFun.CurrentFunction = 0; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4694 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4695 | Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4696 | CurFun.CurrentFunction = SavedCurFn; |
| 4697 | |
| 4698 | // If this is an initializer for a constant pointer, which is referencing a |
| 4699 | // (currently) undefined variable, create a stub now that shall be replaced |
| 4700 | // in the future with the right type of variable. |
| 4701 | // |
| 4702 | if (V == 0) { |
| 4703 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers"); |
| 4704 | const PointerType *PT = cast<PointerType>(Ty); |
| 4705 | |
| 4706 | // First check to see if the forward references value is already created! |
| 4707 | PerModuleInfo::GlobalRefsType::iterator I = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4708 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4709 | |
| 4710 | if (I != CurModule.GlobalRefs.end()) { |
| 4711 | V = I->second; // Placeholder already exists, use it... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4712 | (yyvsp[0].ValIDVal).destroy(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4713 | } else { |
| 4714 | std::string Name; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4715 | if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4716 | |
| 4717 | // Create the forward referenced global. |
| 4718 | GlobalValue *GV; |
| 4719 | if (const FunctionType *FTy = |
| 4720 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 4721 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 4722 | CurModule.CurrentModule); |
| 4723 | } else { |
| 4724 | GV = new GlobalVariable(PT->getElementType(), false, |
| 4725 | GlobalValue::ExternalLinkage, 0, |
| 4726 | Name, CurModule.CurrentModule); |
| 4727 | } |
| 4728 | |
| 4729 | // 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] | 4730 | 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] | 4731 | V = GV; |
| 4732 | } |
| 4733 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4734 | (yyval.ConstVal).C = cast<GlobalValue>(V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4735 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4736 | delete (yyvsp[-1].TypeVal).PAT; // Free the type handle |
| 4737 | ;} |
| 4738 | break; |
| 4739 | |
| 4740 | case 156: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4741 | #line 2432 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4742 | { |
| 4743 | if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4744 | error("Mismatched types for constant expression"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4745 | (yyval.ConstVal) = (yyvsp[0].ConstVal); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4746 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4747 | delete (yyvsp[-1].TypeVal).PAT; |
| 4748 | ;} |
| 4749 | break; |
| 4750 | |
| 4751 | case 157: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4752 | #line 2439 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4753 | { |
| 4754 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4755 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 4756 | error("Cannot create a null initialized value of this type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4757 | (yyval.ConstVal).C = Constant::getNullValue(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4758 | (yyval.ConstVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4759 | delete (yyvsp[-1].TypeVal).PAT; |
| 4760 | ;} |
| 4761 | break; |
| 4762 | |
| 4763 | case 158: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4764 | #line 2447 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4765 | { // integral constants |
| 4766 | const Type *Ty = (yyvsp[-1].PrimType).T; |
| 4767 | if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4768 | error("Constant value doesn't fit in type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4769 | (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4770 | (yyval.ConstVal).S.makeSigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4771 | ;} |
| 4772 | break; |
| 4773 | |
| 4774 | case 159: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4775 | #line 2454 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4776 | { // integral constants |
| 4777 | const Type *Ty = (yyvsp[-1].PrimType).T; |
| 4778 | if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4779 | error("Constant value doesn't fit in type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4780 | (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4781 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4782 | ;} |
| 4783 | break; |
| 4784 | |
| 4785 | case 160: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4786 | #line 2461 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4787 | { // Boolean constants |
| 4788 | (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4789 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4790 | ;} |
| 4791 | break; |
| 4792 | |
| 4793 | case 161: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4794 | #line 2465 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4795 | { // Boolean constants |
| 4796 | (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4797 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4798 | ;} |
| 4799 | break; |
| 4800 | |
| 4801 | case 162: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4802 | #line 2469 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4803 | { // Float & Double constants |
| 4804 | if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal))) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4805 | error("Floating point constant invalid for type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4806 | (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4807 | (yyval.ConstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4808 | ;} |
| 4809 | break; |
| 4810 | |
| 4811 | case 163: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4812 | #line 2478 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4813 | { |
| 4814 | const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType(); |
| 4815 | const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4816 | Signedness SrcSign((yyvsp[-3].ConstVal).S); |
| 4817 | Signedness DstSign((yyvsp[-1].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4818 | if (!SrcTy->isFirstClassType()) |
| 4819 | error("cast constant expression from a non-primitive type: '" + |
| 4820 | SrcTy->getDescription() + "'"); |
| 4821 | if (!DstTy->isFirstClassType()) |
| 4822 | error("cast constant expression to a non-primitive type: '" + |
| 4823 | DstTy->getDescription() + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4824 | (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] | 4825 | (yyval.ConstVal).S.copy(DstSign); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4826 | delete (yyvsp[-1].TypeVal).PAT; |
| 4827 | ;} |
| 4828 | break; |
| 4829 | |
| 4830 | case 164: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4831 | #line 2493 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4832 | { |
| 4833 | const Type *Ty = (yyvsp[-2].ConstVal).C->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4834 | if (!isa<PointerType>(Ty)) |
| 4835 | error("GetElementPtr requires a pointer operand"); |
| 4836 | |
| 4837 | std::vector<Value*> VIndices; |
| 4838 | std::vector<Constant*> CIndices; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4839 | upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4840 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4841 | delete (yyvsp[-1].ValueList); |
| 4842 | (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] | 4843 | (yyval.ConstVal).S.copy(getElementSign((yyvsp[-2].ConstVal), CIndices)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4844 | ;} |
| 4845 | break; |
| 4846 | |
| 4847 | case 165: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4848 | #line 2506 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4849 | { |
| 4850 | if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() || |
| 4851 | cast<IntegerType>((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4852 | error("Select condition must be bool type"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4853 | if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4854 | error("Select operand types must match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4855 | (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] | 4856 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4857 | ;} |
| 4858 | break; |
| 4859 | |
| 4860 | case 166: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4861 | #line 2515 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4862 | { |
| 4863 | const Type *Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4864 | if (Ty != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4865 | error("Binary operator types must match"); |
| 4866 | // First, make sure we're dealing with the right opcode by upgrading from |
| 4867 | // obsolete versions. |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4868 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4869 | |
| 4870 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 4871 | // To retain backward compatibility with these early compilers, we emit a |
| 4872 | // cast to the appropriate integer type automatically if we are in the |
| 4873 | // broken case. See PR424 for more information. |
| 4874 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4875 | (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] | 4876 | } else { |
| 4877 | const Type *IntPtrTy = 0; |
| 4878 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 4879 | case Module::Pointer32: IntPtrTy = Type::Int32Ty; break; |
| 4880 | case Module::Pointer64: IntPtrTy = Type::Int64Ty; break; |
| 4881 | default: error("invalid pointer binary constant expr"); |
| 4882 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4883 | (yyval.ConstVal).C = ConstantExpr::get(Opcode, |
| 4884 | ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy), |
| 4885 | ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy)); |
| 4886 | (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4887 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4888 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4889 | ;} |
| 4890 | break; |
| 4891 | |
| 4892 | case 167: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4893 | #line 2543 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4894 | { |
| 4895 | const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4896 | if (Ty != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4897 | error("Logical operator types must match"); |
| 4898 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4899 | if (!isa<VectorType>(Ty) || |
| 4900 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4901 | error("Logical operator requires integer operands"); |
| 4902 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4903 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S); |
| 4904 | (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] | 4905 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4906 | ;} |
| 4907 | break; |
| 4908 | |
| 4909 | case 168: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4910 | #line 2556 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4911 | { |
| 4912 | const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4913 | if (Ty != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4914 | error("setcc operand types must match"); |
| 4915 | unsigned short pred; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4916 | Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S); |
| 4917 | (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] | 4918 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4919 | ;} |
| 4920 | break; |
| 4921 | |
| 4922 | case 169: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4923 | #line 2565 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4924 | { |
| 4925 | if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4926 | error("icmp operand types must match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4927 | (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] | 4928 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4929 | ;} |
| 4930 | break; |
| 4931 | |
| 4932 | case 170: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4933 | #line 2571 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4934 | { |
| 4935 | if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4936 | error("fcmp operand types must match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4937 | (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] | 4938 | (yyval.ConstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4939 | ;} |
| 4940 | break; |
| 4941 | |
| 4942 | case 171: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4943 | #line 2577 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4944 | { |
| 4945 | if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() || |
| 4946 | cast<IntegerType>((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4947 | error("Shift count for shift constant must be unsigned byte"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4948 | const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); |
| 4949 | if (!(yyvsp[-3].ConstVal).C->getType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4950 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4951 | Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty); |
| 4952 | (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] | 4953 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4954 | ;} |
| 4955 | break; |
| 4956 | |
| 4957 | case 172: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4958 | #line 2588 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4959 | { |
| 4960 | if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4961 | error("Invalid extractelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4962 | (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] | 4963 | (yyval.ConstVal).S.copy((yyvsp[-3].ConstVal).S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4964 | ;} |
| 4965 | break; |
| 4966 | |
| 4967 | case 173: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4968 | #line 2594 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4969 | { |
| 4970 | 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] | 4971 | error("Invalid insertelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4972 | (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] | 4973 | (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4974 | ;} |
| 4975 | break; |
| 4976 | |
| 4977 | case 174: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4978 | #line 2600 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4979 | { |
| 4980 | 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] | 4981 | error("Invalid shufflevector operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4982 | (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] | 4983 | (yyval.ConstVal).S.copy((yyvsp[-5].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4984 | ;} |
| 4985 | break; |
| 4986 | |
| 4987 | case 175: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4988 | #line 2611 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4989 | { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;} |
| 4990 | break; |
| 4991 | |
| 4992 | case 176: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 4993 | #line 2612 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4994 | { |
| 4995 | (yyval.ConstVector) = new std::vector<ConstInfo>(); |
| 4996 | (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); |
| 4997 | ;} |
| 4998 | break; |
| 4999 | |
| 5000 | case 177: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5001 | #line 2621 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5002 | { (yyval.BoolVal) = false; ;} |
| 5003 | break; |
| 5004 | |
| 5005 | case 178: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5006 | #line 2622 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5007 | { (yyval.BoolVal) = true; ;} |
| 5008 | break; |
| 5009 | |
| 5010 | case 179: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5011 | #line 2634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5012 | { |
| 5013 | (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5014 | CurModule.ModuleDone(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5015 | ;} |
| 5016 | break; |
| 5017 | |
| 5018 | case 180: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5019 | #line 2643 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5020 | { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;} |
| 5021 | break; |
| 5022 | |
| 5023 | case 181: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5024 | #line 2644 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5025 | { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;} |
| 5026 | break; |
| 5027 | |
| 5028 | case 182: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5029 | #line 2645 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5030 | { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;} |
| 5031 | break; |
| 5032 | |
| 5033 | case 183: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5034 | #line 2646 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5035 | { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;} |
| 5036 | break; |
| 5037 | |
| 5038 | case 184: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5039 | #line 2647 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5040 | { |
| 5041 | (yyval.ModuleVal) = CurModule.CurrentModule; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5042 | // Emit an error if there are any unresolved types left. |
| 5043 | if (!CurModule.LateResolveTypes.empty()) { |
| 5044 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 5045 | if (DID.Type == ValID::NameVal) { |
| 5046 | error("Reference to an undefined type: '"+DID.getName() + "'"); |
| 5047 | } else { |
| 5048 | error("Reference to an undefined type: #" + itostr(DID.Num)); |
| 5049 | } |
| 5050 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5051 | ;} |
| 5052 | break; |
| 5053 | |
| 5054 | case 185: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5055 | #line 2663 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5056 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5057 | // Eagerly resolve types. This is not an optimization, this is a |
| 5058 | // requirement that is due to the fact that we could have this: |
| 5059 | // |
| 5060 | // %list = type { %list * } |
| 5061 | // %list = type { %list * } ; repeated type decl |
| 5062 | // |
| 5063 | // If types are not resolved eagerly, then the two types will not be |
| 5064 | // determined to be the same type! |
| 5065 | // |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5066 | 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] | 5067 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5068 | if (!setTypeName((yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
| 5069 | // If this is a numbered type that is not a redefinition, add it to the |
| 5070 | // slot table. |
| 5071 | CurModule.Types.push_back((yyvsp[0].TypeVal).PAT->get()); |
| 5072 | CurModule.TypeSigns.push_back((yyvsp[0].TypeVal).S); |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 5073 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5074 | delete (yyvsp[0].TypeVal).PAT; |
| 5075 | ;} |
| 5076 | break; |
| 5077 | |
| 5078 | case 186: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5079 | #line 2683 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5080 | { // Function prototypes can be in const pool |
| 5081 | ;} |
| 5082 | break; |
| 5083 | |
| 5084 | case 187: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5085 | #line 2685 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5086 | { // Asm blocks can be in the const pool |
| 5087 | ;} |
| 5088 | break; |
| 5089 | |
| 5090 | case 188: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5091 | #line 2687 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5092 | { |
| 5093 | if ((yyvsp[0].ConstVal).C == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5094 | error("Global value initializer is not a constant"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5095 | 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] | 5096 | ;} |
| 5097 | break; |
| 5098 | |
| 5099 | case 189: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5100 | #line 2691 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5101 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5102 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5103 | ;} |
| 5104 | break; |
| 5105 | |
| 5106 | case 190: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5107 | #line 2694 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5108 | { |
| 5109 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5110 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0, |
| 5111 | (yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5112 | delete (yyvsp[0].TypeVal).PAT; |
| 5113 | ;} |
| 5114 | break; |
| 5115 | |
| 5116 | case 191: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5117 | #line 2699 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5118 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5119 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5120 | ;} |
| 5121 | break; |
| 5122 | |
| 5123 | case 192: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5124 | #line 2702 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5125 | { |
| 5126 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5127 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0, |
| 5128 | (yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5129 | delete (yyvsp[0].TypeVal).PAT; |
| 5130 | ;} |
| 5131 | break; |
| 5132 | |
| 5133 | case 193: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5134 | #line 2707 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5135 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5136 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5137 | ;} |
| 5138 | break; |
| 5139 | |
| 5140 | case 194: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5141 | #line 2710 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5142 | { |
| 5143 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5144 | CurGV = |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5145 | ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0, |
| 5146 | (yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5147 | delete (yyvsp[0].TypeVal).PAT; |
| 5148 | ;} |
| 5149 | break; |
| 5150 | |
| 5151 | case 195: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5152 | #line 2716 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5153 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5154 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5155 | ;} |
| 5156 | break; |
| 5157 | |
| 5158 | case 196: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5159 | #line 2719 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5160 | { |
| 5161 | ;} |
| 5162 | break; |
| 5163 | |
| 5164 | case 197: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5165 | #line 2721 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5166 | { |
| 5167 | ;} |
| 5168 | break; |
| 5169 | |
| 5170 | case 198: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5171 | #line 2723 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5172 | { |
| 5173 | ;} |
| 5174 | break; |
| 5175 | |
| 5176 | case 199: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5177 | #line 2728 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5178 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5179 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5180 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 5181 | std::string NewAsm((yyvsp[0].StrVal), EndStr); |
| 5182 | free((yyvsp[0].StrVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5183 | |
| 5184 | if (AsmSoFar.empty()) |
| 5185 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 5186 | else |
| 5187 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5188 | ;} |
| 5189 | break; |
| 5190 | |
| 5191 | case 200: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5192 | #line 2742 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5193 | { (yyval.Endianness) = Module::BigEndian; ;} |
| 5194 | break; |
| 5195 | |
| 5196 | case 201: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5197 | #line 2743 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5198 | { (yyval.Endianness) = Module::LittleEndian; ;} |
| 5199 | break; |
| 5200 | |
| 5201 | case 202: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5202 | #line 2747 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5203 | { |
| 5204 | CurModule.setEndianness((yyvsp[0].Endianness)); |
| 5205 | ;} |
| 5206 | break; |
| 5207 | |
| 5208 | case 203: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5209 | #line 2750 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5210 | { |
| 5211 | if ((yyvsp[0].UInt64Val) == 32) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5212 | CurModule.setPointerSize(Module::Pointer32); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5213 | else if ((yyvsp[0].UInt64Val) == 64) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5214 | CurModule.setPointerSize(Module::Pointer64); |
| 5215 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5216 | error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'"); |
| 5217 | ;} |
| 5218 | break; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5219 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5220 | case 204: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5221 | #line 2758 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5222 | { |
| 5223 | CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); |
| 5224 | free((yyvsp[0].StrVal)); |
| 5225 | ;} |
| 5226 | break; |
| 5227 | |
| 5228 | case 205: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5229 | #line 2762 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5230 | { |
| 5231 | CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); |
| 5232 | free((yyvsp[0].StrVal)); |
| 5233 | ;} |
| 5234 | break; |
| 5235 | |
| 5236 | case 207: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5237 | #line 2773 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5238 | { |
| 5239 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 5240 | free((yyvsp[0].StrVal)); |
| 5241 | ;} |
| 5242 | break; |
| 5243 | |
| 5244 | case 208: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5245 | #line 2777 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5246 | { |
| 5247 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 5248 | free((yyvsp[0].StrVal)); |
| 5249 | ;} |
| 5250 | break; |
| 5251 | |
| 5252 | case 209: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5253 | #line 2781 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5254 | { ;} |
| 5255 | break; |
| 5256 | |
| 5257 | case 213: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5258 | #line 2794 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5259 | { (yyval.StrVal) = 0; ;} |
| 5260 | break; |
| 5261 | |
| 5262 | case 214: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5263 | #line 2798 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5264 | { |
| 5265 | if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy) |
| 5266 | error("void typed arguments are invalid"); |
| 5267 | (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal)); |
| 5268 | ;} |
| 5269 | break; |
| 5270 | |
| 5271 | case 215: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5272 | #line 2806 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5273 | { |
| 5274 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 5275 | (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 5276 | delete (yyvsp[0].ArgVal); |
| 5277 | ;} |
| 5278 | break; |
| 5279 | |
| 5280 | case 216: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5281 | #line 2811 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5282 | { |
| 5283 | (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5284 | (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 5285 | delete (yyvsp[0].ArgVal); |
| 5286 | ;} |
| 5287 | break; |
| 5288 | |
| 5289 | case 217: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5290 | #line 2819 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5291 | { (yyval.ArgList) = (yyvsp[0].ArgList); ;} |
| 5292 | break; |
| 5293 | |
| 5294 | case 218: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5295 | #line 2820 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5296 | { |
| 5297 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 5298 | PATypeInfo VoidTI; |
| 5299 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5300 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5301 | (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 5302 | ;} |
| 5303 | break; |
| 5304 | |
| 5305 | case 219: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5306 | #line 2827 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5307 | { |
| 5308 | (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5309 | PATypeInfo VoidTI; |
| 5310 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5311 | VoidTI.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5312 | (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 5313 | ;} |
| 5314 | break; |
| 5315 | |
| 5316 | case 220: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5317 | #line 2834 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5318 | { (yyval.ArgList) = 0; ;} |
| 5319 | break; |
| 5320 | |
| 5321 | case 221: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5322 | #line 2838 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5323 | { |
| 5324 | UnEscapeLexed((yyvsp[-5].StrVal)); |
| 5325 | std::string FunctionName((yyvsp[-5].StrVal)); |
| 5326 | free((yyvsp[-5].StrVal)); // Free strdup'd memory! |
| 5327 | |
| 5328 | const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5329 | |
| 5330 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 5331 | error("LLVM functions cannot return aggregate types"); |
| 5332 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5333 | Signedness FTySign; |
| 5334 | FTySign.makeComposite((yyvsp[-6].TypeVal).S); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5335 | std::vector<const Type*> ParamTyList; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5336 | |
| 5337 | // In LLVM 2.0 the signatures of three varargs intrinsics changed to take |
| 5338 | // i8*. We check here for those names and override the parameter list |
| 5339 | // types to ensure the prototype is correct. |
| 5340 | if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5341 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5342 | } else if (FunctionName == "llvm.va_copy") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5343 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
| 5344 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5345 | } else if ((yyvsp[-3].ArgList)) { // If there are arguments... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5346 | for (std::vector<std::pair<PATypeInfo,char*> >::iterator |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5347 | 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] | 5348 | const Type *Ty = I->first.PAT->get(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5349 | ParamTyList.push_back(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5350 | FTySign.add(I->first.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5351 | } |
| 5352 | } |
| 5353 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5354 | bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy; |
| 5355 | if (isVarArg) |
| 5356 | ParamTyList.pop_back(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5357 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5358 | // Convert the CSRet calling convention into the corresponding parameter |
| 5359 | // attribute. |
| 5360 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5361 | if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) { |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5362 | ParamAttrs.push_back(FunctionType::NoAttributeSet); // result |
| 5363 | ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg |
| 5364 | } |
| 5365 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5366 | const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg, |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5367 | ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5368 | const PointerType *PFT = PointerType::get(FT); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5369 | delete (yyvsp[-6].TypeVal).PAT; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5370 | |
| 5371 | ValID ID; |
| 5372 | if (!FunctionName.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5373 | ID = ValID::create((char*)FunctionName.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5374 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5375 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5376 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5377 | ID.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5378 | |
| 5379 | Function *Fn = 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5380 | Module* M = CurModule.CurrentModule; |
| 5381 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5382 | // See if this function was forward referenced. If so, recycle the object. |
| 5383 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 5384 | // Move the function to the end of the list, from whereever it was |
| 5385 | // previously inserted. |
| 5386 | Fn = cast<Function>(FWRef); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5387 | M->getFunctionList().remove(Fn); |
| 5388 | M->getFunctionList().push_back(Fn); |
| 5389 | } else if (!FunctionName.empty()) { |
| 5390 | GlobalValue *Conflict = M->getFunction(FunctionName); |
| 5391 | if (!Conflict) |
| 5392 | Conflict = M->getNamedGlobal(FunctionName); |
| 5393 | if (Conflict && PFT == Conflict->getType()) { |
| 5394 | if (!CurFun.isDeclare && !Conflict->isDeclaration()) { |
| 5395 | // We have two function definitions that conflict, same type, same |
| 5396 | // name. We should really check to make sure that this is the result |
| 5397 | // of integer type planes collapsing and generate an error if it is |
| 5398 | // not, but we'll just rename on the assumption that it is. However, |
| 5399 | // let's do it intelligently and rename the internal linkage one |
| 5400 | // if there is one. |
| 5401 | std::string NewName(makeNameUnique(FunctionName)); |
| 5402 | if (Conflict->hasInternalLinkage()) { |
| 5403 | Conflict->setName(NewName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5404 | RenameMapKey Key = |
| 5405 | makeRenameMapKey(FunctionName, Conflict->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5406 | CurModule.RenameMap[Key] = NewName; |
| 5407 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5408 | InsertValue(Fn, CurModule.Values); |
| 5409 | } else { |
| 5410 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5411 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5412 | RenameMapKey Key = |
| 5413 | makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5414 | CurModule.RenameMap[Key] = NewName; |
| 5415 | } |
| 5416 | } else { |
| 5417 | // If they are not both definitions, then just use the function we |
| 5418 | // found since the types are the same. |
| 5419 | Fn = cast<Function>(Conflict); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5420 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5421 | // Make sure to strip off any argument names so we can't get |
| 5422 | // conflicts. |
| 5423 | if (Fn->isDeclaration()) |
| 5424 | for (Function::arg_iterator AI = Fn->arg_begin(), |
| 5425 | AE = Fn->arg_end(); AI != AE; ++AI) |
| 5426 | AI->setName(""); |
| 5427 | } |
| 5428 | } else if (Conflict) { |
| 5429 | // We have two globals with the same name and different types. |
| 5430 | // Previously, this was permitted because the symbol table had |
| 5431 | // "type planes" and names only needed to be distinct within a |
| 5432 | // type plane. After PR411 was fixed, this is no loner the case. |
| 5433 | // To resolve this we must rename one of the two. |
| 5434 | if (Conflict->hasInternalLinkage()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5435 | // We can safely rename the Conflict. |
| 5436 | RenameMapKey Key = |
| 5437 | makeRenameMapKey(Conflict->getName(), Conflict->getType(), |
| 5438 | CurModule.NamedValueSigns[Conflict->getName()]); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5439 | Conflict->setName(makeNameUnique(Conflict->getName())); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5440 | CurModule.RenameMap[Key] = Conflict->getName(); |
| 5441 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5442 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5443 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5444 | // We can't quietly rename either of these things, but we must |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5445 | // rename one of them. Only if the function's linkage is internal can |
| 5446 | // we forgo a warning message about the renamed function. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5447 | std::string NewName = makeNameUnique(FunctionName); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5448 | if (CurFun.Linkage != GlobalValue::InternalLinkage) { |
| 5449 | warning("Renaming function '" + FunctionName + "' as '" + NewName + |
| 5450 | "' may cause linkage errors"); |
| 5451 | } |
| 5452 | // Elect to rename the thing we're now defining. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5453 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5454 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5455 | RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5456 | CurModule.RenameMap[Key] = NewName; |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5457 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5458 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5459 | // There's no conflict, just define the function |
| 5460 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5461 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5462 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5463 | } |
| 5464 | |
| 5465 | CurFun.FunctionStart(Fn); |
| 5466 | |
| 5467 | if (CurFun.isDeclare) { |
| 5468 | // If we have declaration, always overwrite linkage. This will allow us |
| 5469 | // to correctly handle cases, when pointer to function is passed as |
| 5470 | // argument to another function. |
| 5471 | Fn->setLinkage(CurFun.Linkage); |
| 5472 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5473 | Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal))); |
| 5474 | Fn->setAlignment((yyvsp[0].UIntVal)); |
| 5475 | if ((yyvsp[-1].StrVal)) { |
| 5476 | Fn->setSection((yyvsp[-1].StrVal)); |
| 5477 | free((yyvsp[-1].StrVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5478 | } |
| 5479 | |
| 5480 | // Add all of the arguments we parsed to the function... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5481 | if ((yyvsp[-3].ArgList)) { // Is null if empty... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5482 | if (isVarArg) { // Nuke the last entry |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5483 | assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy && |
| 5484 | (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker"); |
| 5485 | delete (yyvsp[-3].ArgList)->back().first.PAT; |
| 5486 | (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5487 | } |
| 5488 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5489 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5490 | std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); |
| 5491 | std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[-3].ArgList)->end(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5492 | for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5493 | delete I->first.PAT; // Delete the typeholder... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5494 | ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S); |
| 5495 | setValueName(VI, I->second); // Insert arg into symtab... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5496 | InsertValue(ArgIt); |
| 5497 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5498 | delete (yyvsp[-3].ArgList); // We're now done with the argument list |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5499 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5500 | ;} |
| 5501 | break; |
| 5502 | |
| 5503 | case 224: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5504 | #line 3023 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5505 | { CurFun.Linkage = (yyvsp[0].Linkage); ;} |
| 5506 | break; |
| 5507 | |
| 5508 | case 225: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5509 | #line 3023 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5510 | { |
| 5511 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5512 | |
| 5513 | // Make sure that we keep track of the linkage type even if there was a |
| 5514 | // previous "declare". |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5515 | (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5516 | ;} |
| 5517 | break; |
| 5518 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5519 | case 228: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5520 | #line 3037 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5521 | { |
| 5522 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 5523 | ;} |
| 5524 | break; |
| 5525 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5526 | case 229: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5527 | #line 3042 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5528 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 5529 | break; |
| 5530 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5531 | case 230: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5532 | #line 3043 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5533 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 5534 | break; |
| 5535 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5536 | case 231: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5537 | #line 3044 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5538 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 5539 | break; |
| 5540 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5541 | case 232: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5542 | #line 3048 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5543 | { CurFun.isDeclare = true; ;} |
| 5544 | break; |
| 5545 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5546 | case 233: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5547 | #line 3049 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5548 | { CurFun.Linkage = (yyvsp[0].Linkage); ;} |
| 5549 | break; |
| 5550 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5551 | case 234: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5552 | #line 3049 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5553 | { |
| 5554 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5555 | CurFun.FunctionDone(); |
| 5556 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5557 | ;} |
| 5558 | break; |
| 5559 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5560 | case 235: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5561 | #line 3061 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5562 | { (yyval.BoolVal) = false; ;} |
| 5563 | break; |
| 5564 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5565 | case 236: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5566 | #line 3062 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5567 | { (yyval.BoolVal) = true; ;} |
| 5568 | break; |
| 5569 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5570 | case 237: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5571 | #line 3067 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5572 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5573 | break; |
| 5574 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5575 | case 238: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5576 | #line 3068 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5577 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;} |
| 5578 | break; |
| 5579 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5580 | case 239: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5581 | #line 3069 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5582 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;} |
| 5583 | break; |
| 5584 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5585 | case 240: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5586 | #line 3070 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5587 | { |
| 5588 | (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); |
| 5589 | (yyval.ValIDVal).S.makeUnsigned(); |
| 5590 | ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5591 | break; |
| 5592 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5593 | case 241: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5594 | #line 3074 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5595 | { |
| 5596 | (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); |
| 5597 | (yyval.ValIDVal).S.makeUnsigned(); |
| 5598 | ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5599 | break; |
| 5600 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5601 | case 242: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5602 | #line 3078 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5603 | { (yyval.ValIDVal) = ValID::createNull(); ;} |
| 5604 | break; |
| 5605 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5606 | case 243: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5607 | #line 3079 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5608 | { (yyval.ValIDVal) = ValID::createUndef(); ;} |
| 5609 | break; |
| 5610 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5611 | case 244: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5612 | #line 3080 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5613 | { (yyval.ValIDVal) = ValID::createZeroInit(); ;} |
| 5614 | break; |
| 5615 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5616 | case 245: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5617 | #line 3081 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5618 | { // Nonempty unsized packed vector |
| 5619 | const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType(); |
| 5620 | int NumElements = (yyvsp[-1].ConstVector)->size(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5621 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5622 | (yyval.ValIDVal).S.makeComposite((*(yyvsp[-1].ConstVector))[0].S); |
| 5623 | PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5624 | |
| 5625 | // Verify all elements are correct type! |
| 5626 | std::vector<Constant*> Elems; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5627 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 5628 | Constant *C = (*(yyvsp[-1].ConstVector))[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5629 | const Type *CTy = C->getType(); |
| 5630 | if (ETy != CTy) |
| 5631 | error("Element #" + utostr(i) + " is not of type '" + |
| 5632 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 5633 | CTy->getDescription() + "'"); |
| 5634 | Elems.push_back(C); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 5635 | } |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5636 | (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5637 | delete PTy; delete (yyvsp[-1].ConstVector); |
| 5638 | ;} |
| 5639 | break; |
| 5640 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5641 | case 246: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5642 | #line 3102 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5643 | { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5644 | (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5645 | (yyval.ValIDVal).S.copy((yyvsp[0].ConstVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5646 | ;} |
| 5647 | break; |
| 5648 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5649 | case 247: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5650 | #line 3106 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5651 | { |
| 5652 | char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); |
| 5653 | std::string AsmStr = std::string((yyvsp[-2].StrVal), End); |
| 5654 | End = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 5655 | std::string Constraints = std::string((yyvsp[0].StrVal), End); |
| 5656 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); |
| 5657 | free((yyvsp[-2].StrVal)); |
| 5658 | free((yyvsp[0].StrVal)); |
| 5659 | ;} |
| 5660 | break; |
| 5661 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5662 | case 248: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5663 | #line 3120 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5664 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5665 | break; |
| 5666 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5667 | case 249: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5668 | #line 3121 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5669 | { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5670 | break; |
| 5671 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5672 | case 252: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5673 | #line 3134 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5674 | { |
| 5675 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5676 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5677 | (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5678 | (yyval.ValueVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5679 | delete (yyvsp[-1].TypeVal).PAT; |
| 5680 | ;} |
| 5681 | break; |
| 5682 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5683 | case 253: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5684 | #line 3144 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5685 | { |
| 5686 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 5687 | ;} |
| 5688 | break; |
| 5689 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5690 | case 254: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5691 | #line 3147 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5692 | { // Do not allow functions with 0 basic blocks |
| 5693 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 5694 | ;} |
| 5695 | break; |
| 5696 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5697 | case 255: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5698 | #line 3156 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5699 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5700 | ValueInfo VI; VI.V = (yyvsp[0].TermInstVal).TI; VI.S.copy((yyvsp[0].TermInstVal).S); |
| 5701 | setValueName(VI, (yyvsp[-1].StrVal)); |
| 5702 | InsertValue((yyvsp[0].TermInstVal).TI); |
| 5703 | (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal).TI); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5704 | InsertValue((yyvsp[-2].BasicBlockVal)); |
| 5705 | (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); |
| 5706 | ;} |
| 5707 | break; |
| 5708 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5709 | case 256: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5710 | #line 3167 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5711 | { |
| 5712 | if ((yyvsp[0].InstVal).I) |
| 5713 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I); |
| 5714 | (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); |
| 5715 | ;} |
| 5716 | break; |
| 5717 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5718 | case 257: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5719 | #line 3172 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5720 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5721 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5722 | // Make sure to move the basic block to the correct location in the |
| 5723 | // function, instead of leaving it inserted wherever it was first |
| 5724 | // referenced. |
| 5725 | Function::BasicBlockListType &BBL = |
| 5726 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5727 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
| 5728 | ;} |
| 5729 | break; |
| 5730 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5731 | case 258: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5732 | #line 3181 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5733 | { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5734 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5735 | // Make sure to move the basic block to the correct location in the |
| 5736 | // function, instead of leaving it inserted wherever it was first |
| 5737 | // referenced. |
| 5738 | Function::BasicBlockListType &BBL = |
| 5739 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5740 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
| 5741 | ;} |
| 5742 | break; |
| 5743 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5744 | case 261: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5745 | #line 3195 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5746 | { // Return with a result... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5747 | (yyval.TermInstVal).TI = new ReturnInst((yyvsp[0].ValueVal).V); |
| 5748 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5749 | ;} |
| 5750 | break; |
| 5751 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5752 | case 262: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5753 | #line 3199 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5754 | { // Return with no result... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5755 | (yyval.TermInstVal).TI = new ReturnInst(); |
| 5756 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5757 | ;} |
| 5758 | break; |
| 5759 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5760 | case 263: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5761 | #line 3203 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5762 | { // Unconditional Branch... |
| 5763 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5764 | (yyval.TermInstVal).TI = new BranchInst(tmpBB); |
| 5765 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5766 | ;} |
| 5767 | break; |
| 5768 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5769 | case 264: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5770 | #line 3208 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5771 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5772 | (yyvsp[-3].ValIDVal).S.makeSignless(); |
| 5773 | (yyvsp[0].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5774 | BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); |
| 5775 | BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5776 | (yyvsp[-6].ValIDVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5777 | Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5778 | (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 5779 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5780 | ;} |
| 5781 | break; |
| 5782 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5783 | case 265: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5784 | #line 3218 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5785 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5786 | (yyvsp[-6].ValIDVal).S.copy((yyvsp[-7].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5787 | Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5788 | (yyvsp[-3].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5789 | BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); |
| 5790 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5791 | (yyval.TermInstVal).TI = S; |
| 5792 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5793 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), |
| 5794 | E = (yyvsp[-1].JumpTable)->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5795 | for (; I != E; ++I) { |
| 5796 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 5797 | S->addCase(CI, I->second); |
| 5798 | else |
| 5799 | error("Switch case is constant, but not a simple integer"); |
| 5800 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5801 | delete (yyvsp[-1].JumpTable); |
| 5802 | ;} |
| 5803 | break; |
| 5804 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5805 | case 266: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5806 | #line 3236 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5807 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5808 | (yyvsp[-5].ValIDVal).S.copy((yyvsp[-6].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5809 | Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5810 | (yyvsp[-2].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5811 | BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5812 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5813 | (yyval.TermInstVal).TI = S; |
| 5814 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5815 | ;} |
| 5816 | break; |
| 5817 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5818 | case 267: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5819 | #line 3246 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5820 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5821 | const PointerType *PFTy; |
| 5822 | const FunctionType *Ty; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5823 | Signedness FTySign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5824 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5825 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5826 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5827 | // Pull out the types of all of the arguments... |
| 5828 | std::vector<const Type*> ParamTypes; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5829 | FTySign.makeComposite((yyvsp[-10].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5830 | if ((yyvsp[-7].ValueList)) { |
| 5831 | 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] | 5832 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5833 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5834 | FTySign.add(I->S); |
| 5835 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5836 | } |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5837 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5838 | if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) { |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5839 | ParamAttrs.push_back(FunctionType::NoAttributeSet); |
| 5840 | ParamAttrs.push_back(FunctionType::StructRetAttribute); |
| 5841 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5842 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5843 | if (isVarArg) ParamTypes.pop_back(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5844 | Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5845 | PFTy = PointerType::get(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5846 | (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S); |
| 5847 | } else { |
| 5848 | FTySign = (yyvsp[-10].TypeVal).S; |
| 5849 | (yyval.TermInstVal).S.copy((yyvsp[-10].TypeVal).S.get(0)); // 0th element of FuncTy sign is result ty |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5850 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5851 | (yyvsp[-9].ValIDVal).S.makeComposite(FTySign); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5852 | Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling... |
| 5853 | BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); |
| 5854 | BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5855 | |
| 5856 | // Create the call node... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5857 | if (!(yyvsp[-7].ValueList)) { // Has no arguments? |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5858 | (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, 0, 0); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5859 | } else { // Has arguments? |
| 5860 | // Loop through FunctionType's arguments and ensure they are specified |
| 5861 | // correctly! |
| 5862 | // |
| 5863 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5864 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5865 | 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] | 5866 | |
| 5867 | std::vector<Value*> Args; |
| 5868 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5869 | if ((*ArgI).V->getType() != *I) |
| 5870 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 5871 | (*I)->getDescription() + "'"); |
| 5872 | Args.push_back((*ArgI).V); |
| 5873 | } |
| 5874 | |
| 5875 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 5876 | error("Invalid number of parameters detected"); |
| 5877 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5878 | (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5879 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5880 | cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal))); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5881 | delete (yyvsp[-10].TypeVal).PAT; |
| 5882 | delete (yyvsp[-7].ValueList); |
| 5883 | ;} |
| 5884 | break; |
| 5885 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5886 | case 268: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5887 | #line 3310 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5888 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5889 | (yyval.TermInstVal).TI = new UnwindInst(); |
| 5890 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5891 | ;} |
| 5892 | break; |
| 5893 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5894 | case 269: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5895 | #line 3314 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5896 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5897 | (yyval.TermInstVal).TI = new UnreachableInst(); |
| 5898 | (yyval.TermInstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5899 | ;} |
| 5900 | break; |
| 5901 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5902 | case 270: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5903 | #line 3321 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5904 | { |
| 5905 | (yyval.JumpTable) = (yyvsp[-5].JumpTable); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5906 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5907 | Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5908 | |
| 5909 | if (V == 0) |
| 5910 | error("May only switch on a constant pool value"); |
| 5911 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5912 | (yyvsp[0].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5913 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 5914 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5915 | ;} |
| 5916 | break; |
| 5917 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5918 | case 271: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5919 | #line 3333 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5920 | { |
| 5921 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5922 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-4].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5923 | Constant *V = cast<Constant>(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5924 | |
| 5925 | if (V == 0) |
| 5926 | error("May only switch on a constant pool value"); |
| 5927 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5928 | (yyvsp[0].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5929 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 5930 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5931 | ;} |
| 5932 | break; |
| 5933 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5934 | case 272: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5935 | #line 3348 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5936 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5937 | bool omit = false; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5938 | if ((yyvsp[-1].StrVal)) |
| 5939 | if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[0].InstVal).I)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5940 | if (BCI->getSrcTy() == BCI->getDestTy() && |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5941 | BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5942 | // This is a useless bit cast causing a name redefinition. It is |
| 5943 | // a bit cast from a type to the same type of an operand with the |
| 5944 | // same name as the name we would give this instruction. Since this |
| 5945 | // instruction results in no code generation, it is safe to omit |
| 5946 | // the instruction. This situation can occur because of collapsed |
| 5947 | // type planes. For example: |
| 5948 | // %X = add int %Y, %Z |
| 5949 | // %X = cast int %Y to uint |
| 5950 | // After upgrade, this looks like: |
| 5951 | // %X = add i32 %Y, %Z |
| 5952 | // %X = bitcast i32 to i32 |
| 5953 | // The bitcast is clearly useless so we omit it. |
| 5954 | omit = true; |
| 5955 | if (omit) { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5956 | (yyval.InstVal).I = 0; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5957 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5958 | } else { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5959 | ValueInfo VI; VI.V = (yyvsp[0].InstVal).I; VI.S.copy((yyvsp[0].InstVal).S); |
| 5960 | setValueName(VI, (yyvsp[-1].StrVal)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5961 | InsertValue((yyvsp[0].InstVal).I); |
| 5962 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5963 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5964 | ;} |
| 5965 | break; |
| 5966 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5967 | case 273: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5968 | #line 3378 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5969 | { // Used for PHI nodes |
| 5970 | (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5971 | (yyval.PHIList).S.copy((yyvsp[-5].TypeVal).S); |
| 5972 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-5].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5973 | Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5974 | (yyvsp[-1].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5975 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
| 5976 | (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5977 | delete (yyvsp[-5].TypeVal).PAT; |
| 5978 | ;} |
| 5979 | break; |
| 5980 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5981 | case 274: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5982 | #line 3388 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5983 | { |
| 5984 | (yyval.PHIList) = (yyvsp[-6].PHIList); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5985 | (yyvsp[-3].ValIDVal).S.copy((yyvsp[-6].PHIList).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5986 | 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] | 5987 | (yyvsp[-1].ValIDVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5988 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
| 5989 | (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5990 | ;} |
| 5991 | break; |
| 5992 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5993 | case 275: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 5994 | #line 3398 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5995 | { // Used for call statements, and memory insts... |
| 5996 | (yyval.ValueList) = new std::vector<ValueInfo>(); |
| 5997 | (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); |
| 5998 | ;} |
| 5999 | break; |
| 6000 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6001 | case 276: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6002 | #line 3402 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6003 | { |
| 6004 | (yyval.ValueList) = (yyvsp[-2].ValueList); |
| 6005 | (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); |
| 6006 | ;} |
| 6007 | break; |
| 6008 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6009 | case 278: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6010 | #line 3410 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6011 | { (yyval.ValueList) = 0; ;} |
| 6012 | break; |
| 6013 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6014 | case 279: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6015 | #line 3414 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6016 | { |
| 6017 | (yyval.BoolVal) = true; |
| 6018 | ;} |
| 6019 | break; |
| 6020 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6021 | case 280: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6022 | #line 3417 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6023 | { |
| 6024 | (yyval.BoolVal) = false; |
| 6025 | ;} |
| 6026 | break; |
| 6027 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6028 | case 281: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6029 | #line 3423 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6030 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6031 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6032 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6033 | const Type* Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6034 | if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6035 | error("Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6036 | if (isa<VectorType>(Ty) && |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6037 | ((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] | 6038 | error("Remainder not supported on vector types"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6039 | // Upgrade the opcode from obsolete versions before we do anything with it. |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6040 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S); |
| 6041 | Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6042 | Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6043 | (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2); |
| 6044 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6045 | error("binary operator returned null"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6046 | (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6047 | delete (yyvsp[-3].TypeVal).PAT; |
| 6048 | ;} |
| 6049 | break; |
| 6050 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6051 | case 282: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6052 | #line 3442 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6053 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6054 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6055 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6056 | const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6057 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6058 | if (!isa<VectorType>(Ty) || |
| 6059 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6060 | error("Logical operator requires integral operands"); |
| 6061 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6062 | Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S); |
| 6063 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6064 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6065 | (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); |
| 6066 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6067 | error("binary operator returned null"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6068 | (yyval.InstVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6069 | delete (yyvsp[-3].TypeVal).PAT; |
| 6070 | ;} |
| 6071 | break; |
| 6072 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6073 | case 283: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6074 | #line 3460 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6075 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6076 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6077 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6078 | const Type* Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6079 | if(isa<VectorType>(Ty)) |
| 6080 | error("VectorTypes currently not supported in setcc instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6081 | unsigned short pred; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6082 | Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S); |
| 6083 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6084 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6085 | (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); |
| 6086 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6087 | error("binary operator returned null"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6088 | (yyval.InstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6089 | delete (yyvsp[-3].TypeVal).PAT; |
| 6090 | ;} |
| 6091 | break; |
| 6092 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6093 | case 284: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6094 | #line 3476 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6095 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6096 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6097 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6098 | const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6099 | if (isa<VectorType>(Ty)) |
| 6100 | error("VectorTypes currently not supported in icmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6101 | else if (!Ty->isInteger() && !isa<PointerType>(Ty)) |
| 6102 | error("icmp requires integer or pointer typed operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6103 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6104 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6105 | (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6106 | (yyval.InstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6107 | delete (yyvsp[-3].TypeVal).PAT; |
| 6108 | ;} |
| 6109 | break; |
| 6110 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6111 | case 285: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6112 | #line 3490 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6113 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6114 | (yyvsp[-2].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
| 6115 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-3].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6116 | const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6117 | if (isa<VectorType>(Ty)) |
| 6118 | error("VectorTypes currently not supported in fcmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6119 | else if (!Ty->isFloatingPoint()) |
| 6120 | error("fcmp instruction requires floating point operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6121 | Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); |
| 6122 | Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6123 | (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6124 | (yyval.InstVal).S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6125 | delete (yyvsp[-3].TypeVal).PAT; |
| 6126 | ;} |
| 6127 | break; |
| 6128 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6129 | case 286: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6130 | #line 3504 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6131 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6132 | warning("Use of obsolete 'not' instruction: Replacing with 'xor"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6133 | const Type *Ty = (yyvsp[0].ValueVal).V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6134 | Value *Ones = ConstantInt::getAllOnesValue(Ty); |
| 6135 | if (Ones == 0) |
| 6136 | error("Expected integral type for not instruction"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6137 | (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones); |
| 6138 | if ((yyval.InstVal).I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6139 | error("Could not create a xor instruction"); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6140 | (yyval.InstVal).S.copy((yyvsp[0].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6141 | ;} |
| 6142 | break; |
| 6143 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6144 | case 287: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6145 | #line 3515 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6146 | { |
| 6147 | if (!(yyvsp[0].ValueVal).V->getType()->isInteger() || |
| 6148 | cast<IntegerType>((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6149 | error("Shift amount must be int8"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6150 | const Type* Ty = (yyvsp[-2].ValueVal).V->getType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6151 | if (!Ty->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6152 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6153 | Value* ShiftAmt = 0; |
| 6154 | if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth()) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6155 | if (Constant *C = dyn_cast<Constant>((yyvsp[0].ValueVal).V)) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6156 | ShiftAmt = ConstantExpr::getZExt(C, Ty); |
| 6157 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6158 | ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6159 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6160 | ShiftAmt = (yyvsp[0].ValueVal).V; |
| 6161 | (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] | 6162 | (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6163 | ;} |
| 6164 | break; |
| 6165 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6166 | case 288: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6167 | #line 3533 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6168 | { |
| 6169 | const Type *DstTy = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6170 | if (!DstTy->isFirstClassType()) |
| 6171 | error("cast instruction to a non-primitive type: '" + |
| 6172 | DstTy->getDescription() + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6173 | (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] | 6174 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6175 | delete (yyvsp[0].TypeVal).PAT; |
| 6176 | ;} |
| 6177 | break; |
| 6178 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6179 | case 289: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6180 | #line 3542 "/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[-4].ValueVal).V->getType()->isInteger() || |
| 6183 | cast<IntegerType>((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6184 | error("select condition must be bool"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6185 | if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6186 | error("select value types should match"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6187 | (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] | 6188 | (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6189 | ;} |
| 6190 | break; |
| 6191 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6192 | case 290: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6193 | #line 3551 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6194 | { |
| 6195 | const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6196 | NewVarArgs = true; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6197 | (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6198 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6199 | delete (yyvsp[0].TypeVal).PAT; |
| 6200 | ;} |
| 6201 | break; |
| 6202 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6203 | case 291: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6204 | #line 3558 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6205 | { |
| 6206 | const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType(); |
| 6207 | const Type* DstTy = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6208 | ObsoleteVarArgs = true; |
| 6209 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6210 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6211 | |
| 6212 | //b = vaarg a, t -> |
| 6213 | //foo = alloca 1 of t |
| 6214 | //bar = vacopy a |
| 6215 | //store bar -> foo |
| 6216 | //b = vaarg foo, t |
| 6217 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 6218 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6219 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6220 | CurBB->getInstList().push_back(bar); |
| 6221 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6222 | (yyval.InstVal).I = new VAArgInst(foo, DstTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6223 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6224 | delete (yyvsp[0].TypeVal).PAT; |
| 6225 | ;} |
| 6226 | break; |
| 6227 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6228 | case 292: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6229 | #line 3579 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6230 | { |
| 6231 | const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType(); |
| 6232 | const Type* DstTy = (yyvsp[0].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6233 | ObsoleteVarArgs = true; |
| 6234 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6235 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6236 | |
| 6237 | //b = vanext a, t -> |
| 6238 | //foo = alloca 1 of t |
| 6239 | //bar = vacopy a |
| 6240 | //store bar -> foo |
| 6241 | //tmp = vaarg foo, t |
| 6242 | //b = load foo |
| 6243 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 6244 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6245 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6246 | CurBB->getInstList().push_back(bar); |
| 6247 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 6248 | Instruction* tmp = new VAArgInst(foo, DstTy); |
| 6249 | CurBB->getInstList().push_back(tmp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6250 | (yyval.InstVal).I = new LoadInst(foo); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6251 | (yyval.InstVal).S.copy((yyvsp[0].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6252 | delete (yyvsp[0].TypeVal).PAT; |
| 6253 | ;} |
| 6254 | break; |
| 6255 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6256 | case 293: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6257 | #line 3603 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6258 | { |
| 6259 | if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6260 | error("Invalid extractelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6261 | (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] | 6262 | (yyval.InstVal).S.copy((yyvsp[-2].ValueVal).S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6263 | ;} |
| 6264 | break; |
| 6265 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6266 | case 294: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6267 | #line 3609 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6268 | { |
| 6269 | 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] | 6270 | error("Invalid insertelement operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6271 | (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] | 6272 | (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6273 | ;} |
| 6274 | break; |
| 6275 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6276 | case 295: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6277 | #line 3615 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6278 | { |
| 6279 | 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] | 6280 | error("Invalid shufflevector operands"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6281 | (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] | 6282 | (yyval.InstVal).S.copy((yyvsp[-4].ValueVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6283 | ;} |
| 6284 | break; |
| 6285 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6286 | case 296: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6287 | #line 3621 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6288 | { |
| 6289 | const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6290 | if (!Ty->isFirstClassType()) |
| 6291 | error("PHI node operands must be of first class type"); |
| 6292 | PHINode *PHI = new PHINode(Ty); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6293 | PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size()); |
| 6294 | while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) { |
| 6295 | if ((yyvsp[0].PHIList).P->front().first->getType() != Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6296 | 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] | 6297 | PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second); |
| 6298 | (yyvsp[0].PHIList).P->pop_front(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6299 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6300 | (yyval.InstVal).I = PHI; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6301 | (yyval.InstVal).S.copy((yyvsp[0].PHIList).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6302 | delete (yyvsp[0].PHIList).P; // Free the list... |
| 6303 | ;} |
| 6304 | break; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6305 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6306 | case 297: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6307 | #line 3637 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6308 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6309 | // Handle the short call syntax |
| 6310 | const PointerType *PFTy; |
| 6311 | const FunctionType *FTy; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6312 | Signedness FTySign; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6313 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6314 | !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 6315 | // Pull out the types of all of the arguments... |
| 6316 | std::vector<const Type*> ParamTypes; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6317 | FTySign.makeComposite((yyvsp[-4].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6318 | if ((yyvsp[-1].ValueList)) { |
| 6319 | 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] | 6320 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6321 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6322 | FTySign.add(I->S); |
| 6323 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6324 | } |
| 6325 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 6326 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6327 | if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) { |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 6328 | ParamAttrs.push_back(FunctionType::NoAttributeSet); |
| 6329 | ParamAttrs.push_back(FunctionType::StructRetAttribute); |
| 6330 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6331 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 6332 | if (isVarArg) ParamTypes.pop_back(); |
| 6333 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6334 | const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6335 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 6336 | error("Functions cannot return aggregate types"); |
| 6337 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 6338 | FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6339 | PFTy = PointerType::get(FTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6340 | (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S); |
| 6341 | } else { |
| 6342 | FTySign = (yyvsp[-4].TypeVal).S; |
| 6343 | (yyval.InstVal).S.copy((yyvsp[-4].TypeVal).S.get(0)); // 0th element of FuncTy signedness is result sign |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6344 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6345 | (yyvsp[-3].ValIDVal).S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6346 | |
| 6347 | // First upgrade any intrinsic calls. |
| 6348 | std::vector<Value*> Args; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6349 | if ((yyvsp[-1].ValueList)) |
| 6350 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i) |
| 6351 | Args.push_back((*(yyvsp[-1].ValueList))[i].V); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6352 | Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[-3].ValIDVal), Args); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6353 | |
| 6354 | // If we got an upgraded intrinsic |
| 6355 | if (Inst) { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6356 | (yyval.InstVal).I = Inst; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6357 | } else { |
| 6358 | // Get the function we're calling |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6359 | Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6360 | |
| 6361 | // Check the argument values match |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6362 | if (!(yyvsp[-1].ValueList)) { // Has no arguments? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6363 | // Make sure no arguments is a good thing! |
| 6364 | if (FTy->getNumParams() != 0) |
| 6365 | error("No arguments passed to a function that expects arguments"); |
| 6366 | } else { // Has arguments? |
| 6367 | // Loop through FunctionType's arguments and ensure they are specified |
| 6368 | // correctly! |
| 6369 | // |
| 6370 | FunctionType::param_iterator I = FTy->param_begin(); |
| 6371 | FunctionType::param_iterator E = FTy->param_end(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6372 | 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] | 6373 | |
| 6374 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 6375 | if ((*ArgI).V->getType() != *I) |
| 6376 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 6377 | (*I)->getDescription() + "'"); |
| 6378 | |
| 6379 | if (I != E || (ArgI != ArgE && !FTy->isVarArg())) |
| 6380 | error("Invalid number of parameters detected"); |
| 6381 | } |
| 6382 | |
| 6383 | // Create the call instruction |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6384 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6385 | CI->setTailCall((yyvsp[-6].BoolVal)); |
| 6386 | CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal))); |
| 6387 | (yyval.InstVal).I = CI; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6388 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6389 | delete (yyvsp[-4].TypeVal).PAT; |
| 6390 | delete (yyvsp[-1].ValueList); |
| 6391 | ;} |
| 6392 | break; |
| 6393 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6394 | case 298: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6395 | #line 3721 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6396 | { |
| 6397 | (yyval.InstVal) = (yyvsp[0].InstVal); |
| 6398 | ;} |
| 6399 | break; |
| 6400 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6401 | case 299: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6402 | #line 3729 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6403 | { (yyval.ValueList) = (yyvsp[0].ValueList); ;} |
| 6404 | break; |
| 6405 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6406 | case 300: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6407 | #line 3730 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6408 | { (yyval.ValueList) = new std::vector<ValueInfo>(); ;} |
| 6409 | break; |
| 6410 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6411 | case 301: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6412 | #line 3734 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6413 | { (yyval.BoolVal) = true; ;} |
| 6414 | break; |
| 6415 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6416 | case 302: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6417 | #line 3735 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6418 | { (yyval.BoolVal) = false; ;} |
| 6419 | break; |
| 6420 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6421 | case 303: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6422 | #line 3739 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6423 | { |
| 6424 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6425 | (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6426 | (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal)); |
| 6427 | delete (yyvsp[-1].TypeVal).PAT; |
| 6428 | ;} |
| 6429 | break; |
| 6430 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6431 | case 304: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6432 | #line 3745 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6433 | { |
| 6434 | const Type *Ty = (yyvsp[-4].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6435 | (yyvsp[-1].ValIDVal).S.makeUnsigned(); |
| 6436 | (yyval.InstVal).S.makeComposite((yyvsp[-4].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6437 | (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal)); |
| 6438 | delete (yyvsp[-4].TypeVal).PAT; |
| 6439 | ;} |
| 6440 | break; |
| 6441 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6442 | case 305: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6443 | #line 3752 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6444 | { |
| 6445 | const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6446 | (yyval.InstVal).S.makeComposite((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6447 | (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal)); |
| 6448 | delete (yyvsp[-1].TypeVal).PAT; |
| 6449 | ;} |
| 6450 | break; |
| 6451 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6452 | case 306: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6453 | #line 3758 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6454 | { |
| 6455 | const Type *Ty = (yyvsp[-4].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6456 | (yyvsp[-1].ValIDVal).S.makeUnsigned(); |
| 6457 | (yyval.InstVal).S.makeComposite((yyvsp[-2].PrimType).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6458 | (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal)); |
| 6459 | delete (yyvsp[-4].TypeVal).PAT; |
| 6460 | ;} |
| 6461 | break; |
| 6462 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6463 | case 307: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6464 | #line 3765 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6465 | { |
| 6466 | const Type *PTy = (yyvsp[0].ValueVal).V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6467 | if (!isa<PointerType>(PTy)) |
| 6468 | error("Trying to free nonpointer type '" + PTy->getDescription() + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6469 | (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6470 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6471 | ;} |
| 6472 | break; |
| 6473 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6474 | case 308: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6475 | #line 3772 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6476 | { |
| 6477 | const Type* Ty = (yyvsp[-1].TypeVal).PAT->get(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6478 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6479 | if (!isa<PointerType>(Ty)) |
| 6480 | error("Can't load from nonpointer type: " + Ty->getDescription()); |
| 6481 | if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType()) |
| 6482 | error("Can't load from pointer of non-first-class type: " + |
| 6483 | Ty->getDescription()); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6484 | Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal)); |
| 6485 | (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6486 | (yyval.InstVal).S.copy((yyvsp[-1].TypeVal).S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6487 | delete (yyvsp[-1].TypeVal).PAT; |
| 6488 | ;} |
| 6489 | break; |
| 6490 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6491 | case 309: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6492 | #line 3785 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6493 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6494 | (yyvsp[0].ValIDVal).S.copy((yyvsp[-1].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6495 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).PAT->get()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6496 | if (!PTy) |
| 6497 | error("Can't store to a nonpointer type: " + |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6498 | (yyvsp[-1].TypeVal).PAT->get()->getDescription()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6499 | const Type *ElTy = PTy->getElementType(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6500 | Value *StoreVal = (yyvsp[-3].ValueVal).V; |
| 6501 | Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal)); |
| 6502 | if (ElTy != (yyvsp[-3].ValueVal).V->getType()) { |
| 6503 | StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6504 | if (!StoreVal) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6505 | error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() + |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6506 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 6507 | else { |
| 6508 | PTy = PointerType::get(StoreVal->getType()); |
| 6509 | if (Constant *C = dyn_cast<Constant>(tmpVal)) |
| 6510 | tmpVal = ConstantExpr::getBitCast(C, PTy); |
| 6511 | else |
| 6512 | tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB); |
| 6513 | } |
| 6514 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6515 | (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6516 | (yyval.InstVal).S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6517 | delete (yyvsp[-1].TypeVal).PAT; |
| 6518 | ;} |
| 6519 | break; |
| 6520 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6521 | case 310: |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6522 | #line 3811 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6523 | { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6524 | (yyvsp[-1].ValIDVal).S.copy((yyvsp[-2].TypeVal).S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6525 | const Type* Ty = (yyvsp[-2].TypeVal).PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6526 | if (!isa<PointerType>(Ty)) |
| 6527 | error("getelementptr insn requires pointer operand"); |
| 6528 | |
| 6529 | std::vector<Value*> VIndices; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6530 | upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6531 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6532 | Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal)); |
| 6533 | (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6534 | ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[-2].TypeVal).S); |
| 6535 | (yyval.InstVal).S.copy(getElementSign(VI, VIndices)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6536 | delete (yyvsp[-2].TypeVal).PAT; |
| 6537 | delete (yyvsp[0].ValueList); |
| 6538 | ;} |
| 6539 | break; |
| 6540 | |
| 6541 | |
| 6542 | default: break; |
| 6543 | } |
| 6544 | |
| 6545 | /* Line 1126 of yacc.c. */ |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6546 | #line 6547 "UpgradeParser.tab.c" |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6547 | |
| 6548 | yyvsp -= yylen; |
| 6549 | yyssp -= yylen; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 6550 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6551 | |
| 6552 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6553 | |
| 6554 | *++yyvsp = yyval; |
| 6555 | |
| 6556 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6557 | /* Now `shift' the result of the reduction. Determine what state |
| 6558 | that goes to, based on the state we popped back to and the rule |
| 6559 | number reduced by. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6560 | |
| 6561 | yyn = yyr1[yyn]; |
| 6562 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6563 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 6564 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6565 | yystate = yytable[yystate]; |
| 6566 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6567 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6568 | |
| 6569 | goto yynewstate; |
| 6570 | |
| 6571 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6572 | /*------------------------------------. |
| 6573 | | yyerrlab -- here on detecting error | |
| 6574 | `------------------------------------*/ |
| 6575 | yyerrlab: |
| 6576 | /* If not already recovering from an error, report this error. */ |
| 6577 | if (!yyerrstatus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6578 | { |
| 6579 | ++yynerrs; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6580 | #if YYERROR_VERBOSE |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6581 | yyn = yypact[yystate]; |
| 6582 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6583 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6584 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6585 | int yytype = YYTRANSLATE (yychar); |
| 6586 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 6587 | YYSIZE_T yysize = yysize0; |
| 6588 | YYSIZE_T yysize1; |
| 6589 | int yysize_overflow = 0; |
| 6590 | char *yymsg = 0; |
| 6591 | # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 |
| 6592 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 6593 | int yyx; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6594 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6595 | #if 0 |
| 6596 | /* This is so xgettext sees the translatable formats that are |
| 6597 | constructed on the fly. */ |
| 6598 | YY_("syntax error, unexpected %s"); |
| 6599 | YY_("syntax error, unexpected %s, expecting %s"); |
| 6600 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 6601 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 6602 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 6603 | #endif |
| 6604 | char *yyfmt; |
| 6605 | char const *yyf; |
| 6606 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 6607 | static char const yyexpecting[] = ", expecting %s"; |
| 6608 | static char const yyor[] = " or %s"; |
| 6609 | char yyformat[sizeof yyunexpected |
| 6610 | + sizeof yyexpecting - 1 |
| 6611 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 6612 | * (sizeof yyor - 1))]; |
| 6613 | char const *yyprefix = yyexpecting; |
| 6614 | |
| 6615 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 6616 | YYCHECK. */ |
| 6617 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 6618 | |
| 6619 | /* Stay within bounds of both yycheck and yytname. */ |
| 6620 | int yychecklim = YYLAST - yyn; |
| 6621 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 6622 | int yycount = 1; |
| 6623 | |
| 6624 | yyarg[0] = yytname[yytype]; |
| 6625 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 6626 | |
| 6627 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 6628 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 6629 | { |
| 6630 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 6631 | { |
| 6632 | yycount = 1; |
| 6633 | yysize = yysize0; |
| 6634 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 6635 | break; |
| 6636 | } |
| 6637 | yyarg[yycount++] = yytname[yyx]; |
| 6638 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 6639 | yysize_overflow |= yysize1 < yysize; |
| 6640 | yysize = yysize1; |
| 6641 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 6642 | yyprefix = yyor; |
| 6643 | } |
| 6644 | |
| 6645 | yyf = YY_(yyformat); |
| 6646 | yysize1 = yysize + yystrlen (yyf); |
| 6647 | yysize_overflow |= yysize1 < yysize; |
| 6648 | yysize = yysize1; |
| 6649 | |
| 6650 | if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) |
| 6651 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 6652 | if (yymsg) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6653 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6654 | /* Avoid sprintf, as that infringes on the user's name space. |
| 6655 | Don't have undefined behavior even if the translation |
| 6656 | produced a string with the wrong number of "%s"s. */ |
| 6657 | char *yyp = yymsg; |
| 6658 | int yyi = 0; |
| 6659 | while ((*yyp = *yyf)) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6660 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6661 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 6662 | { |
| 6663 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 6664 | yyf += 2; |
| 6665 | } |
| 6666 | else |
| 6667 | { |
| 6668 | yyp++; |
| 6669 | yyf++; |
| 6670 | } |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6671 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6672 | yyerror (yymsg); |
| 6673 | YYSTACK_FREE (yymsg); |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6674 | } |
| 6675 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6676 | { |
| 6677 | yyerror (YY_("syntax error")); |
| 6678 | goto yyexhaustedlab; |
| 6679 | } |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6680 | } |
| 6681 | else |
| 6682 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6683 | yyerror (YY_("syntax error")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6684 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6685 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6686 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6687 | |
| 6688 | if (yyerrstatus == 3) |
| 6689 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6690 | /* If just tried and failed to reuse look-ahead token after an |
| 6691 | error, discard it. */ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6692 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6693 | if (yychar <= YYEOF) |
| 6694 | { |
| 6695 | /* Return failure if at end of input. */ |
| 6696 | if (yychar == YYEOF) |
| 6697 | YYABORT; |
| 6698 | } |
| 6699 | else |
| 6700 | { |
| 6701 | yydestruct ("Error: discarding", yytoken, &yylval); |
| 6702 | yychar = YYEMPTY; |
| 6703 | } |
| 6704 | } |
| 6705 | |
| 6706 | /* Else will try to reuse look-ahead token after shifting the error |
| 6707 | token. */ |
| 6708 | goto yyerrlab1; |
| 6709 | |
| 6710 | |
| 6711 | /*---------------------------------------------------. |
| 6712 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 6713 | `---------------------------------------------------*/ |
| 6714 | yyerrorlab: |
| 6715 | |
| 6716 | /* Pacify compilers like GCC when the user code never invokes |
| 6717 | YYERROR and the label yyerrorlab therefore never appears in user |
| 6718 | code. */ |
| 6719 | if (0) |
| 6720 | goto yyerrorlab; |
| 6721 | |
| 6722 | yyvsp -= yylen; |
| 6723 | yyssp -= yylen; |
| 6724 | yystate = *yyssp; |
| 6725 | goto yyerrlab1; |
| 6726 | |
| 6727 | |
| 6728 | /*-------------------------------------------------------------. |
| 6729 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 6730 | `-------------------------------------------------------------*/ |
| 6731 | yyerrlab1: |
| 6732 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 6733 | |
| 6734 | for (;;) |
| 6735 | { |
| 6736 | yyn = yypact[yystate]; |
| 6737 | if (yyn != YYPACT_NINF) |
| 6738 | { |
| 6739 | yyn += YYTERROR; |
| 6740 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 6741 | { |
| 6742 | yyn = yytable[yyn]; |
| 6743 | if (0 < yyn) |
| 6744 | break; |
| 6745 | } |
| 6746 | } |
| 6747 | |
| 6748 | /* Pop the current state because it cannot handle the error token. */ |
| 6749 | if (yyssp == yyss) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6750 | YYABORT; |
| 6751 | |
| 6752 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6753 | yydestruct ("Error: popping", yystos[yystate], yyvsp); |
| 6754 | YYPOPSTACK; |
| 6755 | yystate = *yyssp; |
| 6756 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6757 | } |
| 6758 | |
| 6759 | if (yyn == YYFINAL) |
| 6760 | YYACCEPT; |
| 6761 | |
| 6762 | *++yyvsp = yylval; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6763 | |
| 6764 | |
| 6765 | /* Shift the error token. */ |
| 6766 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6767 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6768 | yystate = yyn; |
| 6769 | goto yynewstate; |
| 6770 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6771 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6772 | /*-------------------------------------. |
| 6773 | | yyacceptlab -- YYACCEPT comes here. | |
| 6774 | `-------------------------------------*/ |
| 6775 | yyacceptlab: |
| 6776 | yyresult = 0; |
| 6777 | goto yyreturn; |
| 6778 | |
| 6779 | /*-----------------------------------. |
| 6780 | | yyabortlab -- YYABORT comes here. | |
| 6781 | `-----------------------------------*/ |
| 6782 | yyabortlab: |
| 6783 | yyresult = 1; |
| 6784 | goto yyreturn; |
| 6785 | |
| 6786 | #ifndef yyoverflow |
| 6787 | /*-------------------------------------------------. |
| 6788 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 6789 | `-------------------------------------------------*/ |
| 6790 | yyexhaustedlab: |
| 6791 | yyerror (YY_("memory exhausted")); |
| 6792 | yyresult = 2; |
| 6793 | /* Fall through. */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6794 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6795 | |
| 6796 | yyreturn: |
| 6797 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 6798 | yydestruct ("Cleanup: discarding lookahead", |
| 6799 | yytoken, &yylval); |
| 6800 | while (yyssp != yyss) |
| 6801 | { |
| 6802 | yydestruct ("Cleanup: popping", |
| 6803 | yystos[*yyssp], yyvsp); |
| 6804 | YYPOPSTACK; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6805 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6806 | #ifndef yyoverflow |
| 6807 | if (yyss != yyssa) |
| 6808 | YYSTACK_FREE (yyss); |
| 6809 | #endif |
| 6810 | return yyresult; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6811 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6812 | |
| 6813 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame^] | 6814 | #line 3829 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6815 | |
| 6816 | |
| 6817 | int yyerror(const char *ErrorMsg) { |
| 6818 | std::string where |
| 6819 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6820 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6821 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 6822 | if (yychar != YYEMPTY && yychar != 0) |
| 6823 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6824 | "'."; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 6825 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6826 | std::cout << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6827 | exit(1); |
| 6828 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6829 | |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 6830 | void warning(const std::string& ErrorMsg) { |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6831 | std::string where |
| 6832 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6833 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6834 | std::string errMsg = where + "warning: " + std::string(ErrorMsg); |
| 6835 | if (yychar != YYEMPTY && yychar != 0) |
| 6836 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6837 | "'."; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6838 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
| 6839 | } |
| 6840 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6841 | void error(const std::string& ErrorMsg, int LineNo) { |
| 6842 | if (LineNo == -1) LineNo = Upgradelineno; |
| 6843 | Upgradelineno = LineNo; |
| 6844 | yyerror(ErrorMsg.c_str()); |
| 6845 | } |
| 6846 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6847 | |