David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 1 | /* A Bison parser, made by GNU Bison 1.875c. */ |
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, |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 18 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | Boston, MA 02111-1307, USA. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 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 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 39 | /* Skeleton name. */ |
| 40 | #define YYSKELETON_NAME "yacc.c" |
| 41 | |
| 42 | /* Pure parsers. */ |
| 43 | #define YYPURE 0 |
| 44 | |
| 45 | /* Using locations. */ |
| 46 | #define YYLSP_NEEDED 0 |
| 47 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 48 | /* If NAME_PREFIX is specified substitute the variables and functions |
| 49 | names. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 50 | #define yyparse Upgradeparse |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 51 | #define yylex Upgradelex |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 52 | #define yyerror Upgradeerror |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 53 | #define yylval Upgradelval |
| 54 | #define yychar Upgradechar |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 55 | #define yydebug Upgradedebug |
| 56 | #define yynerrs Upgradenerrs |
| 57 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 58 | |
| 59 | /* Tokens. */ |
| 60 | #ifndef YYTOKENTYPE |
| 61 | # define YYTOKENTYPE |
| 62 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 63 | know about them. */ |
| 64 | enum yytokentype { |
| 65 | ESINT64VAL = 258, |
| 66 | EUINT64VAL = 259, |
| 67 | SINTVAL = 260, |
| 68 | UINTVAL = 261, |
| 69 | FPVAL = 262, |
| 70 | VOID = 263, |
| 71 | BOOL = 264, |
| 72 | SBYTE = 265, |
| 73 | UBYTE = 266, |
| 74 | SHORT = 267, |
| 75 | USHORT = 268, |
| 76 | INT = 269, |
| 77 | UINT = 270, |
| 78 | LONG = 271, |
| 79 | ULONG = 272, |
| 80 | FLOAT = 273, |
| 81 | DOUBLE = 274, |
| 82 | TYPE = 275, |
| 83 | LABEL = 276, |
| 84 | VAR_ID = 277, |
| 85 | LABELSTR = 278, |
| 86 | STRINGCONSTANT = 279, |
| 87 | IMPLEMENTATION = 280, |
| 88 | ZEROINITIALIZER = 281, |
| 89 | TRUETOK = 282, |
| 90 | FALSETOK = 283, |
| 91 | BEGINTOK = 284, |
| 92 | ENDTOK = 285, |
| 93 | DECLARE = 286, |
| 94 | GLOBAL = 287, |
| 95 | CONSTANT = 288, |
| 96 | SECTION = 289, |
| 97 | VOLATILE = 290, |
| 98 | TO = 291, |
| 99 | DOTDOTDOT = 292, |
| 100 | NULL_TOK = 293, |
| 101 | UNDEF = 294, |
| 102 | CONST = 295, |
| 103 | INTERNAL = 296, |
| 104 | LINKONCE = 297, |
| 105 | WEAK = 298, |
| 106 | APPENDING = 299, |
| 107 | DLLIMPORT = 300, |
| 108 | DLLEXPORT = 301, |
| 109 | EXTERN_WEAK = 302, |
| 110 | OPAQUE = 303, |
| 111 | NOT = 304, |
| 112 | EXTERNAL = 305, |
| 113 | TARGET = 306, |
| 114 | TRIPLE = 307, |
| 115 | ENDIAN = 308, |
| 116 | POINTERSIZE = 309, |
| 117 | LITTLE = 310, |
| 118 | BIG = 311, |
| 119 | ALIGN = 312, |
| 120 | DEPLIBS = 313, |
| 121 | CALL = 314, |
| 122 | TAIL = 315, |
| 123 | ASM_TOK = 316, |
| 124 | MODULE = 317, |
| 125 | SIDEEFFECT = 318, |
| 126 | CC_TOK = 319, |
| 127 | CCC_TOK = 320, |
| 128 | CSRETCC_TOK = 321, |
| 129 | FASTCC_TOK = 322, |
| 130 | COLDCC_TOK = 323, |
| 131 | X86_STDCALLCC_TOK = 324, |
| 132 | X86_FASTCALLCC_TOK = 325, |
| 133 | DATALAYOUT = 326, |
| 134 | RET = 327, |
| 135 | BR = 328, |
| 136 | SWITCH = 329, |
| 137 | INVOKE = 330, |
| 138 | UNREACHABLE = 331, |
| 139 | UNWIND = 332, |
| 140 | EXCEPT = 333, |
| 141 | ADD = 334, |
| 142 | SUB = 335, |
| 143 | MUL = 336, |
| 144 | DIV = 337, |
| 145 | UDIV = 338, |
| 146 | SDIV = 339, |
| 147 | FDIV = 340, |
| 148 | REM = 341, |
| 149 | UREM = 342, |
| 150 | SREM = 343, |
| 151 | FREM = 344, |
| 152 | AND = 345, |
| 153 | OR = 346, |
| 154 | XOR = 347, |
| 155 | SHL = 348, |
| 156 | SHR = 349, |
| 157 | ASHR = 350, |
| 158 | LSHR = 351, |
| 159 | SETLE = 352, |
| 160 | SETGE = 353, |
| 161 | SETLT = 354, |
| 162 | SETGT = 355, |
| 163 | SETEQ = 356, |
| 164 | SETNE = 357, |
| 165 | ICMP = 358, |
| 166 | FCMP = 359, |
| 167 | MALLOC = 360, |
| 168 | ALLOCA = 361, |
| 169 | FREE = 362, |
| 170 | LOAD = 363, |
| 171 | STORE = 364, |
| 172 | GETELEMENTPTR = 365, |
| 173 | PHI_TOK = 366, |
| 174 | SELECT = 367, |
| 175 | VAARG = 368, |
| 176 | EXTRACTELEMENT = 369, |
| 177 | INSERTELEMENT = 370, |
| 178 | SHUFFLEVECTOR = 371, |
| 179 | VAARG_old = 372, |
| 180 | VANEXT_old = 373, |
| 181 | EQ = 374, |
| 182 | NE = 375, |
| 183 | SLT = 376, |
| 184 | SGT = 377, |
| 185 | SLE = 378, |
| 186 | SGE = 379, |
| 187 | ULT = 380, |
| 188 | UGT = 381, |
| 189 | ULE = 382, |
| 190 | UGE = 383, |
| 191 | OEQ = 384, |
| 192 | ONE = 385, |
| 193 | OLT = 386, |
| 194 | OGT = 387, |
| 195 | OLE = 388, |
| 196 | OGE = 389, |
| 197 | ORD = 390, |
| 198 | UNO = 391, |
| 199 | UEQ = 392, |
| 200 | UNE = 393, |
| 201 | CAST = 394, |
| 202 | TRUNC = 395, |
| 203 | ZEXT = 396, |
| 204 | SEXT = 397, |
| 205 | FPTRUNC = 398, |
| 206 | FPEXT = 399, |
| 207 | FPTOUI = 400, |
| 208 | FPTOSI = 401, |
| 209 | UITOFP = 402, |
| 210 | SITOFP = 403, |
| 211 | PTRTOINT = 404, |
| 212 | INTTOPTR = 405, |
| 213 | BITCAST = 406 |
| 214 | }; |
| 215 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 216 | #define ESINT64VAL 258 |
| 217 | #define EUINT64VAL 259 |
| 218 | #define SINTVAL 260 |
| 219 | #define UINTVAL 261 |
| 220 | #define FPVAL 262 |
| 221 | #define VOID 263 |
| 222 | #define BOOL 264 |
| 223 | #define SBYTE 265 |
| 224 | #define UBYTE 266 |
| 225 | #define SHORT 267 |
| 226 | #define USHORT 268 |
| 227 | #define INT 269 |
| 228 | #define UINT 270 |
| 229 | #define LONG 271 |
| 230 | #define ULONG 272 |
| 231 | #define FLOAT 273 |
| 232 | #define DOUBLE 274 |
| 233 | #define TYPE 275 |
| 234 | #define LABEL 276 |
| 235 | #define VAR_ID 277 |
| 236 | #define LABELSTR 278 |
| 237 | #define STRINGCONSTANT 279 |
| 238 | #define IMPLEMENTATION 280 |
| 239 | #define ZEROINITIALIZER 281 |
| 240 | #define TRUETOK 282 |
| 241 | #define FALSETOK 283 |
| 242 | #define BEGINTOK 284 |
| 243 | #define ENDTOK 285 |
| 244 | #define DECLARE 286 |
| 245 | #define GLOBAL 287 |
| 246 | #define CONSTANT 288 |
| 247 | #define SECTION 289 |
| 248 | #define VOLATILE 290 |
| 249 | #define TO 291 |
| 250 | #define DOTDOTDOT 292 |
| 251 | #define NULL_TOK 293 |
| 252 | #define UNDEF 294 |
| 253 | #define CONST 295 |
| 254 | #define INTERNAL 296 |
| 255 | #define LINKONCE 297 |
| 256 | #define WEAK 298 |
| 257 | #define APPENDING 299 |
| 258 | #define DLLIMPORT 300 |
| 259 | #define DLLEXPORT 301 |
| 260 | #define EXTERN_WEAK 302 |
| 261 | #define OPAQUE 303 |
| 262 | #define NOT 304 |
| 263 | #define EXTERNAL 305 |
| 264 | #define TARGET 306 |
| 265 | #define TRIPLE 307 |
| 266 | #define ENDIAN 308 |
| 267 | #define POINTERSIZE 309 |
| 268 | #define LITTLE 310 |
| 269 | #define BIG 311 |
| 270 | #define ALIGN 312 |
| 271 | #define DEPLIBS 313 |
| 272 | #define CALL 314 |
| 273 | #define TAIL 315 |
| 274 | #define ASM_TOK 316 |
| 275 | #define MODULE 317 |
| 276 | #define SIDEEFFECT 318 |
| 277 | #define CC_TOK 319 |
| 278 | #define CCC_TOK 320 |
| 279 | #define CSRETCC_TOK 321 |
| 280 | #define FASTCC_TOK 322 |
| 281 | #define COLDCC_TOK 323 |
| 282 | #define X86_STDCALLCC_TOK 324 |
| 283 | #define X86_FASTCALLCC_TOK 325 |
| 284 | #define DATALAYOUT 326 |
| 285 | #define RET 327 |
| 286 | #define BR 328 |
| 287 | #define SWITCH 329 |
| 288 | #define INVOKE 330 |
| 289 | #define UNREACHABLE 331 |
| 290 | #define UNWIND 332 |
| 291 | #define EXCEPT 333 |
| 292 | #define ADD 334 |
| 293 | #define SUB 335 |
| 294 | #define MUL 336 |
| 295 | #define DIV 337 |
| 296 | #define UDIV 338 |
| 297 | #define SDIV 339 |
| 298 | #define FDIV 340 |
| 299 | #define REM 341 |
| 300 | #define UREM 342 |
| 301 | #define SREM 343 |
| 302 | #define FREM 344 |
| 303 | #define AND 345 |
| 304 | #define OR 346 |
| 305 | #define XOR 347 |
| 306 | #define SHL 348 |
| 307 | #define SHR 349 |
| 308 | #define ASHR 350 |
| 309 | #define LSHR 351 |
| 310 | #define SETLE 352 |
| 311 | #define SETGE 353 |
| 312 | #define SETLT 354 |
| 313 | #define SETGT 355 |
| 314 | #define SETEQ 356 |
| 315 | #define SETNE 357 |
| 316 | #define ICMP 358 |
| 317 | #define FCMP 359 |
| 318 | #define MALLOC 360 |
| 319 | #define ALLOCA 361 |
| 320 | #define FREE 362 |
| 321 | #define LOAD 363 |
| 322 | #define STORE 364 |
| 323 | #define GETELEMENTPTR 365 |
| 324 | #define PHI_TOK 366 |
| 325 | #define SELECT 367 |
| 326 | #define VAARG 368 |
| 327 | #define EXTRACTELEMENT 369 |
| 328 | #define INSERTELEMENT 370 |
| 329 | #define SHUFFLEVECTOR 371 |
| 330 | #define VAARG_old 372 |
| 331 | #define VANEXT_old 373 |
| 332 | #define EQ 374 |
| 333 | #define NE 375 |
| 334 | #define SLT 376 |
| 335 | #define SGT 377 |
| 336 | #define SLE 378 |
| 337 | #define SGE 379 |
| 338 | #define ULT 380 |
| 339 | #define UGT 381 |
| 340 | #define ULE 382 |
| 341 | #define UGE 383 |
| 342 | #define OEQ 384 |
| 343 | #define ONE 385 |
| 344 | #define OLT 386 |
| 345 | #define OGT 387 |
| 346 | #define OLE 388 |
| 347 | #define OGE 389 |
| 348 | #define ORD 390 |
| 349 | #define UNO 391 |
| 350 | #define UEQ 392 |
| 351 | #define UNE 393 |
| 352 | #define CAST 394 |
| 353 | #define TRUNC 395 |
| 354 | #define ZEXT 396 |
| 355 | #define SEXT 397 |
| 356 | #define FPTRUNC 398 |
| 357 | #define FPEXT 399 |
| 358 | #define FPTOUI 400 |
| 359 | #define FPTOSI 401 |
| 360 | #define UITOFP 402 |
| 361 | #define SITOFP 403 |
| 362 | #define PTRTOINT 404 |
| 363 | #define INTTOPTR 405 |
| 364 | #define BITCAST 406 |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | /* Copy the first part of user declarations. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 370 | #line 14 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 371 | |
| 372 | #include "UpgradeInternals.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 373 | #include "llvm/CallingConv.h" |
| 374 | #include "llvm/InlineAsm.h" |
| 375 | #include "llvm/Instructions.h" |
| 376 | #include "llvm/Module.h" |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 377 | #include "llvm/ParameterAttributes.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 378 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 379 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 380 | #include "llvm/ADT/STLExtras.h" |
| 381 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 382 | #include <algorithm> |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 383 | #include <iostream> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 384 | #include <map> |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 385 | #include <list> |
| 386 | #include <utility> |
| 387 | |
| 388 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 389 | // relating to upreferences in the input stream. |
| 390 | // |
| 391 | //#define DEBUG_UPREFS 1 |
| 392 | #ifdef DEBUG_UPREFS |
| 393 | #define UR_OUT(X) std::cerr << X |
| 394 | #else |
| 395 | #define UR_OUT(X) |
| 396 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 397 | |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 398 | #define YYERROR_VERBOSE 1 |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 399 | #define YYINCLUDED_STDLIB_H |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 400 | #define YYDEBUG 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 401 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 402 | int yylex(); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 403 | int yyparse(); |
| 404 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 405 | int yyerror(const char*); |
| 406 | static void warning(const std::string& WarningMsg); |
| 407 | |
| 408 | namespace llvm { |
| 409 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 410 | std::istream* LexInput; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 411 | static std::string CurFilename; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 412 | |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 413 | // This bool controls whether attributes are ever added to function declarations |
| 414 | // definitions and calls. |
| 415 | static bool AddAttributes = false; |
| 416 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 417 | static Module *ParserResult; |
| 418 | static bool ObsoleteVarArgs; |
| 419 | static bool NewVarArgs; |
| 420 | static BasicBlock *CurBB; |
| 421 | static GlobalVariable *CurGV; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 422 | static unsigned lastCallingConv; |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 423 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 424 | // This contains info used when building the body of a function. It is |
| 425 | // destroyed when the function is completed. |
| 426 | // |
| 427 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 428 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 429 | typedef std::pair<std::string,TypeInfo> RenameMapKey; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 430 | typedef std::map<RenameMapKey,std::string> RenameMapType; |
| 431 | |
| 432 | static void |
| 433 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 434 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 435 | |
| 436 | static struct PerModuleInfo { |
| 437 | Module *CurrentModule; |
| 438 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 439 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 440 | std::vector<PATypeHolder> Types; |
| 441 | std::vector<Signedness> TypeSigns; |
| 442 | std::map<std::string,Signedness> NamedTypeSigns; |
| 443 | std::map<std::string,Signedness> NamedValueSigns; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 444 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 445 | static Module::Endianness Endian; |
| 446 | static Module::PointerSize PointerSize; |
| 447 | RenameMapType RenameMap; |
| 448 | |
| 449 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
| 450 | /// how they were referenced and on which line of the input they came from so |
| 451 | /// that we can resolve them later and print error messages as appropriate. |
| 452 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 453 | |
| 454 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 455 | // references to global values. Global values may be referenced before they |
| 456 | // are defined, and if so, the temporary object that they represent is held |
| 457 | // here. This is used for forward references of GlobalValues. |
| 458 | // |
| 459 | typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*> |
| 460 | GlobalRefsType; |
| 461 | GlobalRefsType GlobalRefs; |
| 462 | |
| 463 | void ModuleDone() { |
| 464 | // If we could not resolve some functions at function compilation time |
| 465 | // (calls to functions before they are defined), resolve them now... Types |
| 466 | // are resolved when the constant pool has been completely parsed. |
| 467 | // |
| 468 | ResolveDefinitions(LateResolveValues); |
| 469 | |
| 470 | // Check to make sure that all global value forward references have been |
| 471 | // resolved! |
| 472 | // |
| 473 | if (!GlobalRefs.empty()) { |
| 474 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 475 | |
| 476 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 477 | I != E; ++I) { |
| 478 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 479 | I->first.second.getName() + "\n"; |
| 480 | } |
| 481 | error(UndefinedReferences); |
| 482 | return; |
| 483 | } |
| 484 | |
| 485 | if (CurrentModule->getDataLayout().empty()) { |
| 486 | std::string dataLayout; |
| 487 | if (Endian != Module::AnyEndianness) |
| 488 | dataLayout.append(Endian == Module::BigEndian ? "E" : "e"); |
| 489 | if (PointerSize != Module::AnyPointerSize) { |
| 490 | if (!dataLayout.empty()) |
| 491 | dataLayout += "-"; |
| 492 | dataLayout.append(PointerSize == Module::Pointer64 ? |
| 493 | "p:64:64" : "p:32:32"); |
| 494 | } |
| 495 | CurrentModule->setDataLayout(dataLayout); |
| 496 | } |
| 497 | |
| 498 | Values.clear(); // Clear out function local definitions |
| 499 | Types.clear(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 500 | TypeSigns.clear(); |
| 501 | NamedTypeSigns.clear(); |
| 502 | NamedValueSigns.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 503 | CurrentModule = 0; |
| 504 | } |
| 505 | |
| 506 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 507 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 508 | // If not, just return null. |
| 509 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 510 | // Check to see if there is a forward reference to this global variable... |
| 511 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 512 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 513 | GlobalValue *Ret = 0; |
| 514 | if (I != GlobalRefs.end()) { |
| 515 | Ret = I->second; |
| 516 | GlobalRefs.erase(I); |
| 517 | } |
| 518 | return Ret; |
| 519 | } |
| 520 | void setEndianness(Module::Endianness E) { Endian = E; } |
| 521 | void setPointerSize(Module::PointerSize sz) { PointerSize = sz; } |
| 522 | } CurModule; |
| 523 | |
| 524 | Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness; |
| 525 | Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize; |
| 526 | |
| 527 | static struct PerFunctionInfo { |
| 528 | Function *CurrentFunction; // Pointer to current function being created |
| 529 | |
| 530 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
| 531 | std::map<const Type*, ValueList> LateResolveValues; |
| 532 | bool isDeclare; // Is this function a forward declararation? |
| 533 | GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration. |
| 534 | |
| 535 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 536 | /// track of them here. |
| 537 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 538 | std::vector<BasicBlock*> NumberedBlocks; |
| 539 | RenameMapType RenameMap; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 540 | unsigned NextBBNum; |
| 541 | |
| 542 | inline PerFunctionInfo() { |
| 543 | CurrentFunction = 0; |
| 544 | isDeclare = false; |
| 545 | Linkage = GlobalValue::ExternalLinkage; |
| 546 | } |
| 547 | |
| 548 | inline void FunctionStart(Function *M) { |
| 549 | CurrentFunction = M; |
| 550 | NextBBNum = 0; |
| 551 | } |
| 552 | |
| 553 | void FunctionDone() { |
| 554 | NumberedBlocks.clear(); |
| 555 | |
| 556 | // Any forward referenced blocks left? |
| 557 | if (!BBForwardRefs.empty()) { |
| 558 | error("Undefined reference to label " + |
| 559 | BBForwardRefs.begin()->first->getName()); |
| 560 | return; |
| 561 | } |
| 562 | |
| 563 | // Resolve all forward references now. |
| 564 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 565 | |
| 566 | Values.clear(); // Clear out function local definitions |
| 567 | RenameMap.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 568 | CurrentFunction = 0; |
| 569 | isDeclare = false; |
| 570 | Linkage = GlobalValue::ExternalLinkage; |
| 571 | } |
| 572 | } CurFun; // Info for the current function... |
| 573 | |
| 574 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 575 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 576 | /// This function is just a utility to make a Key value for the rename map. |
| 577 | /// The Key is a combination of the name, type, Signedness of the original |
| 578 | /// value (global/function). This just constructs the key and ensures that |
| 579 | /// named Signedness values are resolved to the actual Signedness. |
| 580 | /// @brief Make a key for the RenameMaps |
| 581 | static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty, |
| 582 | const Signedness &Sign) { |
| 583 | TypeInfo TI; |
| 584 | TI.T = Ty; |
| 585 | if (Sign.isNamed()) |
| 586 | // Don't allow Named Signedness nodes because they won't match. The actual |
| 587 | // Signedness must be looked up in the NamedTypeSigns map. |
| 588 | TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]); |
| 589 | else |
| 590 | TI.S.copy(Sign); |
| 591 | return std::make_pair(Name, TI); |
| 592 | } |
| 593 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 594 | |
| 595 | //===----------------------------------------------------------------------===// |
| 596 | // Code to handle definitions of all the types |
| 597 | //===----------------------------------------------------------------------===// |
| 598 | |
| 599 | static int InsertValue(Value *V, |
| 600 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 601 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 602 | |
| 603 | // Yes, insert the value into the value table... |
| 604 | ValueList &List = ValueTab[V->getType()]; |
| 605 | List.push_back(V); |
| 606 | return List.size()-1; |
| 607 | } |
| 608 | |
Reid Spencer | d7c4f8c | 2007-01-26 19:59:25 +0000 | [diff] [blame] | 609 | static const Type *getType(const ValID &D, bool DoNotImprovise = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 610 | switch (D.Type) { |
| 611 | case ValID::NumberVal: // Is it a numbered definition? |
| 612 | // Module constants occupy the lowest numbered slots... |
| 613 | if ((unsigned)D.Num < CurModule.Types.size()) { |
| 614 | return CurModule.Types[(unsigned)D.Num]; |
| 615 | } |
| 616 | break; |
| 617 | case ValID::NameVal: // Is it a named definition? |
| 618 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 619 | return N; |
| 620 | } |
| 621 | break; |
| 622 | default: |
| 623 | error("Internal parser error: Invalid symbol type reference"); |
| 624 | return 0; |
| 625 | } |
| 626 | |
| 627 | // If we reached here, we referenced either a symbol that we don't know about |
| 628 | // or an id number that hasn't been read yet. We may be referencing something |
| 629 | // forward, so just create an entry to be resolved later and get to it... |
| 630 | // |
| 631 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 632 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 633 | if (inFunctionScope()) { |
| 634 | if (D.Type == ValID::NameVal) { |
| 635 | error("Reference to an undefined type: '" + D.getName() + "'"); |
| 636 | return 0; |
| 637 | } else { |
| 638 | error("Reference to an undefined type: #" + itostr(D.Num)); |
| 639 | return 0; |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 644 | if (I != CurModule.LateResolveTypes.end()) |
| 645 | return I->second; |
| 646 | |
| 647 | Type *Typ = OpaqueType::get(); |
| 648 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 649 | return Typ; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | /// This is like the getType method except that instead of looking up the type |
| 653 | /// for a given ID, it looks up that type's sign. |
| 654 | /// @brief Get the signedness of a referenced type |
| 655 | static Signedness getTypeSign(const ValID &D) { |
| 656 | switch (D.Type) { |
| 657 | case ValID::NumberVal: // Is it a numbered definition? |
| 658 | // Module constants occupy the lowest numbered slots... |
| 659 | if ((unsigned)D.Num < CurModule.TypeSigns.size()) { |
| 660 | return CurModule.TypeSigns[(unsigned)D.Num]; |
| 661 | } |
| 662 | break; |
| 663 | case ValID::NameVal: { // Is it a named definition? |
| 664 | std::map<std::string,Signedness>::const_iterator I = |
| 665 | CurModule.NamedTypeSigns.find(D.Name); |
| 666 | if (I != CurModule.NamedTypeSigns.end()) |
| 667 | return I->second; |
| 668 | // Perhaps its a named forward .. just cache the name |
| 669 | Signedness S; |
| 670 | S.makeNamed(D.Name); |
| 671 | return S; |
| 672 | } |
| 673 | default: |
| 674 | break; |
| 675 | } |
| 676 | // If we don't find it, its signless |
| 677 | Signedness S; |
| 678 | S.makeSignless(); |
| 679 | return S; |
| 680 | } |
| 681 | |
| 682 | /// This function is analagous to getElementType in LLVM. It provides the same |
| 683 | /// function except that it looks up the Signedness instead of the type. This is |
| 684 | /// used when processing GEP instructions that need to extract the type of an |
| 685 | /// indexed struct/array/ptr member. |
| 686 | /// @brief Look up an element's sign. |
| 687 | static Signedness getElementSign(const ValueInfo& VI, |
| 688 | const std::vector<Value*> &Indices) { |
| 689 | const Type *Ptr = VI.V->getType(); |
| 690 | assert(isa<PointerType>(Ptr) && "Need pointer type"); |
| 691 | |
| 692 | unsigned CurIdx = 0; |
| 693 | Signedness S(VI.S); |
| 694 | while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) { |
| 695 | if (CurIdx == Indices.size()) |
| 696 | break; |
| 697 | |
| 698 | Value *Index = Indices[CurIdx++]; |
| 699 | assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type"); |
| 700 | Ptr = CT->getTypeAtIndex(Index); |
| 701 | if (const Type* Ty = Ptr->getForwardedType()) |
| 702 | Ptr = Ty; |
| 703 | assert(S.isComposite() && "Bad Signedness type"); |
| 704 | if (isa<StructType>(CT)) { |
| 705 | S = S.get(cast<ConstantInt>(Index)->getZExtValue()); |
| 706 | } else { |
| 707 | S = S.get(0UL); |
| 708 | } |
| 709 | if (S.isNamed()) |
| 710 | S = CurModule.NamedTypeSigns[S.getName()]; |
| 711 | } |
| 712 | Signedness Result; |
| 713 | Result.makeComposite(S); |
| 714 | return Result; |
| 715 | } |
| 716 | |
| 717 | /// This function just translates a ConstantInfo into a ValueInfo and calls |
| 718 | /// getElementSign(ValueInfo,...). Its just a convenience. |
| 719 | /// @brief ConstantInfo version of getElementSign. |
| 720 | static Signedness getElementSign(const ConstInfo& CI, |
| 721 | const std::vector<Constant*> &Indices) { |
| 722 | ValueInfo VI; |
| 723 | VI.V = CI.C; |
| 724 | VI.S.copy(CI.S); |
| 725 | std::vector<Value*> Idx; |
| 726 | for (unsigned i = 0; i < Indices.size(); ++i) |
| 727 | Idx.push_back(Indices[i]); |
| 728 | Signedness result = getElementSign(VI, Idx); |
| 729 | VI.destroy(); |
| 730 | return result; |
| 731 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 732 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 733 | /// This function determines if two function types differ only in their use of |
| 734 | /// the sret parameter attribute in the first argument. If they are identical |
| 735 | /// in all other respects, it returns true. Otherwise, it returns false. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 736 | static bool FuncTysDifferOnlyBySRet(const FunctionType *F1, |
| 737 | const FunctionType *F2) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 738 | if (F1->getReturnType() != F2->getReturnType() || |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 739 | F1->getNumParams() != F2->getNumParams()) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 740 | return false; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 741 | const ParamAttrsList *PAL1 = F1->getParamAttrs(); |
| 742 | const ParamAttrsList *PAL2 = F2->getParamAttrs(); |
| 743 | if (PAL1 && !PAL2 || PAL2 && !PAL1) |
| 744 | return false; |
| 745 | if (PAL1 && PAL2 && ((PAL1->size() != PAL2->size()) || |
| 746 | (PAL1->getParamAttrs(0) != PAL2->getParamAttrs(0)))) |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 747 | return false; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 748 | unsigned SRetMask = ~unsigned(ParamAttr::StructRet); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 749 | for (unsigned i = 0; i < F1->getNumParams(); ++i) { |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 750 | if (F1->getParamType(i) != F2->getParamType(i) || (PAL1 && PAL2 && |
| 751 | (unsigned(PAL1->getParamAttrs(i+1)) & SRetMask != |
| 752 | unsigned(PAL2->getParamAttrs(i+1)) & SRetMask))) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 753 | return false; |
| 754 | } |
| 755 | return true; |
| 756 | } |
| 757 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 758 | /// This function determines if the type of V and Ty differ only by the SRet |
| 759 | /// parameter attribute. This is a more generalized case of |
| 760 | /// FuncTysDIfferOnlyBySRet since it doesn't require FunctionType arguments. |
| 761 | static bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) { |
| 762 | if (V->getType() == Ty) |
| 763 | return true; |
| 764 | const PointerType *PF1 = dyn_cast<PointerType>(Ty); |
| 765 | const PointerType *PF2 = dyn_cast<PointerType>(V->getType()); |
| 766 | if (PF1 && PF2) { |
| 767 | const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType()); |
| 768 | const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType()); |
| 769 | if (FT1 && FT2) |
| 770 | return FuncTysDifferOnlyBySRet(FT1, FT2); |
| 771 | } |
| 772 | return false; |
| 773 | } |
| 774 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 775 | // The upgrade of csretcc to sret param attribute may have caused a function |
| 776 | // to not be found because the param attribute changed the type of the called |
| 777 | // function. This helper function, used in getExistingValue, detects that |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 778 | // situation and bitcasts the function to the correct type. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 779 | static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) { |
| 780 | // Handle degenerate cases |
| 781 | if (!V) |
| 782 | return 0; |
| 783 | if (V->getType() == Ty) |
| 784 | return V; |
| 785 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 786 | const PointerType *PF1 = dyn_cast<PointerType>(Ty); |
| 787 | const PointerType *PF2 = dyn_cast<PointerType>(V->getType()); |
| 788 | if (PF1 && PF2) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 789 | const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType()); |
| 790 | const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType()); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 791 | if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2)) { |
| 792 | const ParamAttrsList *PAL2 = FT2->getParamAttrs(); |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 793 | if (PAL2 && PAL2->paramHasAttr(1, ParamAttr::StructRet)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 794 | return V; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 795 | else if (Constant *C = dyn_cast<Constant>(V)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 796 | return ConstantExpr::getBitCast(C, PF1); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 797 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 798 | return new BitCastInst(V, PF1, "upgrd.cast", CurBB); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 799 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 800 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 801 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 802 | return 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 803 | } |
| 804 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 805 | // getExistingValue - Look up the value specified by the provided type and |
| 806 | // the provided ValID. If the value exists and has already been defined, return |
| 807 | // it. Otherwise return null. |
| 808 | // |
| 809 | static Value *getExistingValue(const Type *Ty, const ValID &D) { |
| 810 | if (isa<FunctionType>(Ty)) { |
| 811 | error("Functions are not values and must be referenced as pointers"); |
| 812 | } |
| 813 | |
| 814 | switch (D.Type) { |
| 815 | case ValID::NumberVal: { // Is it a numbered definition? |
| 816 | unsigned Num = (unsigned)D.Num; |
| 817 | |
| 818 | // Module constants occupy the lowest numbered slots... |
| 819 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 820 | if (VI != CurModule.Values.end()) { |
| 821 | if (Num < VI->second.size()) |
| 822 | return VI->second[Num]; |
| 823 | Num -= VI->second.size(); |
| 824 | } |
| 825 | |
| 826 | // Make sure that our type is within bounds |
| 827 | VI = CurFun.Values.find(Ty); |
| 828 | if (VI == CurFun.Values.end()) return 0; |
| 829 | |
| 830 | // Check that the number is within bounds... |
| 831 | if (VI->second.size() <= Num) return 0; |
| 832 | |
| 833 | return VI->second[Num]; |
| 834 | } |
| 835 | |
| 836 | case ValID::NameVal: { // Is it a named definition? |
| 837 | // Get the name out of the ID |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 838 | RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S); |
| 839 | Value *V = 0; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 840 | if (inFunctionScope()) { |
| 841 | // See if the name was renamed |
| 842 | RenameMapType::const_iterator I = CurFun.RenameMap.find(Key); |
| 843 | std::string LookupName; |
| 844 | if (I != CurFun.RenameMap.end()) |
| 845 | LookupName = I->second; |
| 846 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 847 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 848 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 849 | V = SymTab.lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 850 | if (V && V->getType() != Ty) |
| 851 | V = handleSRetFuncTypeMerge(V, Ty); |
| 852 | assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 853 | } |
| 854 | if (!V) { |
| 855 | RenameMapType::const_iterator I = CurModule.RenameMap.find(Key); |
| 856 | std::string LookupName; |
| 857 | if (I != CurModule.RenameMap.end()) |
| 858 | LookupName = I->second; |
| 859 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 860 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 861 | V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 862 | if (V && V->getType() != Ty) |
| 863 | V = handleSRetFuncTypeMerge(V, Ty); |
| 864 | assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 865 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 866 | if (!V) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 867 | return 0; |
| 868 | |
| 869 | D.destroy(); // Free old strdup'd memory... |
| 870 | return V; |
| 871 | } |
| 872 | |
| 873 | // Check to make sure that "Ty" is an integral type, and that our |
| 874 | // value will fit into the specified type... |
| 875 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
| 876 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
| 877 | error("Signed integral constant '" + itostr(D.ConstPool64) + |
| 878 | "' is invalid for type '" + Ty->getDescription() + "'"); |
| 879 | } |
| 880 | return ConstantInt::get(Ty, D.ConstPool64); |
| 881 | |
| 882 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
| 883 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 884 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) |
| 885 | error("Integral constant '" + utostr(D.UConstPool64) + |
| 886 | "' is invalid or out of range"); |
| 887 | else // This is really a signed reference. Transmogrify. |
| 888 | return ConstantInt::get(Ty, D.ConstPool64); |
| 889 | } else |
| 890 | return ConstantInt::get(Ty, D.UConstPool64); |
| 891 | |
| 892 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
| 893 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) |
| 894 | error("FP constant invalid for type"); |
| 895 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 896 | |
| 897 | case ValID::ConstNullVal: // Is it a null value? |
| 898 | if (!isa<PointerType>(Ty)) |
| 899 | error("Cannot create a a non pointer null"); |
| 900 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 901 | |
| 902 | case ValID::ConstUndefVal: // Is it an undef value? |
| 903 | return UndefValue::get(Ty); |
| 904 | |
| 905 | case ValID::ConstZeroVal: // Is it a zero value? |
| 906 | return Constant::getNullValue(Ty); |
| 907 | |
| 908 | case ValID::ConstantVal: // Fully resolved constant? |
| 909 | if (D.ConstantValue->getType() != Ty) |
| 910 | error("Constant expression type different from required type"); |
| 911 | return D.ConstantValue; |
| 912 | |
| 913 | case ValID::InlineAsmVal: { // Inline asm expression |
| 914 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 915 | const FunctionType *FTy = |
| 916 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
| 917 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) |
| 918 | error("Invalid type for asm constraint string"); |
| 919 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 920 | D.IAD->HasSideEffects); |
| 921 | D.destroy(); // Free InlineAsmDescriptor. |
| 922 | return IA; |
| 923 | } |
| 924 | default: |
| 925 | assert(0 && "Unhandled case"); |
| 926 | return 0; |
| 927 | } // End of switch |
| 928 | |
| 929 | assert(0 && "Unhandled case"); |
| 930 | return 0; |
| 931 | } |
| 932 | |
| 933 | // getVal - This function is identical to getExistingValue, except that if a |
| 934 | // value is not already defined, it "improvises" by creating a placeholder var |
| 935 | // that looks and acts just like the requested variable. When the value is |
| 936 | // defined later, all uses of the placeholder variable are replaced with the |
| 937 | // real thing. |
| 938 | // |
| 939 | static Value *getVal(const Type *Ty, const ValID &ID) { |
| 940 | if (Ty == Type::LabelTy) |
| 941 | error("Cannot use a basic block here"); |
| 942 | |
| 943 | // See if the value has already been defined. |
| 944 | Value *V = getExistingValue(Ty, ID); |
| 945 | if (V) return V; |
| 946 | |
| 947 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) |
| 948 | error("Invalid use of a composite type"); |
| 949 | |
| 950 | // If we reached here, we referenced either a symbol that we don't know about |
| 951 | // or an id number that hasn't been read yet. We may be referencing something |
| 952 | // 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] | 953 | V = new Argument(Ty); |
| 954 | |
| 955 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 956 | // to recycle these things?? |
| 957 | CurModule.PlaceHolderInfo.insert( |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 958 | std::make_pair(V, std::make_pair(ID, Upgradelineno))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 959 | |
| 960 | if (inFunctionScope()) |
| 961 | InsertValue(V, CurFun.LateResolveValues); |
| 962 | else |
| 963 | InsertValue(V, CurModule.LateResolveValues); |
| 964 | return V; |
| 965 | } |
| 966 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 967 | /// @brief This just makes any name given to it unique, up to MAX_UINT times. |
| 968 | static std::string makeNameUnique(const std::string& Name) { |
| 969 | static unsigned UniqueNameCounter = 1; |
| 970 | std::string Result(Name); |
| 971 | Result += ".upgrd." + llvm::utostr(UniqueNameCounter++); |
| 972 | return Result; |
| 973 | } |
| 974 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 975 | /// getBBVal - This is used for two purposes: |
| 976 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 977 | /// defined. |
| 978 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 979 | /// or may not be a forward reference. |
| 980 | /// |
| 981 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 982 | assert(inFunctionScope() && "Can't get basic block at global scope"); |
| 983 | |
| 984 | std::string Name; |
| 985 | BasicBlock *BB = 0; |
| 986 | switch (ID.Type) { |
| 987 | default: |
| 988 | error("Illegal label reference " + ID.getName()); |
| 989 | break; |
| 990 | case ValID::NumberVal: // Is it a numbered definition? |
| 991 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 992 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 993 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 994 | break; |
| 995 | case ValID::NameVal: // Is it a named definition? |
| 996 | Name = ID.Name; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 997 | if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 998 | if (N->getType() != Type::LabelTy) { |
| 999 | // Register names didn't use to conflict with basic block names |
| 1000 | // because of type planes. Now they all have to be unique. So, we just |
| 1001 | // rename the register and treat this name as if no basic block |
| 1002 | // had been found. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1003 | RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1004 | N->setName(makeNameUnique(N->getName())); |
| 1005 | CurModule.RenameMap[Key] = N->getName(); |
| 1006 | BB = 0; |
| 1007 | } else { |
| 1008 | BB = cast<BasicBlock>(N); |
| 1009 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1010 | } |
| 1011 | break; |
| 1012 | } |
| 1013 | |
| 1014 | // See if the block has already been defined. |
| 1015 | if (BB) { |
| 1016 | // If this is the definition of the block, make sure the existing value was |
| 1017 | // just a forward reference. If it was a forward reference, there will be |
| 1018 | // an entry for it in the PlaceHolderInfo map. |
| 1019 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) |
| 1020 | // The existing value was a definition, not a forward reference. |
| 1021 | error("Redefinition of label " + ID.getName()); |
| 1022 | |
| 1023 | ID.destroy(); // Free strdup'd memory. |
| 1024 | return BB; |
| 1025 | } |
| 1026 | |
| 1027 | // Otherwise this block has not been seen before. |
| 1028 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 1029 | if (ID.Type == ValID::NameVal) { |
| 1030 | BB->setName(ID.Name); |
| 1031 | } else { |
| 1032 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 1033 | } |
| 1034 | |
| 1035 | // If this is not a definition, keep track of it so we can use it as a forward |
| 1036 | // reference. |
| 1037 | if (!isDefinition) { |
| 1038 | // Remember where this forward reference came from. |
| 1039 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno); |
| 1040 | } else { |
| 1041 | // The forward declaration could have been inserted anywhere in the |
| 1042 | // function: insert it into the correct place now. |
| 1043 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 1044 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 1045 | } |
| 1046 | ID.destroy(); |
| 1047 | return BB; |
| 1048 | } |
| 1049 | |
| 1050 | |
| 1051 | //===----------------------------------------------------------------------===// |
| 1052 | // Code to handle forward references in instructions |
| 1053 | //===----------------------------------------------------------------------===// |
| 1054 | // |
| 1055 | // This code handles the late binding needed with statements that reference |
| 1056 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 1057 | // a loop body. |
| 1058 | // |
| 1059 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 1060 | // and back patchs after we are done. |
| 1061 | // |
| 1062 | |
| 1063 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 1064 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 1065 | // defs now... |
| 1066 | // |
| 1067 | static void |
| 1068 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 1069 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1070 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1071 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 1072 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 1073 | E = LateResolvers.end(); LRI != E; ++LRI) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1074 | const Type* Ty = LRI->first; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1075 | ValueList &List = LRI->second; |
| 1076 | while (!List.empty()) { |
| 1077 | Value *V = List.back(); |
| 1078 | List.pop_back(); |
| 1079 | |
| 1080 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 1081 | CurModule.PlaceHolderInfo.find(V); |
| 1082 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error"); |
| 1083 | |
| 1084 | ValID &DID = PHI->second.first; |
| 1085 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1086 | Value *TheRealValue = getExistingValue(Ty, DID); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1087 | if (TheRealValue) { |
| 1088 | V->replaceAllUsesWith(TheRealValue); |
| 1089 | delete V; |
| 1090 | CurModule.PlaceHolderInfo.erase(PHI); |
| 1091 | } else if (FutureLateResolvers) { |
| 1092 | // Functions have their unresolved items forwarded to the module late |
| 1093 | // resolver table |
| 1094 | InsertValue(V, *FutureLateResolvers); |
| 1095 | } else { |
| 1096 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 1097 | error("Reference to an invalid definition: '" + DID.getName() + |
| 1098 | "' of type '" + V->getType()->getDescription() + "'", |
| 1099 | PHI->second.second); |
Reid Spencer | 7de2e01 | 2007-01-29 19:08:46 +0000 | [diff] [blame] | 1100 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1101 | } else { |
| 1102 | error("Reference to an invalid definition: #" + |
| 1103 | itostr(DID.Num) + " of type '" + |
| 1104 | V->getType()->getDescription() + "'", PHI->second.second); |
| 1105 | return; |
| 1106 | } |
| 1107 | } |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | LateResolvers.clear(); |
| 1112 | } |
| 1113 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1114 | /// This function is used for type resolution and upref handling. When a type |
| 1115 | /// becomes concrete, this function is called to adjust the signedness for the |
| 1116 | /// concrete type. |
| 1117 | static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) { |
| 1118 | std::string TyName = CurModule.CurrentModule->getTypeName(oldTy); |
| 1119 | if (!TyName.empty()) |
| 1120 | CurModule.NamedTypeSigns[TyName] = Sign; |
| 1121 | } |
| 1122 | |
| 1123 | /// ResolveTypeTo - A brand new type was just declared. This means that (if |
| 1124 | /// name is not null) things referencing Name can be resolved. Otherwise, |
| 1125 | /// things refering to the number can be resolved. Do this now. |
| 1126 | static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1127 | ValID D; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1128 | if (Name) |
| 1129 | D = ValID::create(Name); |
| 1130 | else |
| 1131 | D = ValID::create((int)CurModule.Types.size()); |
| 1132 | D.S.copy(Sign); |
| 1133 | |
Reid Spencer | baba98a | 2007-04-11 12:10:58 +0000 | [diff] [blame] | 1134 | if (Name) |
| 1135 | CurModule.NamedTypeSigns[Name] = Sign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1136 | |
| 1137 | std::map<ValID, PATypeHolder>::iterator I = |
| 1138 | CurModule.LateResolveTypes.find(D); |
| 1139 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1140 | const Type *OldTy = I->second.get(); |
| 1141 | ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1142 | CurModule.LateResolveTypes.erase(I); |
| 1143 | } |
| 1144 | } |
| 1145 | |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1146 | /// This is the implementation portion of TypeHasInteger. It traverses the |
| 1147 | /// type given, avoiding recursive types, and returns true as soon as it finds |
| 1148 | /// an integer type. If no integer type is found, it returns false. |
| 1149 | static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) { |
| 1150 | // Handle some easy cases |
| 1151 | if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID)) |
| 1152 | return false; |
| 1153 | if (Ty->isInteger()) |
| 1154 | return true; |
| 1155 | if (const SequentialType *STy = dyn_cast<SequentialType>(Ty)) |
| 1156 | return STy->getElementType()->isInteger(); |
| 1157 | |
| 1158 | // Avoid type structure recursion |
| 1159 | for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end(); |
| 1160 | I != E; ++I) |
| 1161 | if (Ty == *I) |
| 1162 | return false; |
| 1163 | |
| 1164 | // Push us on the type stack |
| 1165 | Stack.push_back(Ty); |
| 1166 | |
| 1167 | if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) { |
| 1168 | if (TypeHasIntegerI(FTy->getReturnType(), Stack)) |
| 1169 | return true; |
| 1170 | FunctionType::param_iterator I = FTy->param_begin(); |
| 1171 | FunctionType::param_iterator E = FTy->param_end(); |
| 1172 | for (; I != E; ++I) |
| 1173 | if (TypeHasIntegerI(*I, Stack)) |
| 1174 | return true; |
| 1175 | return false; |
| 1176 | } else if (const StructType *STy = dyn_cast<StructType>(Ty)) { |
| 1177 | StructType::element_iterator I = STy->element_begin(); |
| 1178 | StructType::element_iterator E = STy->element_end(); |
| 1179 | for (; I != E; ++I) { |
| 1180 | if (TypeHasIntegerI(*I, Stack)) |
| 1181 | return true; |
| 1182 | } |
| 1183 | return false; |
| 1184 | } |
| 1185 | // There shouldn't be anything else, but its definitely not integer |
| 1186 | assert(0 && "What type is this?"); |
| 1187 | return false; |
| 1188 | } |
| 1189 | |
| 1190 | /// This is the interface to TypeHasIntegerI. It just provides the type stack, |
| 1191 | /// to avoid recursion, and then calls TypeHasIntegerI. |
| 1192 | static inline bool TypeHasInteger(const Type *Ty) { |
| 1193 | std::vector<const Type*> TyStack; |
| 1194 | return TypeHasIntegerI(Ty, TyStack); |
| 1195 | } |
| 1196 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1197 | // setValueName - Set the specified value to the name given. The name may be |
| 1198 | // null potentially, in which case this is a noop. The string passed in is |
| 1199 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 1200 | // |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1201 | static void setValueName(const ValueInfo &V, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1202 | if (NameStr) { |
| 1203 | std::string Name(NameStr); // Copy string |
| 1204 | free(NameStr); // Free old string |
| 1205 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1206 | if (V.V->getType() == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1207 | error("Can't assign name '" + Name + "' to value with void type"); |
| 1208 | return; |
| 1209 | } |
| 1210 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1211 | assert(inFunctionScope() && "Must be in function scope"); |
| 1212 | |
| 1213 | // 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] | 1214 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 1215 | Value* Existing = ST.lookup(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1216 | if (Existing) { |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1217 | // An existing value of the same name was found. This might have happened |
| 1218 | // because of the integer type planes collapsing in LLVM 2.0. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1219 | if (Existing->getType() == V.V->getType() && |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1220 | !TypeHasInteger(Existing->getType())) { |
| 1221 | // If the type does not contain any integers in them then this can't be |
| 1222 | // a type plane collapsing issue. It truly is a redefinition and we |
| 1223 | // should error out as the assembly is invalid. |
| 1224 | error("Redefinition of value named '" + Name + "' of type '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1225 | V.V->getType()->getDescription() + "'"); |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 1226 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1227 | } |
| 1228 | // In LLVM 2.0 we don't allow names to be re-used for any values in a |
| 1229 | // function, regardless of Type. Previously re-use of names was okay as |
| 1230 | // long as they were distinct types. With type planes collapsing because |
| 1231 | // of the signedness change and because of PR411, this can no longer be |
| 1232 | // supported. We must search the entire symbol table for a conflicting |
| 1233 | // name and make the name unique. No warning is needed as this can't |
| 1234 | // cause a problem. |
| 1235 | std::string NewName = makeNameUnique(Name); |
| 1236 | // We're changing the name but it will probably be used by other |
| 1237 | // instructions as operands later on. Consequently we have to retain |
| 1238 | // a mapping of the renaming that we're doing. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1239 | RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1240 | CurFun.RenameMap[Key] = NewName; |
| 1241 | Name = NewName; |
| 1242 | } |
| 1243 | |
| 1244 | // Set the name. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1245 | V.V->setName(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 1250 | /// this is a declaration, otherwise it is a definition. |
| 1251 | static GlobalVariable * |
| 1252 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 1253 | bool isConstantGlobal, const Type *Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1254 | Constant *Initializer, |
| 1255 | const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1256 | if (isa<FunctionType>(Ty)) |
| 1257 | error("Cannot declare global vars of function type"); |
| 1258 | |
| 1259 | const PointerType *PTy = PointerType::get(Ty); |
| 1260 | |
| 1261 | std::string Name; |
| 1262 | if (NameStr) { |
| 1263 | Name = NameStr; // Copy string |
| 1264 | free(NameStr); // Free old string |
| 1265 | } |
| 1266 | |
| 1267 | // See if this global value was forward referenced. If so, recycle the |
| 1268 | // object. |
| 1269 | ValID ID; |
| 1270 | if (!Name.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1271 | ID = ValID::create((char*)Name.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1272 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 1273 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1274 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1275 | ID.S.makeComposite(Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1276 | |
| 1277 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1278 | // Move the global to the end of the list, from whereever it was |
| 1279 | // previously inserted. |
| 1280 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1281 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1282 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1283 | GV->setInitializer(Initializer); |
| 1284 | GV->setLinkage(Linkage); |
| 1285 | GV->setConstant(isConstantGlobal); |
| 1286 | InsertValue(GV, CurModule.Values); |
| 1287 | return GV; |
| 1288 | } |
| 1289 | |
| 1290 | // If this global has a name, check to see if there is already a definition |
| 1291 | // of this global in the module and emit warnings if there are conflicts. |
| 1292 | if (!Name.empty()) { |
| 1293 | // The global has a name. See if there's an existing one of the same name. |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 1294 | if (CurModule.CurrentModule->getNamedGlobal(Name) || |
| 1295 | CurModule.CurrentModule->getFunction(Name)) { |
| 1296 | // We found an existing global of the same name. This isn't allowed |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1297 | // in LLVM 2.0. Consequently, we must alter the name of the global so it |
| 1298 | // can at least compile. This can happen because of type planes |
| 1299 | // There is alread a global of the same name which means there is a |
| 1300 | // conflict. Let's see what we can do about it. |
| 1301 | std::string NewName(makeNameUnique(Name)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1302 | if (Linkage != GlobalValue::InternalLinkage) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1303 | // The linkage of this gval is external so we can't reliably rename |
| 1304 | // it because it could potentially create a linking problem. |
| 1305 | // However, we can't leave the name conflict in the output either or |
| 1306 | // it won't assemble with LLVM 2.0. So, all we can do is rename |
| 1307 | // this one to something unique and emit a warning about the problem. |
| 1308 | warning("Renaming global variable '" + Name + "' to '" + NewName + |
| 1309 | "' may cause linkage errors"); |
| 1310 | } |
| 1311 | |
| 1312 | // Put the renaming in the global rename map |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1313 | RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1314 | CurModule.RenameMap[Key] = NewName; |
| 1315 | |
| 1316 | // Rename it |
| 1317 | Name = NewName; |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | // Otherwise there is no existing GV to use, create one now. |
| 1322 | GlobalVariable *GV = |
| 1323 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 1324 | CurModule.CurrentModule); |
| 1325 | InsertValue(GV, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1326 | // Remember the sign of this global. |
| 1327 | CurModule.NamedValueSigns[Name] = ID.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1328 | return GV; |
| 1329 | } |
| 1330 | |
| 1331 | // setTypeName - Set the specified type to the name given. The name may be |
| 1332 | // null potentially, in which case this is a noop. The string passed in is |
| 1333 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1334 | // |
| 1335 | // This function returns true if the type has already been defined, but is |
| 1336 | // allowed to be redefined in the specified context. If the name is a new name |
| 1337 | // for the type plane, it is inserted and false is returned. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1338 | static bool setTypeName(const PATypeInfo& TI, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1339 | assert(!inFunctionScope() && "Can't give types function-local names"); |
| 1340 | if (NameStr == 0) return false; |
| 1341 | |
| 1342 | std::string Name(NameStr); // Copy string |
| 1343 | free(NameStr); // Free old string |
| 1344 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1345 | const Type* Ty = TI.PAT->get(); |
| 1346 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1347 | // We don't allow assigning names to void type |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1348 | if (Ty == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1349 | error("Can't assign name '" + Name + "' to the void type"); |
| 1350 | return false; |
| 1351 | } |
| 1352 | |
| 1353 | // Set the type name, checking for conflicts as we do so. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1354 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty); |
| 1355 | |
| 1356 | // Save the sign information for later use |
| 1357 | CurModule.NamedTypeSigns[Name] = TI.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1358 | |
| 1359 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1360 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 1361 | assert(Existing && "Conflict but no matching type?"); |
| 1362 | |
| 1363 | // There is only one case where this is allowed: when we are refining an |
| 1364 | // opaque type. In this case, Existing will be an opaque type. |
| 1365 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1366 | // We ARE replacing an opaque type! |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1367 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1368 | return true; |
| 1369 | } |
| 1370 | |
| 1371 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1372 | // the redefinition is identical to the original. This will be so if |
| 1373 | // Existing and T point to the same Type object. In this one case we |
| 1374 | // allow the equivalent redefinition. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1375 | if (Existing == Ty) return true; // Yes, it's equal. |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1376 | |
| 1377 | // Any other kind of (non-equivalent) redefinition is an error. |
| 1378 | error("Redefinition of type named '" + Name + "' in the '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1379 | Ty->getDescription() + "' type plane"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1380 | } |
| 1381 | |
| 1382 | return false; |
| 1383 | } |
| 1384 | |
| 1385 | //===----------------------------------------------------------------------===// |
| 1386 | // Code for handling upreferences in type names... |
| 1387 | // |
| 1388 | |
| 1389 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1390 | // |
| 1391 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1392 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1393 | E) != Ty->subtype_end(); |
| 1394 | } |
| 1395 | |
| 1396 | namespace { |
| 1397 | struct UpRefRecord { |
| 1398 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1399 | // this type is resolved. |
| 1400 | unsigned NestingLevel; |
| 1401 | |
| 1402 | // LastContainedTy - This is the type at the current binding level for the |
| 1403 | // type. Every time we reduce the nesting level, this gets updated. |
| 1404 | const Type *LastContainedTy; |
| 1405 | |
| 1406 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1407 | // represented with. |
| 1408 | OpaqueType *UpRefTy; |
| 1409 | |
| 1410 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1411 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1412 | }; |
| 1413 | } |
| 1414 | |
| 1415 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1416 | static std::vector<UpRefRecord> UpRefs; |
| 1417 | |
| 1418 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1419 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1420 | /// currently active types. For each type, if the up reference is contained in |
| 1421 | /// the newly completed type, we decrement the level count. When the level |
| 1422 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1423 | /// thus we can complete the cycle. |
| 1424 | /// |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1425 | static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1426 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1427 | // nothing to resolve here. |
| 1428 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1429 | |
| 1430 | PATypeHolder Ty(ty); |
| 1431 | UR_OUT("Type '" << Ty->getDescription() << |
| 1432 | "' newly formed. Resolving upreferences.\n" << |
| 1433 | UpRefs.size() << " upreferences active!\n"); |
| 1434 | |
| 1435 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1436 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1437 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1438 | // this variable. |
| 1439 | OpaqueType *TypeToResolve = 0; |
| 1440 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1441 | unsigned i = 0; |
| 1442 | for (; i != UpRefs.size(); ++i) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1443 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1444 | << UpRefs[i].UpRefTy->getDescription() << ") = " |
| 1445 | << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1446 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1447 | // Decrement level of upreference |
| 1448 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1449 | UpRefs[i].LastContainedTy = Ty; |
| 1450 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1451 | if (Level == 0) { // Upreference should be resolved! |
| 1452 | if (!TypeToResolve) { |
| 1453 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1454 | } else { |
| 1455 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1456 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
| 1457 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1458 | ResolveTypeSign(UpRefs[i].UpRefTy, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1459 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1460 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1461 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1462 | } |
| 1463 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1464 | --i; // Do not skip the next element... |
| 1465 | } |
| 1466 | } |
| 1467 | } |
| 1468 | |
| 1469 | if (TypeToResolve) { |
| 1470 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1471 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1472 | std::string OldName = TypeToResolve->getDescription()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1473 | ResolveTypeSign(TypeToResolve, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1474 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1475 | } |
| 1476 | |
| 1477 | return Ty; |
| 1478 | } |
| 1479 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1480 | bool Signedness::operator<(const Signedness &that) const { |
| 1481 | if (isNamed()) { |
| 1482 | if (that.isNamed()) |
| 1483 | return *(this->name) < *(that.name); |
| 1484 | else |
| 1485 | return CurModule.NamedTypeSigns[*name] < that; |
| 1486 | } else if (that.isNamed()) { |
| 1487 | return *this < CurModule.NamedTypeSigns[*that.name]; |
| 1488 | } |
| 1489 | |
| 1490 | if (isComposite() && that.isComposite()) { |
| 1491 | if (sv->size() == that.sv->size()) { |
| 1492 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1493 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1494 | thatE = that.sv->end(); |
| 1495 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1496 | if (*thisI < *thatI) |
| 1497 | return true; |
| 1498 | else if (!(*thisI == *thatI)) |
| 1499 | return false; |
| 1500 | } |
| 1501 | return false; |
| 1502 | } |
| 1503 | return sv->size() < that.sv->size(); |
| 1504 | } |
| 1505 | return kind < that.kind; |
| 1506 | } |
| 1507 | |
| 1508 | bool Signedness::operator==(const Signedness &that) const { |
| 1509 | if (isNamed()) |
| 1510 | if (that.isNamed()) |
| 1511 | return *(this->name) == *(that.name); |
| 1512 | else |
| 1513 | return CurModule.NamedTypeSigns[*(this->name)] == that; |
| 1514 | else if (that.isNamed()) |
| 1515 | return *this == CurModule.NamedTypeSigns[*(that.name)]; |
| 1516 | if (isComposite() && that.isComposite()) { |
| 1517 | if (sv->size() == that.sv->size()) { |
| 1518 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1519 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1520 | thatE = that.sv->end(); |
| 1521 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1522 | if (!(*thisI == *thatI)) |
| 1523 | return false; |
| 1524 | } |
| 1525 | return true; |
| 1526 | } |
| 1527 | return false; |
| 1528 | } |
| 1529 | return kind == that.kind; |
| 1530 | } |
| 1531 | |
| 1532 | void Signedness::copy(const Signedness &that) { |
| 1533 | if (that.isNamed()) { |
| 1534 | kind = Named; |
| 1535 | name = new std::string(*that.name); |
| 1536 | } else if (that.isComposite()) { |
| 1537 | kind = Composite; |
| 1538 | sv = new SignVector(); |
| 1539 | *sv = *that.sv; |
| 1540 | } else { |
| 1541 | kind = that.kind; |
| 1542 | sv = 0; |
| 1543 | } |
| 1544 | } |
| 1545 | |
| 1546 | void Signedness::destroy() { |
| 1547 | if (isNamed()) { |
| 1548 | delete name; |
| 1549 | } else if (isComposite()) { |
| 1550 | delete sv; |
| 1551 | } |
| 1552 | } |
| 1553 | |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1554 | #ifndef NDEBUG |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1555 | void Signedness::dump() const { |
| 1556 | if (isComposite()) { |
| 1557 | if (sv->size() == 1) { |
| 1558 | (*sv)[0].dump(); |
| 1559 | std::cerr << "*"; |
| 1560 | } else { |
| 1561 | std::cerr << "{ " ; |
| 1562 | for (unsigned i = 0; i < sv->size(); ++i) { |
| 1563 | if (i != 0) |
| 1564 | std::cerr << ", "; |
| 1565 | (*sv)[i].dump(); |
| 1566 | } |
| 1567 | std::cerr << "} " ; |
| 1568 | } |
| 1569 | } else if (isNamed()) { |
| 1570 | std::cerr << *name; |
| 1571 | } else if (isSigned()) { |
| 1572 | std::cerr << "S"; |
| 1573 | } else if (isUnsigned()) { |
| 1574 | std::cerr << "U"; |
| 1575 | } else |
| 1576 | std::cerr << "."; |
| 1577 | } |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1578 | #endif |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1579 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1580 | static inline Instruction::TermOps |
| 1581 | getTermOp(TermOps op) { |
| 1582 | switch (op) { |
| 1583 | default : assert(0 && "Invalid OldTermOp"); |
| 1584 | case RetOp : return Instruction::Ret; |
| 1585 | case BrOp : return Instruction::Br; |
| 1586 | case SwitchOp : return Instruction::Switch; |
| 1587 | case InvokeOp : return Instruction::Invoke; |
| 1588 | case UnwindOp : return Instruction::Unwind; |
| 1589 | case UnreachableOp: return Instruction::Unreachable; |
| 1590 | } |
| 1591 | } |
| 1592 | |
| 1593 | static inline Instruction::BinaryOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1594 | getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1595 | switch (op) { |
| 1596 | default : assert(0 && "Invalid OldBinaryOps"); |
| 1597 | case SetEQ : |
| 1598 | case SetNE : |
| 1599 | case SetLE : |
| 1600 | case SetGE : |
| 1601 | case SetLT : |
| 1602 | case SetGT : assert(0 && "Should use getCompareOp"); |
| 1603 | case AddOp : return Instruction::Add; |
| 1604 | case SubOp : return Instruction::Sub; |
| 1605 | case MulOp : return Instruction::Mul; |
| 1606 | case DivOp : { |
| 1607 | // This is an obsolete instruction so we must upgrade it based on the |
| 1608 | // types of its operands. |
| 1609 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1610 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1611 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1612 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1613 | if (isFP) |
| 1614 | return Instruction::FDiv; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1615 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1616 | return Instruction::SDiv; |
| 1617 | return Instruction::UDiv; |
| 1618 | } |
| 1619 | case UDivOp : return Instruction::UDiv; |
| 1620 | case SDivOp : return Instruction::SDiv; |
| 1621 | case FDivOp : return Instruction::FDiv; |
| 1622 | case RemOp : { |
| 1623 | // This is an obsolete instruction so we must upgrade it based on the |
| 1624 | // types of its operands. |
| 1625 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1626 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1627 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1628 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1629 | // Select correct opcode |
| 1630 | if (isFP) |
| 1631 | return Instruction::FRem; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1632 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1633 | return Instruction::SRem; |
| 1634 | return Instruction::URem; |
| 1635 | } |
| 1636 | case URemOp : return Instruction::URem; |
| 1637 | case SRemOp : return Instruction::SRem; |
| 1638 | case FRemOp : return Instruction::FRem; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1639 | case LShrOp : return Instruction::LShr; |
| 1640 | case AShrOp : return Instruction::AShr; |
| 1641 | case ShlOp : return Instruction::Shl; |
| 1642 | case ShrOp : |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1643 | if (Sign.isSigned()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1644 | return Instruction::AShr; |
| 1645 | return Instruction::LShr; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1646 | case AndOp : return Instruction::And; |
| 1647 | case OrOp : return Instruction::Or; |
| 1648 | case XorOp : return Instruction::Xor; |
| 1649 | } |
| 1650 | } |
| 1651 | |
| 1652 | static inline Instruction::OtherOps |
| 1653 | getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1654 | const Signedness &Sign) { |
| 1655 | bool isSigned = Sign.isSigned(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1656 | bool isFP = Ty->isFloatingPoint(); |
| 1657 | switch (op) { |
| 1658 | default : assert(0 && "Invalid OldSetCC"); |
| 1659 | case SetEQ : |
| 1660 | if (isFP) { |
| 1661 | predicate = FCmpInst::FCMP_OEQ; |
| 1662 | return Instruction::FCmp; |
| 1663 | } else { |
| 1664 | predicate = ICmpInst::ICMP_EQ; |
| 1665 | return Instruction::ICmp; |
| 1666 | } |
| 1667 | case SetNE : |
| 1668 | if (isFP) { |
| 1669 | predicate = FCmpInst::FCMP_UNE; |
| 1670 | return Instruction::FCmp; |
| 1671 | } else { |
| 1672 | predicate = ICmpInst::ICMP_NE; |
| 1673 | return Instruction::ICmp; |
| 1674 | } |
| 1675 | case SetLE : |
| 1676 | if (isFP) { |
| 1677 | predicate = FCmpInst::FCMP_OLE; |
| 1678 | return Instruction::FCmp; |
| 1679 | } else { |
| 1680 | if (isSigned) |
| 1681 | predicate = ICmpInst::ICMP_SLE; |
| 1682 | else |
| 1683 | predicate = ICmpInst::ICMP_ULE; |
| 1684 | return Instruction::ICmp; |
| 1685 | } |
| 1686 | case SetGE : |
| 1687 | if (isFP) { |
| 1688 | predicate = FCmpInst::FCMP_OGE; |
| 1689 | return Instruction::FCmp; |
| 1690 | } else { |
| 1691 | if (isSigned) |
| 1692 | predicate = ICmpInst::ICMP_SGE; |
| 1693 | else |
| 1694 | predicate = ICmpInst::ICMP_UGE; |
| 1695 | return Instruction::ICmp; |
| 1696 | } |
| 1697 | case SetLT : |
| 1698 | if (isFP) { |
| 1699 | predicate = FCmpInst::FCMP_OLT; |
| 1700 | return Instruction::FCmp; |
| 1701 | } else { |
| 1702 | if (isSigned) |
| 1703 | predicate = ICmpInst::ICMP_SLT; |
| 1704 | else |
| 1705 | predicate = ICmpInst::ICMP_ULT; |
| 1706 | return Instruction::ICmp; |
| 1707 | } |
| 1708 | case SetGT : |
| 1709 | if (isFP) { |
| 1710 | predicate = FCmpInst::FCMP_OGT; |
| 1711 | return Instruction::FCmp; |
| 1712 | } else { |
| 1713 | if (isSigned) |
| 1714 | predicate = ICmpInst::ICMP_SGT; |
| 1715 | else |
| 1716 | predicate = ICmpInst::ICMP_UGT; |
| 1717 | return Instruction::ICmp; |
| 1718 | } |
| 1719 | } |
| 1720 | } |
| 1721 | |
| 1722 | static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) { |
| 1723 | switch (op) { |
| 1724 | default : assert(0 && "Invalid OldMemoryOps"); |
| 1725 | case MallocOp : return Instruction::Malloc; |
| 1726 | case FreeOp : return Instruction::Free; |
| 1727 | case AllocaOp : return Instruction::Alloca; |
| 1728 | case LoadOp : return Instruction::Load; |
| 1729 | case StoreOp : return Instruction::Store; |
| 1730 | case GetElementPtrOp : return Instruction::GetElementPtr; |
| 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | static inline Instruction::OtherOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1735 | getOtherOp(OtherOps op, const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1736 | switch (op) { |
| 1737 | default : assert(0 && "Invalid OldOtherOps"); |
| 1738 | case PHIOp : return Instruction::PHI; |
| 1739 | case CallOp : return Instruction::Call; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1740 | case SelectOp : return Instruction::Select; |
| 1741 | case UserOp1 : return Instruction::UserOp1; |
| 1742 | case UserOp2 : return Instruction::UserOp2; |
| 1743 | case VAArg : return Instruction::VAArg; |
| 1744 | case ExtractElementOp : return Instruction::ExtractElement; |
| 1745 | case InsertElementOp : return Instruction::InsertElement; |
| 1746 | case ShuffleVectorOp : return Instruction::ShuffleVector; |
| 1747 | case ICmpOp : return Instruction::ICmp; |
| 1748 | case FCmpOp : return Instruction::FCmp; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1749 | }; |
| 1750 | } |
| 1751 | |
| 1752 | static inline Value* |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1753 | getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy, |
| 1754 | const Signedness &DstSign, bool ForceInstruction = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1755 | Instruction::CastOps Opcode; |
| 1756 | const Type* SrcTy = Src->getType(); |
| 1757 | if (op == CastOp) { |
| 1758 | if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) { |
| 1759 | // fp -> ptr cast is no longer supported but we must upgrade this |
| 1760 | // by doing a double cast: fp -> int -> ptr |
| 1761 | SrcTy = Type::Int64Ty; |
| 1762 | Opcode = Instruction::IntToPtr; |
| 1763 | if (isa<Constant>(Src)) { |
| 1764 | Src = ConstantExpr::getCast(Instruction::FPToUI, |
| 1765 | cast<Constant>(Src), SrcTy); |
| 1766 | } else { |
| 1767 | std::string NewName(makeNameUnique(Src->getName())); |
| 1768 | Src = new FPToUIInst(Src, SrcTy, NewName, CurBB); |
| 1769 | } |
| 1770 | } else if (isa<IntegerType>(DstTy) && |
| 1771 | cast<IntegerType>(DstTy)->getBitWidth() == 1) { |
| 1772 | // cast type %x to bool was previously defined as setne type %x, null |
| 1773 | // The cast semantic is now to truncate, not compare so we must retain |
| 1774 | // the original intent by replacing the cast with a setne |
| 1775 | Constant* Null = Constant::getNullValue(SrcTy); |
| 1776 | Instruction::OtherOps Opcode = Instruction::ICmp; |
| 1777 | unsigned short predicate = ICmpInst::ICMP_NE; |
| 1778 | if (SrcTy->isFloatingPoint()) { |
| 1779 | Opcode = Instruction::FCmp; |
| 1780 | predicate = FCmpInst::FCMP_ONE; |
| 1781 | } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) { |
| 1782 | error("Invalid cast to bool"); |
| 1783 | } |
| 1784 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1785 | return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null); |
| 1786 | else |
| 1787 | return CmpInst::create(Opcode, predicate, Src, Null); |
| 1788 | } |
| 1789 | // Determine the opcode to use by calling CastInst::getCastOpcode |
| 1790 | Opcode = |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1791 | CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy, |
| 1792 | DstSign.isSigned()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1793 | |
| 1794 | } else switch (op) { |
| 1795 | default: assert(0 && "Invalid cast token"); |
| 1796 | case TruncOp: Opcode = Instruction::Trunc; break; |
| 1797 | case ZExtOp: Opcode = Instruction::ZExt; break; |
| 1798 | case SExtOp: Opcode = Instruction::SExt; break; |
| 1799 | case FPTruncOp: Opcode = Instruction::FPTrunc; break; |
| 1800 | case FPExtOp: Opcode = Instruction::FPExt; break; |
| 1801 | case FPToUIOp: Opcode = Instruction::FPToUI; break; |
| 1802 | case FPToSIOp: Opcode = Instruction::FPToSI; break; |
| 1803 | case UIToFPOp: Opcode = Instruction::UIToFP; break; |
| 1804 | case SIToFPOp: Opcode = Instruction::SIToFP; break; |
| 1805 | case PtrToIntOp: Opcode = Instruction::PtrToInt; break; |
| 1806 | case IntToPtrOp: Opcode = Instruction::IntToPtr; break; |
| 1807 | case BitCastOp: Opcode = Instruction::BitCast; break; |
| 1808 | } |
| 1809 | |
| 1810 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1811 | return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy); |
| 1812 | return CastInst::create(Opcode, Src, DstTy); |
| 1813 | } |
| 1814 | |
| 1815 | static Instruction * |
| 1816 | upgradeIntrinsicCall(const Type* RetTy, const ValID &ID, |
| 1817 | std::vector<Value*>& Args) { |
| 1818 | |
| 1819 | std::string Name = ID.Type == ValID::NameVal ? ID.Name : ""; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 1820 | if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' || |
| 1821 | Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.') |
| 1822 | return 0; |
| 1823 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1824 | switch (Name[5]) { |
| 1825 | case 'i': |
| 1826 | if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") { |
| 1827 | if (Args.size() != 2) |
| 1828 | error("Invalid prototype for " + Name); |
| 1829 | return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]); |
| 1830 | } |
| 1831 | break; |
| 1832 | case 'b': |
| 1833 | if (Name.length() == 14 && !memcmp(&Name[5], "bswap.i", 7)) { |
| 1834 | const Type* ArgTy = Args[0]->getType(); |
| 1835 | Name += ".i" + utostr(cast<IntegerType>(ArgTy)->getBitWidth()); |
| 1836 | Function *F = cast<Function>( |
| 1837 | CurModule.CurrentModule->getOrInsertFunction(Name, RetTy, ArgTy, |
| 1838 | (void*)0)); |
| 1839 | return new CallInst(F, Args[0]); |
| 1840 | } |
| 1841 | break; |
Reid Spencer | 8166a6c | 2007-04-02 02:08:35 +0000 | [diff] [blame] | 1842 | case 'c': |
| 1843 | if ((Name.length() <= 14 && !memcmp(&Name[5], "ctpop.i", 7)) || |
| 1844 | (Name.length() <= 13 && !memcmp(&Name[5], "ctlz.i", 6)) || |
| 1845 | (Name.length() <= 13 && !memcmp(&Name[5], "cttz.i", 6))) { |
| 1846 | // These intrinsics changed their result type. |
| 1847 | const Type* ArgTy = Args[0]->getType(); |
| 1848 | Function *OldF = CurModule.CurrentModule->getFunction(Name); |
| 1849 | if (OldF) |
| 1850 | OldF->setName("upgrd.rm." + Name); |
| 1851 | |
| 1852 | Function *NewF = cast<Function>( |
| 1853 | CurModule.CurrentModule->getOrInsertFunction(Name, Type::Int32Ty, |
| 1854 | ArgTy, (void*)0)); |
| 1855 | |
| 1856 | Instruction *Call = new CallInst(NewF, Args[0], "", CurBB); |
| 1857 | return CastInst::createIntegerCast(Call, RetTy, false); |
| 1858 | } |
| 1859 | break; |
| 1860 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1861 | case 'v' : { |
| 1862 | const Type* PtrTy = PointerType::get(Type::Int8Ty); |
| 1863 | std::vector<const Type*> Params; |
| 1864 | if (Name == "llvm.va_start" || Name == "llvm.va_end") { |
| 1865 | if (Args.size() != 1) |
| 1866 | error("Invalid prototype for " + Name + " prototype"); |
| 1867 | Params.push_back(PtrTy); |
| 1868 | const FunctionType *FTy = |
| 1869 | FunctionType::get(Type::VoidTy, Params, false); |
| 1870 | const PointerType *PFTy = PointerType::get(FTy); |
| 1871 | Value* Func = getVal(PFTy, ID); |
| 1872 | Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 1873 | return new CallInst(Func, Args.begin(), Args.end()); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1874 | } else if (Name == "llvm.va_copy") { |
| 1875 | if (Args.size() != 2) |
| 1876 | error("Invalid prototype for " + Name + " prototype"); |
| 1877 | Params.push_back(PtrTy); |
| 1878 | Params.push_back(PtrTy); |
| 1879 | const FunctionType *FTy = |
| 1880 | FunctionType::get(Type::VoidTy, Params, false); |
| 1881 | const PointerType *PFTy = PointerType::get(FTy); |
| 1882 | Value* Func = getVal(PFTy, ID); |
| 1883 | std::string InstName0(makeNameUnique("va0")); |
| 1884 | std::string InstName1(makeNameUnique("va1")); |
| 1885 | Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB); |
| 1886 | Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 1887 | return new CallInst(Func, Args.begin(), Args.end()); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1888 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1889 | } |
| 1890 | } |
| 1891 | return 0; |
| 1892 | } |
| 1893 | |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1894 | const Type* upgradeGEPCEIndices(const Type* PTy, |
| 1895 | std::vector<ValueInfo> *Indices, |
| 1896 | std::vector<Constant*> &Result) { |
| 1897 | const Type *Ty = PTy; |
| 1898 | Result.clear(); |
| 1899 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1900 | Constant *Index = cast<Constant>((*Indices)[i].V); |
| 1901 | |
| 1902 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1903 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1904 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1905 | if (CI->getBitWidth() < 32) |
| 1906 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1907 | } |
| 1908 | |
| 1909 | if (isa<SequentialType>(Ty)) { |
| 1910 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1911 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1912 | // all indices for SequentialType elements. We must retain the same |
| 1913 | // semantic (zext) for unsigned types. |
| 1914 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
| 1915 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
| 1916 | Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty); |
| 1917 | } |
| 1918 | } |
| 1919 | } |
| 1920 | Result.push_back(Index); |
| 1921 | Ty = GetElementPtrInst::getIndexedType(PTy, (Value**)&Result[0], |
| 1922 | Result.size(),true); |
| 1923 | if (!Ty) |
| 1924 | error("Index list invalid for constant getelementptr"); |
| 1925 | } |
| 1926 | return Ty; |
| 1927 | } |
| 1928 | |
| 1929 | const Type* upgradeGEPInstIndices(const Type* PTy, |
| 1930 | std::vector<ValueInfo> *Indices, |
| 1931 | std::vector<Value*> &Result) { |
| 1932 | const Type *Ty = PTy; |
| 1933 | Result.clear(); |
| 1934 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1935 | Value *Index = (*Indices)[i].V; |
| 1936 | |
| 1937 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1938 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1939 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1940 | if (CI->getBitWidth() < 32) |
| 1941 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1942 | } |
| 1943 | |
| 1944 | |
| 1945 | if (isa<StructType>(Ty)) { // Only change struct indices |
| 1946 | if (!isa<Constant>(Index)) { |
| 1947 | error("Invalid non-constant structure index"); |
| 1948 | return 0; |
| 1949 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1950 | } else { |
| 1951 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1952 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1953 | // all indices for SequentialType elements. We must retain the same |
| 1954 | // semantic (zext) for unsigned types. |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1955 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1956 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1957 | if (isa<Constant>(Index)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1958 | Index = ConstantExpr::getCast(Instruction::ZExt, |
| 1959 | cast<Constant>(Index), Type::Int64Ty); |
| 1960 | else |
| 1961 | Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty, |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1962 | makeNameUnique("gep"), CurBB); |
Reid Spencer | 38f682b | 2007-01-26 20:31:18 +0000 | [diff] [blame] | 1963 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1964 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1965 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1966 | Result.push_back(Index); |
| 1967 | Ty = GetElementPtrInst::getIndexedType(PTy, &Result[0], Result.size(),true); |
| 1968 | if (!Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1969 | error("Index list invalid for constant getelementptr"); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1970 | } |
| 1971 | return Ty; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1972 | } |
| 1973 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 1974 | unsigned upgradeCallingConv(unsigned CC) { |
| 1975 | switch (CC) { |
| 1976 | case OldCallingConv::C : return CallingConv::C; |
| 1977 | case OldCallingConv::CSRet : return CallingConv::C; |
| 1978 | case OldCallingConv::Fast : return CallingConv::Fast; |
| 1979 | case OldCallingConv::Cold : return CallingConv::Cold; |
| 1980 | case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall; |
| 1981 | case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall; |
| 1982 | default: |
| 1983 | return CC; |
| 1984 | } |
| 1985 | } |
| 1986 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1987 | Module* UpgradeAssembly(const std::string &infile, std::istream& in, |
| 1988 | bool debug, bool addAttrs) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1989 | { |
| 1990 | Upgradelineno = 1; |
| 1991 | CurFilename = infile; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 1992 | LexInput = ∈ |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1993 | yydebug = debug; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 1994 | AddAttributes = addAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1995 | ObsoleteVarArgs = false; |
| 1996 | NewVarArgs = false; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1997 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1998 | CurModule.CurrentModule = new Module(CurFilename); |
| 1999 | |
| 2000 | // Check to make sure the parser succeeded |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2001 | if (yyparse()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2002 | if (ParserResult) |
| 2003 | delete ParserResult; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2004 | std::cerr << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2005 | return 0; |
| 2006 | } |
| 2007 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2008 | // Check to make sure that parsing produced a result |
| 2009 | if (!ParserResult) { |
| 2010 | std::cerr << "llvm-upgrade: no parse result.\n"; |
| 2011 | return 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2012 | } |
| 2013 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2014 | // Reset ParserResult variable while saving its value for the result. |
| 2015 | Module *Result = ParserResult; |
| 2016 | ParserResult = 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2017 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2018 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2019 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2020 | Function* F; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2021 | if ((F = Result->getFunction("llvm.va_start")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2022 | && F->getFunctionType()->getNumParams() == 0) |
| 2023 | ObsoleteVarArgs = true; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2024 | if((F = Result->getFunction("llvm.va_copy")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2025 | && F->getFunctionType()->getNumParams() == 1) |
| 2026 | ObsoleteVarArgs = true; |
Reid Spencer | 280d801 | 2006-12-01 23:40:53 +0000 | [diff] [blame] | 2027 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2028 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2029 | if (ObsoleteVarArgs && NewVarArgs) { |
| 2030 | error("This file is corrupt: it uses both new and old style varargs"); |
| 2031 | return 0; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2032 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2033 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2034 | if(ObsoleteVarArgs) { |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2035 | if(Function* F = Result->getFunction("llvm.va_start")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2036 | if (F->arg_size() != 0) { |
| 2037 | error("Obsolete va_start takes 0 argument"); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2038 | return 0; |
| 2039 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2040 | |
| 2041 | //foo = va_start() |
| 2042 | // -> |
| 2043 | //bar = alloca typeof(foo) |
| 2044 | //va_start(bar) |
| 2045 | //foo = load bar |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2046 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2047 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2048 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2049 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2050 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2051 | "llvm.va_start", RetTy, ArgTyPtr, (Type *)0)); |
| 2052 | |
| 2053 | while (!F->use_empty()) { |
| 2054 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2055 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 2056 | new CallInst(NF, bar, "", CI); |
| 2057 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 2058 | CI->replaceAllUsesWith(foo); |
| 2059 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2060 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2061 | Result->getFunctionList().erase(F); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2062 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2063 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2064 | if(Function* F = Result->getFunction("llvm.va_end")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2065 | if(F->arg_size() != 1) { |
| 2066 | error("Obsolete va_end takes 1 argument"); |
| 2067 | return 0; |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2068 | } |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2069 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2070 | //vaend foo |
| 2071 | // -> |
| 2072 | //bar = alloca 1 of typeof(foo) |
| 2073 | //vaend bar |
| 2074 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2075 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 2076 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2077 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2078 | "llvm.va_end", RetTy, ArgTyPtr, (Type *)0)); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2079 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2080 | while (!F->use_empty()) { |
| 2081 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2082 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 2083 | new StoreInst(CI->getOperand(1), bar, CI); |
| 2084 | new CallInst(NF, bar, "", CI); |
| 2085 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2086 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2087 | Result->getFunctionList().erase(F); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2088 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2089 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2090 | if(Function* F = Result->getFunction("llvm.va_copy")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2091 | if(F->arg_size() != 1) { |
| 2092 | error("Obsolete va_copy takes 1 argument"); |
| 2093 | return 0; |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2094 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2095 | //foo = vacopy(bar) |
| 2096 | // -> |
| 2097 | //a = alloca 1 of typeof(foo) |
| 2098 | //b = alloca 1 of typeof(foo) |
| 2099 | //store bar -> b |
| 2100 | //vacopy(a, b) |
| 2101 | //foo = load a |
| 2102 | |
| 2103 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2104 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2105 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2106 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2107 | "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0)); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2108 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2109 | while (!F->use_empty()) { |
| 2110 | CallInst* CI = cast<CallInst>(F->use_back()); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2111 | SmallVector<Value *, 2> Args; |
| 2112 | Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI)); |
| 2113 | Args.push_back(new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI)); |
| 2114 | new StoreInst(CI->getOperand(1), Args[1], CI); |
| 2115 | new CallInst(NF, Args.begin(), Args.end(), "", CI); |
| 2116 | Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2117 | CI->replaceAllUsesWith(foo); |
| 2118 | CI->getParent()->getInstList().erase(CI); |
| 2119 | } |
| 2120 | Result->getFunctionList().erase(F); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2121 | } |
| 2122 | } |
| 2123 | |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 2124 | return Result; |
| 2125 | } |
| 2126 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2127 | } // end llvm namespace |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2128 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2129 | using namespace llvm; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2130 | |
| 2131 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2132 | |
| 2133 | /* Enabling traces. */ |
| 2134 | #ifndef YYDEBUG |
| 2135 | # define YYDEBUG 0 |
| 2136 | #endif |
| 2137 | |
| 2138 | /* Enabling verbose error messages. */ |
| 2139 | #ifdef YYERROR_VERBOSE |
| 2140 | # undef YYERROR_VERBOSE |
| 2141 | # define YYERROR_VERBOSE 1 |
| 2142 | #else |
| 2143 | # define YYERROR_VERBOSE 0 |
| 2144 | #endif |
| 2145 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2146 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2147 | #line 1776 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2148 | typedef union YYSTYPE { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2149 | llvm::Module *ModuleVal; |
| 2150 | llvm::Function *FunctionVal; |
| 2151 | std::pair<llvm::PATypeInfo, char*> *ArgVal; |
| 2152 | llvm::BasicBlock *BasicBlockVal; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 2153 | llvm::TermInstInfo TermInstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2154 | llvm::InstrInfo InstVal; |
| 2155 | llvm::ConstInfo ConstVal; |
| 2156 | llvm::ValueInfo ValueVal; |
| 2157 | llvm::PATypeInfo TypeVal; |
| 2158 | llvm::TypeInfo PrimType; |
| 2159 | llvm::PHIListInfo PHIList; |
| 2160 | std::list<llvm::PATypeInfo> *TypeList; |
| 2161 | std::vector<llvm::ValueInfo> *ValueList; |
| 2162 | std::vector<llvm::ConstInfo> *ConstVector; |
| 2163 | |
| 2164 | |
| 2165 | std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList; |
| 2166 | // Represent the RHS of PHI node |
| 2167 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 2168 | |
| 2169 | llvm::GlobalValue::LinkageTypes Linkage; |
| 2170 | int64_t SInt64Val; |
| 2171 | uint64_t UInt64Val; |
| 2172 | int SIntVal; |
| 2173 | unsigned UIntVal; |
| 2174 | double FPVal; |
| 2175 | bool BoolVal; |
| 2176 | |
| 2177 | char *StrVal; // This memory is strdup'd! |
| 2178 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 2179 | |
| 2180 | llvm::BinaryOps BinaryOpVal; |
| 2181 | llvm::TermOps TermOpVal; |
| 2182 | llvm::MemoryOps MemOpVal; |
| 2183 | llvm::OtherOps OtherOpVal; |
| 2184 | llvm::CastOps CastOpVal; |
| 2185 | llvm::ICmpInst::Predicate IPred; |
| 2186 | llvm::FCmpInst::Predicate FPred; |
| 2187 | llvm::Module::Endianness Endianness; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2188 | } YYSTYPE; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2189 | /* Line 191 of yacc.c. */ |
| 2190 | #line 2191 "UpgradeParser.tab.c" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2191 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 2192 | # define YYSTYPE_IS_DECLARED 1 |
| 2193 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2194 | #endif |
| 2195 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2196 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2197 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2198 | /* Copy the second part of user declarations. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2199 | |
| 2200 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2201 | /* Line 214 of yacc.c. */ |
| 2202 | #line 2203 "UpgradeParser.tab.c" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2203 | |
| 2204 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 2205 | |
| 2206 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 2207 | |
| 2208 | # ifdef YYSTACK_USE_ALLOCA |
| 2209 | # if YYSTACK_USE_ALLOCA |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2210 | # define YYSTACK_ALLOC alloca |
| 2211 | # endif |
| 2212 | # else |
| 2213 | # if defined (alloca) || defined (_ALLOCA_H) |
| 2214 | # define YYSTACK_ALLOC alloca |
| 2215 | # else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2216 | # ifdef __GNUC__ |
| 2217 | # define YYSTACK_ALLOC __builtin_alloca |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2218 | # endif |
| 2219 | # endif |
| 2220 | # endif |
| 2221 | |
| 2222 | # ifdef YYSTACK_ALLOC |
| 2223 | /* Pacify GCC's `empty if-body' warning. */ |
| 2224 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2225 | # else |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2226 | # if defined (__STDC__) || defined (__cplusplus) |
| 2227 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 2228 | # define YYSIZE_T size_t |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2229 | # endif |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2230 | # define YYSTACK_ALLOC malloc |
| 2231 | # define YYSTACK_FREE free |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2232 | # endif |
| 2233 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 2234 | |
| 2235 | |
| 2236 | #if (! defined (yyoverflow) \ |
| 2237 | && (! defined (__cplusplus) \ |
| 2238 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 2239 | |
| 2240 | /* A type that is properly aligned for any stack member. */ |
| 2241 | union yyalloc |
| 2242 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2243 | short yyss; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2244 | YYSTYPE yyvs; |
| 2245 | }; |
| 2246 | |
| 2247 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 2248 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 2249 | |
| 2250 | /* The size of an array large to enough to hold all stacks, each with |
| 2251 | N elements. */ |
| 2252 | # define YYSTACK_BYTES(N) \ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2253 | ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2254 | + YYSTACK_GAP_MAXIMUM) |
| 2255 | |
| 2256 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 2257 | not overlap. */ |
| 2258 | # ifndef YYCOPY |
| 2259 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 2260 | # define YYCOPY(To, From, Count) \ |
| 2261 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 2262 | # else |
| 2263 | # define YYCOPY(To, From, Count) \ |
| 2264 | do \ |
| 2265 | { \ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2266 | register YYSIZE_T yyi; \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2267 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 2268 | (To)[yyi] = (From)[yyi]; \ |
| 2269 | } \ |
| 2270 | while (0) |
| 2271 | # endif |
| 2272 | # endif |
| 2273 | |
| 2274 | /* Relocate STACK from its old location to the new one. The |
| 2275 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 2276 | elements in the stack, and YYPTR gives the new location of the |
| 2277 | stack. Advance YYPTR to a properly aligned location for the next |
| 2278 | stack. */ |
| 2279 | # define YYSTACK_RELOCATE(Stack) \ |
| 2280 | do \ |
| 2281 | { \ |
| 2282 | YYSIZE_T yynewbytes; \ |
| 2283 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 2284 | Stack = &yyptr->Stack; \ |
| 2285 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 2286 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 2287 | } \ |
| 2288 | while (0) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2289 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2290 | #endif |
| 2291 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2292 | #if defined (__STDC__) || defined (__cplusplus) |
| 2293 | typedef signed char yysigned_char; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2294 | #else |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2295 | typedef short yysigned_char; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2296 | #endif |
| 2297 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2298 | /* YYFINAL -- State number of the termination state. */ |
| 2299 | #define YYFINAL 4 |
| 2300 | /* YYLAST -- Last index in YYTABLE. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2301 | #define YYLAST 1630 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2302 | |
| 2303 | /* YYNTOKENS -- Number of terminals. */ |
| 2304 | #define YYNTOKENS 166 |
| 2305 | /* YYNNTS -- Number of nonterminals. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2306 | #define YYNNTS 81 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2307 | /* YYNRULES -- Number of rules. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2308 | #define YYNRULES 310 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2309 | /* YYNRULES -- Number of states. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2310 | #define YYNSTATES 606 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2311 | |
| 2312 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 2313 | #define YYUNDEFTOK 2 |
| 2314 | #define YYMAXUTOK 406 |
| 2315 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2316 | #define YYTRANSLATE(YYX) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2317 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 2318 | |
| 2319 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 2320 | static const unsigned char yytranslate[] = |
| 2321 | { |
| 2322 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2323 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2324 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2325 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2326 | 155, 156, 164, 2, 153, 2, 2, 2, 2, 2, |
| 2327 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2328 | 160, 152, 161, 2, 2, 2, 2, 2, 2, 2, |
| 2329 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2330 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2331 | 2, 157, 154, 159, 2, 2, 2, 2, 2, 165, |
| 2332 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2333 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2334 | 158, 2, 2, 162, 2, 163, 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, 2, 2, 2, 2, |
| 2344 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2345 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2346 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2347 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 2348 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 2349 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 2350 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 2351 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 2352 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 2353 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 2354 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 2355 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2356 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2357 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2358 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 2359 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2360 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
| 2361 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 2362 | 145, 146, 147, 148, 149, 150, 151 |
| 2363 | }; |
| 2364 | |
| 2365 | #if YYDEBUG |
| 2366 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 2367 | YYRHS. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2368 | static const unsigned short yyprhs[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2369 | { |
| 2370 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 2371 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 2372 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 2373 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 2374 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 2375 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 2376 | 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, |
| 2377 | 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, |
| 2378 | 159, 161, 164, 165, 167, 169, 171, 173, 175, 177, |
| 2379 | 179, 180, 181, 183, 185, 187, 189, 191, 193, 196, |
| 2380 | 197, 200, 201, 205, 208, 209, 211, 212, 216, 218, |
| 2381 | 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, |
| 2382 | 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, |
| 2383 | 261, 264, 269, 275, 281, 285, 288, 294, 299, 302, |
| 2384 | 304, 308, 310, 314, 316, 317, 322, 326, 330, 335, |
| 2385 | 340, 344, 351, 357, 360, 363, 366, 369, 372, 375, |
| 2386 | 378, 381, 384, 387, 394, 400, 409, 416, 423, 430, |
| 2387 | 438, 446, 453, 460, 469, 478, 482, 484, 486, 488, |
| 2388 | 490, 493, 496, 501, 504, 506, 511, 514, 519, 520, |
| 2389 | 528, 529, 537, 538, 546, 547, 555, 559, 564, 565, |
| 2390 | 567, 569, 571, 575, 579, 583, 587, 591, 595, 597, |
| 2391 | 598, 600, 602, 604, 605, 608, 612, 614, 616, 620, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2392 | 622, 623, 632, 634, 636, 637, 642, 644, 646, 649, |
| 2393 | 650, 652, 654, 655, 656, 662, 663, 665, 667, 669, |
| 2394 | 671, 673, 675, 677, 679, 681, 685, 687, 693, 695, |
| 2395 | 697, 699, 701, 704, 707, 710, 714, 717, 718, 720, |
| 2396 | 722, 724, 727, 730, 734, 744, 754, 763, 777, 779, |
| 2397 | 781, 788, 794, 797, 804, 812, 814, 818, 820, 821, |
| 2398 | 824, 826, 832, 838, 844, 851, 858, 861, 866, 871, |
| 2399 | 878, 883, 888, 893, 898, 905, 912, 915, 923, 925, |
| 2400 | 928, 929, 931, 932, 936, 943, 947, 954, 957, 962, |
| 2401 | 969 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2402 | }; |
| 2403 | |
| 2404 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2405 | static const short yyrhs[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2406 | { |
| 2407 | 200, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
| 2408 | -1, 79, -1, 80, -1, 81, -1, 82, -1, 83, |
| 2409 | -1, 84, -1, 85, -1, 86, -1, 87, -1, 88, |
| 2410 | -1, 89, -1, 90, -1, 91, -1, 92, -1, 97, |
| 2411 | -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, |
| 2412 | -1, 119, -1, 120, -1, 121, -1, 122, -1, 123, |
| 2413 | -1, 124, -1, 125, -1, 126, -1, 127, -1, 128, |
| 2414 | -1, 129, -1, 130, -1, 131, -1, 132, -1, 133, |
| 2415 | -1, 134, -1, 135, -1, 136, -1, 137, -1, 138, |
| 2416 | -1, 125, -1, 126, -1, 127, -1, 128, -1, 27, |
| 2417 | -1, 28, -1, 93, -1, 94, -1, 95, -1, 96, |
| 2418 | -1, 140, -1, 141, -1, 142, -1, 143, -1, 144, |
| 2419 | -1, 145, -1, 146, -1, 147, -1, 148, -1, 149, |
| 2420 | -1, 150, -1, 151, -1, 139, -1, 16, -1, 14, |
| 2421 | -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, |
| 2422 | -1, 11, -1, 176, -1, 177, -1, 18, -1, 19, |
| 2423 | -1, 212, 152, -1, -1, 41, -1, 42, -1, 43, |
| 2424 | -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, |
| 2425 | -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, |
| 2426 | -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, |
| 2427 | -1, 153, 57, 4, -1, 34, 24, -1, -1, 185, |
| 2428 | -1, -1, 153, 188, 187, -1, 185, -1, 57, 4, |
| 2429 | -1, 191, -1, 8, -1, 193, -1, 8, -1, 193, |
| 2430 | -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, |
| 2431 | -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2432 | -1, 19, -1, 21, -1, 192, -1, 48, -1, 229, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2433 | -1, 154, 4, -1, 190, 155, 195, 156, -1, 157, |
| 2434 | 4, 158, 193, 159, -1, 160, 4, 158, 193, 161, |
| 2435 | -1, 162, 194, 163, -1, 162, 163, -1, 160, 162, |
| 2436 | 194, 163, 161, -1, 160, 162, 163, 161, -1, 193, |
| 2437 | 164, -1, 193, -1, 194, 153, 193, -1, 194, -1, |
| 2438 | 194, 153, 37, -1, 37, -1, -1, 191, 157, 198, |
| 2439 | 159, -1, 191, 157, 159, -1, 191, 165, 24, -1, |
| 2440 | 191, 160, 198, 161, -1, 191, 162, 198, 163, -1, |
| 2441 | 191, 162, 163, -1, 191, 160, 162, 198, 163, 161, |
| 2442 | -1, 191, 160, 162, 163, 161, -1, 191, 38, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2443 | 191, 39, -1, 191, 229, -1, 191, 197, -1, 191, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2444 | 26, -1, 176, 168, -1, 177, 4, -1, 9, 27, |
| 2445 | -1, 9, 28, -1, 179, 7, -1, 175, 155, 196, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2446 | 36, 191, 156, -1, 110, 155, 196, 244, 156, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2447 | 112, 155, 196, 153, 196, 153, 196, 156, -1, 169, |
| 2448 | 155, 196, 153, 196, 156, -1, 170, 155, 196, 153, |
| 2449 | 196, 156, -1, 171, 155, 196, 153, 196, 156, -1, |
| 2450 | 103, 172, 155, 196, 153, 196, 156, -1, 104, 173, |
| 2451 | 155, 196, 153, 196, 156, -1, 174, 155, 196, 153, |
| 2452 | 196, 156, -1, 114, 155, 196, 153, 196, 156, -1, |
| 2453 | 115, 155, 196, 153, 196, 153, 196, 156, -1, 116, |
| 2454 | 155, 196, 153, 196, 153, 196, 156, -1, 198, 153, |
| 2455 | 196, -1, 196, -1, 32, -1, 33, -1, 201, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2456 | 201, 222, -1, 201, 224, -1, 201, 62, 61, 207, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2457 | -1, 201, 25, -1, 202, -1, 202, 180, 20, 189, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2458 | -1, 202, 224, -1, 202, 62, 61, 207, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2459 | 202, 180, 181, 199, 196, 203, 187, -1, -1, 202, |
| 2460 | 180, 50, 199, 191, 204, 187, -1, -1, 202, 180, |
| 2461 | 45, 199, 191, 205, 187, -1, -1, 202, 180, 47, |
| 2462 | 199, 191, 206, 187, -1, 202, 51, 209, -1, 202, |
| 2463 | 58, 152, 210, -1, -1, 24, -1, 56, -1, 55, |
| 2464 | -1, 53, 152, 208, -1, 54, 152, 4, -1, 52, |
| 2465 | 152, 24, -1, 71, 152, 24, -1, 157, 211, 159, |
| 2466 | -1, 211, 153, 24, -1, 24, -1, -1, 22, -1, |
| 2467 | 24, -1, 212, -1, -1, 191, 213, -1, 215, 153, |
| 2468 | 214, -1, 214, -1, 215, -1, 215, 153, 37, -1, |
| 2469 | 37, -1, -1, 182, 189, 212, 155, 216, 156, 186, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2470 | 183, -1, 29, -1, 162, -1, -1, 181, 220, 217, |
| 2471 | 218, -1, 30, -1, 163, -1, 232, 221, -1, -1, |
| 2472 | 45, -1, 47, -1, -1, -1, 31, 225, 223, 226, |
| 2473 | 217, -1, -1, 63, -1, 3, -1, 4, -1, 7, |
| 2474 | -1, 27, -1, 28, -1, 38, -1, 39, -1, 26, |
| 2475 | -1, 160, 198, 161, -1, 197, -1, 61, 227, 24, |
| 2476 | 153, 24, -1, 167, -1, 212, -1, 229, -1, 228, |
| 2477 | -1, 191, 230, -1, 232, 233, -1, 219, 233, -1, |
| 2478 | 234, 180, 236, -1, 234, 238, -1, -1, 23, -1, |
| 2479 | 77, -1, 78, -1, 72, 231, -1, 72, 8, -1, |
| 2480 | 73, 21, 230, -1, 73, 9, 230, 153, 21, 230, |
| 2481 | 153, 21, 230, -1, 74, 178, 230, 153, 21, 230, |
| 2482 | 157, 237, 159, -1, 74, 178, 230, 153, 21, 230, |
| 2483 | 157, 159, -1, 75, 182, 189, 230, 155, 241, 156, |
| 2484 | 36, 21, 230, 235, 21, 230, -1, 235, -1, 76, |
| 2485 | -1, 237, 178, 228, 153, 21, 230, -1, 178, 228, |
| 2486 | 153, 21, 230, -1, 180, 243, -1, 191, 157, 230, |
| 2487 | 153, 230, 159, -1, 239, 153, 157, 230, 153, 230, |
| 2488 | 159, -1, 231, -1, 240, 153, 231, -1, 240, -1, |
| 2489 | -1, 60, 59, -1, 59, -1, 169, 191, 230, 153, |
| 2490 | 230, -1, 170, 191, 230, 153, 230, -1, 171, 191, |
| 2491 | 230, 153, 230, -1, 103, 172, 191, 230, 153, 230, |
| 2492 | -1, 104, 173, 191, 230, 153, 230, -1, 49, 231, |
| 2493 | -1, 174, 231, 153, 231, -1, 175, 231, 36, 191, |
| 2494 | -1, 112, 231, 153, 231, 153, 231, -1, 113, 231, |
| 2495 | 153, 191, -1, 117, 231, 153, 191, -1, 118, 231, |
| 2496 | 153, 191, -1, 114, 231, 153, 231, -1, 115, 231, |
| 2497 | 153, 231, 153, 231, -1, 116, 231, 153, 231, 153, |
| 2498 | 231, -1, 111, 239, -1, 242, 182, 189, 230, 155, |
| 2499 | 241, 156, -1, 246, -1, 153, 240, -1, -1, 35, |
| 2500 | -1, -1, 105, 191, 184, -1, 105, 191, 153, 15, |
| 2501 | 230, 184, -1, 106, 191, 184, -1, 106, 191, 153, |
| 2502 | 15, 230, 184, -1, 107, 231, -1, 245, 108, 191, |
| 2503 | 230, -1, 245, 109, 231, 153, 191, 230, -1, 110, |
| 2504 | 191, 230, 244, -1 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2505 | }; |
| 2506 | |
| 2507 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2508 | static const unsigned short yyrline[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2509 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2510 | 0, 1916, 1916, 1917, 1925, 1926, 1936, 1936, 1936, 1936, |
| 2511 | 1936, 1936, 1936, 1936, 1936, 1936, 1936, 1940, 1940, 1940, |
| 2512 | 1944, 1944, 1944, 1944, 1944, 1944, 1948, 1948, 1949, 1949, |
| 2513 | 1950, 1950, 1951, 1951, 1952, 1952, 1956, 1956, 1957, 1957, |
| 2514 | 1958, 1958, 1959, 1959, 1960, 1960, 1961, 1961, 1962, 1962, |
| 2515 | 1963, 1964, 1967, 1967, 1967, 1967, 1971, 1971, 1971, 1971, |
| 2516 | 1971, 1971, 1971, 1972, 1972, 1972, 1972, 1972, 1972, 1978, |
| 2517 | 1978, 1978, 1978, 1982, 1982, 1982, 1982, 1986, 1986, 1990, |
| 2518 | 1990, 1995, 1998, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
| 2519 | 2010, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2031, |
| 2520 | 2032, 2040, 2041, 2049, 2058, 2059, 2066, 2067, 2071, 2075, |
| 2521 | 2091, 2092, 2099, 2100, 2107, 2115, 2115, 2115, 2115, 2115, |
| 2522 | 2115, 2115, 2116, 2116, 2116, 2116, 2116, 2121, 2125, 2129, |
| 2523 | 2134, 2143, 2170, 2176, 2189, 2200, 2204, 2217, 2221, 2235, |
| 2524 | 2239, 2246, 2247, 2253, 2260, 2272, 2302, 2315, 2338, 2366, |
| 2525 | 2388, 2399, 2421, 2432, 2441, 2446, 2505, 2512, 2520, 2527, |
| 2526 | 2534, 2538, 2542, 2551, 2566, 2578, 2587, 2615, 2628, 2637, |
| 2527 | 2643, 2649, 2660, 2666, 2672, 2683, 2684, 2693, 2694, 2706, |
| 2528 | 2715, 2716, 2717, 2718, 2719, 2735, 2755, 2757, 2759, 2759, |
| 2529 | 2766, 2766, 2774, 2774, 2782, 2782, 2791, 2793, 2795, 2800, |
| 2530 | 2814, 2815, 2819, 2822, 2830, 2834, 2841, 2845, 2849, 2853, |
| 2531 | 2861, 2861, 2865, 2866, 2870, 2878, 2883, 2891, 2892, 2899, |
| 2532 | 2906, 2910, 3100, 3100, 3104, 3104, 3114, 3114, 3118, 3123, |
| 2533 | 3124, 3125, 3129, 3130, 3129, 3142, 3143, 3148, 3149, 3150, |
| 2534 | 3151, 3155, 3159, 3160, 3161, 3162, 3183, 3187, 3201, 3202, |
| 2535 | 3207, 3207, 3215, 3225, 3228, 3237, 3248, 3253, 3262, 3273, |
| 2536 | 3273, 3276, 3280, 3284, 3289, 3299, 3317, 3326, 3399, 3403, |
| 2537 | 3410, 3422, 3437, 3467, 3477, 3487, 3491, 3498, 3499, 3503, |
| 2538 | 3506, 3512, 3531, 3549, 3565, 3579, 3593, 3604, 3622, 3631, |
| 2539 | 3640, 3647, 3668, 3692, 3698, 3704, 3710, 3726, 3819, 3827, |
| 2540 | 3828, 3832, 3833, 3837, 3843, 3850, 3856, 3863, 3870, 3883, |
| 2541 | 3909 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2542 | }; |
| 2543 | #endif |
| 2544 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2545 | #if YYDEBUG || YYERROR_VERBOSE |
| 2546 | /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2547 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 2548 | static const char *const yytname[] = |
| 2549 | { |
| 2550 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 2551 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 2552 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 2553 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 2554 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 2555 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 2556 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 2557 | "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 2558 | "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", |
| 2559 | "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", |
| 2560 | "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", |
| 2561 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 2562 | "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT", |
| 2563 | "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM", |
| 2564 | "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR", |
| 2565 | "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP", |
| 2566 | "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", |
| 2567 | "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", |
| 2568 | "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", |
| 2569 | "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", |
| 2570 | "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", |
| 2571 | "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR", |
| 2572 | "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", |
| 2573 | "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL", |
| 2574 | "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates", |
| 2575 | "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType", |
| 2576 | "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", |
| 2577 | "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes", |
| 2578 | "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", |
| 2579 | "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", |
| 2580 | "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", |
| 2581 | "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition", |
| 2582 | "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal", |
| 2583 | "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2584 | "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7", |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2585 | "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", |
| 2586 | "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", |
| 2587 | "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList", |
| 2588 | "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList", |
| 2589 | "OptVolatile", "MemoryInst", 0 |
| 2590 | }; |
| 2591 | #endif |
| 2592 | |
| 2593 | # ifdef YYPRINT |
| 2594 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 2595 | token YYLEX-NUM. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2596 | static const unsigned short yytoknum[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2597 | { |
| 2598 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 2599 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 2600 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 2601 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 2602 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 2603 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 2604 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 2605 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 2606 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 2607 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 2608 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 2609 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 2610 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 2611 | 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, |
| 2612 | 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, |
| 2613 | 405, 406, 61, 44, 92, 40, 41, 91, 120, 93, |
| 2614 | 60, 62, 123, 125, 42, 99 |
| 2615 | }; |
| 2616 | # endif |
| 2617 | |
| 2618 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 2619 | static const unsigned char yyr1[] = |
| 2620 | { |
| 2621 | 0, 166, 167, 167, 168, 168, 169, 169, 169, 169, |
| 2622 | 169, 169, 169, 169, 169, 169, 169, 170, 170, 170, |
| 2623 | 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, |
| 2624 | 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, |
| 2625 | 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, |
| 2626 | 173, 173, 174, 174, 174, 174, 175, 175, 175, 175, |
| 2627 | 175, 175, 175, 175, 175, 175, 175, 175, 175, 176, |
| 2628 | 176, 176, 176, 177, 177, 177, 177, 178, 178, 179, |
| 2629 | 179, 180, 180, 181, 181, 181, 181, 181, 181, 181, |
| 2630 | 181, 182, 182, 182, 182, 182, 182, 182, 182, 183, |
| 2631 | 183, 184, 184, 185, 186, 186, 187, 187, 188, 188, |
| 2632 | 189, 189, 190, 190, 191, 192, 192, 192, 192, 192, |
| 2633 | 192, 192, 192, 192, 192, 192, 192, 193, 193, 193, |
| 2634 | 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, |
| 2635 | 194, 195, 195, 195, 195, 196, 196, 196, 196, 196, |
| 2636 | 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, |
| 2637 | 196, 196, 196, 197, 197, 197, 197, 197, 197, 197, |
| 2638 | 197, 197, 197, 197, 197, 198, 198, 199, 199, 200, |
| 2639 | 201, 201, 201, 201, 201, 202, 202, 202, 203, 202, |
| 2640 | 204, 202, 205, 202, 206, 202, 202, 202, 202, 207, |
| 2641 | 208, 208, 209, 209, 209, 209, 210, 211, 211, 211, |
| 2642 | 212, 212, 213, 213, 214, 215, 215, 216, 216, 216, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2643 | 216, 217, 218, 218, 220, 219, 221, 221, 222, 223, |
| 2644 | 223, 223, 225, 226, 224, 227, 227, 228, 228, 228, |
| 2645 | 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, |
| 2646 | 230, 230, 231, 232, 232, 233, 234, 234, 234, 235, |
| 2647 | 235, 236, 236, 236, 236, 236, 236, 236, 236, 236, |
| 2648 | 237, 237, 238, 239, 239, 240, 240, 241, 241, 242, |
| 2649 | 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, |
| 2650 | 243, 243, 243, 243, 243, 243, 243, 243, 243, 244, |
| 2651 | 244, 245, 245, 246, 246, 246, 246, 246, 246, 246, |
| 2652 | 246 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2653 | }; |
| 2654 | |
| 2655 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 2656 | static const unsigned char yyr2[] = |
| 2657 | { |
| 2658 | 0, 2, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2663 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2664 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2665 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2666 | 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, |
| 2667 | 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, |
| 2668 | 2, 0, 3, 2, 0, 1, 0, 3, 1, 2, |
| 2669 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2670 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2671 | 2, 4, 5, 5, 3, 2, 5, 4, 2, 1, |
| 2672 | 3, 1, 3, 1, 0, 4, 3, 3, 4, 4, |
| 2673 | 3, 6, 5, 2, 2, 2, 2, 2, 2, 2, |
| 2674 | 2, 2, 2, 6, 5, 8, 6, 6, 6, 7, |
| 2675 | 7, 6, 6, 8, 8, 3, 1, 1, 1, 1, |
| 2676 | 2, 2, 4, 2, 1, 4, 2, 4, 0, 7, |
| 2677 | 0, 7, 0, 7, 0, 7, 3, 4, 0, 1, |
| 2678 | 1, 1, 3, 3, 3, 3, 3, 3, 1, 0, |
| 2679 | 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2680 | 0, 8, 1, 1, 0, 4, 1, 1, 2, 0, |
| 2681 | 1, 1, 0, 0, 5, 0, 1, 1, 1, 1, |
| 2682 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 2683 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 1, |
| 2684 | 1, 2, 2, 3, 9, 9, 8, 13, 1, 1, |
| 2685 | 6, 5, 2, 6, 7, 1, 3, 1, 0, 2, |
| 2686 | 1, 5, 5, 5, 6, 6, 2, 4, 4, 6, |
| 2687 | 4, 4, 4, 4, 6, 6, 2, 7, 1, 2, |
| 2688 | 0, 1, 0, 3, 6, 3, 6, 2, 4, 6, |
| 2689 | 4 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2690 | }; |
| 2691 | |
| 2692 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 2693 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 2694 | means the default is an error. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2695 | static const unsigned short yydefact[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2696 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2697 | 198, 0, 90, 184, 1, 183, 232, 83, 84, 85, |
| 2698 | 86, 87, 88, 89, 0, 224, 257, 180, 181, 257, |
| 2699 | 210, 211, 0, 0, 0, 90, 0, 186, 229, 0, |
| 2700 | 91, 258, 254, 82, 226, 227, 228, 253, 0, 0, |
| 2701 | 0, 0, 196, 0, 0, 0, 0, 0, 0, 0, |
| 2702 | 81, 230, 231, 233, 199, 182, 0, 92, 93, 94, |
| 2703 | 95, 96, 97, 0, 0, 302, 256, 0, 0, 0, |
| 2704 | 0, 209, 197, 187, 2, 3, 111, 115, 116, 117, |
| 2705 | 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, |
| 2706 | 0, 0, 0, 0, 248, 185, 0, 110, 127, 114, |
| 2707 | 249, 129, 177, 178, 0, 0, 0, 0, 91, 98, |
| 2708 | 0, 222, 223, 225, 301, 0, 280, 0, 0, 0, |
| 2709 | 0, 91, 269, 259, 260, 6, 7, 8, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2710 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 52, |
| 2711 | 53, 54, 55, 20, 21, 22, 23, 24, 25, 0, |
| 2712 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2713 | 0, 0, 0, 68, 56, 57, 58, 59, 60, 61, |
| 2714 | 62, 63, 64, 65, 66, 67, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2715 | 0, 268, 255, 91, 272, 0, 298, 204, 201, 200, |
| 2716 | 202, 203, 205, 208, 0, 130, 0, 0, 0, 113, |
| 2717 | 135, 139, 0, 144, 138, 192, 194, 190, 115, 116, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2718 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2719 | 0, 0, 0, 188, 234, 0, 0, 286, 279, 262, |
| 2720 | 261, 0, 0, 72, 76, 71, 75, 70, 74, 69, |
| 2721 | 73, 77, 78, 0, 0, 26, 27, 28, 29, 30, |
| 2722 | 31, 32, 33, 34, 35, 0, 50, 51, 46, 47, |
| 2723 | 48, 49, 36, 37, 38, 39, 40, 41, 42, 43, |
| 2724 | 44, 45, 0, 101, 101, 307, 0, 0, 296, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 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, 0, 206, 0, 0, 0, 0, |
| 2727 | 0, 134, 143, 141, 0, 106, 106, 106, 160, 161, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2728 | 4, 5, 158, 159, 162, 157, 153, 154, 0, 0, |
| 2729 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2730 | 0, 0, 0, 0, 156, 155, 106, 220, 237, 238, |
| 2731 | 239, 244, 240, 241, 242, 243, 235, 0, 246, 251, |
| 2732 | 250, 252, 0, 263, 0, 0, 0, 0, 0, 303, |
| 2733 | 0, 305, 300, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2734 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2735 | 207, 112, 112, 137, 0, 140, 0, 131, 0, 193, |
| 2736 | 195, 191, 0, 0, 0, 0, 0, 0, 0, 146, |
| 2737 | 176, 0, 0, 0, 150, 0, 147, 0, 0, 0, |
| 2738 | 0, 0, 189, 219, 213, 216, 217, 0, 236, 0, |
| 2739 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2740 | 310, 0, 0, 0, 290, 293, 0, 0, 291, 292, |
| 2741 | 0, 0, 0, 287, 288, 0, 308, 0, 132, 133, |
| 2742 | 136, 142, 0, 0, 108, 106, 0, 0, 300, 0, |
| 2743 | 0, 0, 0, 0, 145, 135, 114, 0, 148, 149, |
| 2744 | 0, 0, 0, 0, 0, 212, 214, 0, 104, 0, |
| 2745 | 245, 0, 0, 278, 0, 0, 101, 102, 101, 275, |
| 2746 | 299, 0, 0, 0, 0, 0, 281, 282, 283, 278, |
| 2747 | 0, 103, 109, 107, 0, 0, 0, 0, 0, 0, |
| 2748 | 0, 175, 152, 0, 0, 0, 0, 0, 0, 218, |
| 2749 | 215, 105, 99, 0, 0, 0, 277, 0, 284, 285, |
| 2750 | 0, 304, 306, 0, 0, 0, 289, 294, 295, 0, |
| 2751 | 309, 0, 0, 164, 0, 0, 0, 0, 151, 0, |
| 2752 | 0, 0, 0, 0, 0, 221, 247, 0, 0, 0, |
| 2753 | 276, 273, 0, 297, 0, 0, 0, 172, 0, 0, |
| 2754 | 166, 167, 168, 171, 163, 100, 0, 266, 0, 0, |
| 2755 | 0, 274, 169, 170, 0, 0, 0, 264, 0, 265, |
| 2756 | 0, 0, 165, 173, 174, 0, 0, 0, 0, 0, |
| 2757 | 0, 271, 0, 0, 270, 267 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2758 | }; |
| 2759 | |
| 2760 | /* YYDEFGOTO[NTERM-NUM]. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2761 | static const short yydefgoto[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2762 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2763 | -1, 94, 312, 329, 330, 331, 255, 272, 332, 333, |
| 2764 | 219, 220, 243, 221, 25, 15, 63, 555, 359, 454, |
| 2765 | 522, 389, 455, 95, 96, 222, 98, 99, 202, 304, |
| 2766 | 400, 348, 401, 104, 1, 2, 3, 336, 307, 305, |
| 2767 | 306, 55, 190, 42, 72, 194, 100, 476, 415, 416, |
| 2768 | 417, 64, 113, 16, 30, 36, 17, 53, 18, 28, |
| 2769 | 108, 419, 349, 101, 351, 489, 19, 32, 33, 181, |
| 2770 | 182, 579, 66, 278, 526, 527, 183, 184, 430, 185, |
| 2771 | 186 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2772 | }; |
| 2773 | |
| 2774 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 2775 | STATE-NUM. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2776 | #define YYPACT_NINF -542 |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2777 | static const short yypact[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2778 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2779 | -542, 13, 162, 567, -542, -542, -542, -542, -542, -542, |
| 2780 | -542, -542, -542, -542, 83, -542, 19, -542, -542, -14, |
| 2781 | -542, -542, 50, -87, 87, 233, 27, -542, 123, 141, |
| 2782 | 175, -542, -542, 98, -542, -542, -542, -542, 33, 40, |
| 2783 | 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156, |
| 2784 | -542, -542, -542, -542, -542, -542, 221, -542, -542, -542, |
| 2785 | -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226, |
| 2786 | 227, 235, -542, -542, -542, -542, 81, -542, -542, -542, |
| 2787 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2788 | 256, 257, 4, 15, -542, -542, 108, -542, -542, 12, |
| 2789 | -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542, |
| 2790 | 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116, |
| 2791 | 479, 175, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2792 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2793 | -542, -542, -542, -542, -542, -542, -542, -542, -542, 355, |
| 2794 | 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, |
| 2795 | 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542, |
| 2796 | -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306, |
| 2797 | 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542, |
| 2798 | -542, -542, -542, -542, -13, -542, 110, 111, 75, -542, |
| 2799 | -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208, |
| 2800 | 266, 210, 267, 212, 268, 230, 277, 275, 278, 246, |
| 2801 | 280, 279, 566, -542, -542, 136, 766, -542, -542, 81, |
| 2802 | -542, 766, 766, -542, -542, -542, -542, -542, -542, -542, |
| 2803 | -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542, |
| 2804 | -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542, |
| 2805 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2806 | -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147, |
| 2807 | 148, 149, 151, 152, 158, 160, 766, 766, 766, 161, |
| 2808 | 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27, |
| 2809 | 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542, |
| 2810 | -542, -542, -542, -542, -542, -542, -542, -542, 355, 429, |
| 2811 | 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184, |
| 2812 | 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542, |
| 2813 | -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542, |
| 2814 | -542, -542, 193, -542, 194, 766, 766, 766, 7, -542, |
| 2815 | 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306, |
| 2816 | 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207, |
| 2817 | -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542, |
| 2818 | -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542, |
| 2819 | -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326, |
| 2820 | 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337, |
| 2821 | -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306, |
| 2822 | -542, 223, 766, 224, -542, -542, 225, 234, -542, -542, |
| 2823 | 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542, |
| 2824 | -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236, |
| 2825 | 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542, |
| 2826 | 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252, |
| 2827 | -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542, |
| 2828 | 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306, |
| 2829 | 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326, |
| 2830 | 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542, |
| 2831 | -542, -542, 368, 402, 274, 276, 259, 287, -542, -542, |
| 2832 | 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290, |
| 2833 | -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296, |
| 2834 | 297, 299, 302, 303, 430, -542, -542, 414, 41, 425, |
| 2835 | -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326, |
| 2836 | -542, -542, -542, -542, -542, -542, 766, -542, 893, 144, |
| 2837 | 448, -542, -542, -542, 314, 315, 316, -542, 331, -542, |
| 2838 | 893, 766, -542, -542, -542, 464, 334, 180, 766, 481, |
| 2839 | 482, -542, 766, 766, -542, -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2840 | }; |
| 2841 | |
| 2842 | /* YYPGOTO[NTERM-NUM]. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2843 | static const short yypgoto[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2844 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2845 | -542, -542, -542, 435, 439, 441, 191, 197, 442, 445, |
| 2846 | -119, -116, -541, -542, 478, 489, -107, -542, -267, 37, |
| 2847 | -542, -238, -542, -60, -542, -45, -542, -74, -51, -542, |
| 2848 | -101, 300, -252, 134, -542, -542, -542, -542, -542, -542, |
| 2849 | -542, 473, -542, -542, -542, -542, 8, -542, 46, -542, |
| 2850 | -542, 410, -542, -542, -542, -542, -542, -542, 518, -542, |
| 2851 | -542, -542, -528, 142, -90, -113, -542, 505, -542, -72, |
| 2852 | -542, -542, -542, -542, 97, 28, -542, -542, 70, -542, |
| 2853 | -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2854 | }; |
| 2855 | |
| 2856 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2857 | positive, shift that token. If negative, reduce the rule which |
| 2858 | number is the opposite. If zero, do what YYDEFACT says. |
| 2859 | If YYTABLE_NINF, syntax error. */ |
| 2860 | #define YYTABLE_NINF -180 |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 2861 | static const short yytable[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2862 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2863 | 97, 241, 227, 110, 242, 230, 223, 361, 197, 31, |
| 2864 | 111, 26, 449, 4, 244, 204, 34, 578, 97, 201, |
| 2865 | 74, 75, 426, 199, 77, 78, 79, 80, 81, 82, |
| 2866 | 83, 84, 85, 86, 87, 428, 88, 20, 590, 21, |
| 2867 | 275, 26, 31, 279, 280, 281, 282, 283, 284, 285, |
| 2868 | 588, 233, 234, 235, 236, 237, 238, 239, 240, 205, |
| 2869 | 206, 207, 596, 89, 427, 43, 289, 290, 390, 391, |
| 2870 | 226, 463, 300, 226, 403, 405, 291, 427, 452, 468, |
| 2871 | 74, 75, 301, 199, 77, 78, 79, 80, 81, 82, |
| 2872 | 83, 84, 85, 86, 87, 420, 88, 20, 412, 21, |
| 2873 | 448, 453, 38, 39, 40, 204, 273, 274, 226, 276, |
| 2874 | 277, 226, 226, 226, 226, 226, 226, 226, 225, 463, |
| 2875 | 20, 41, 21, 89, 201, 231, 300, 480, -139, 201, |
| 2876 | -112, 286, 287, 288, 226, 226, 384, 232, -139, 204, |
| 2877 | 294, 352, 353, 112, 29, 463, 295, 299, 44, 35, |
| 2878 | 467, 464, 303, 354, 233, 234, 235, 236, 237, 238, |
| 2879 | 239, 240, -179, 463, 463, 54, 198, -112, 51, 90, |
| 2880 | 52, 71, 91, 469, 513, 92, 204, 93, 200, 50, |
| 2881 | 379, 105, 106, 107, 355, 67, 362, 5, 102, 103, |
| 2882 | 188, 189, 68, 6, 292, 293, 372, 373, 374, 97, |
| 2883 | 577, 308, 309, 7, 8, 9, 10, 11, 12, 13, |
| 2884 | 356, -72, -72, -71, -71, -70, -70, 503, 69, 531, |
| 2885 | 70, 532, 381, 382, 14, 109, 385, 357, 187, 90, |
| 2886 | 191, 377, 91, -69, -69, 92, -113, 93, 298, 56, |
| 2887 | 57, 58, 59, 60, 61, 62, 97, 378, 226, 310, |
| 2888 | 311, 192, 433, 45, 435, 436, 437, 123, 124, 193, |
| 2889 | 195, 196, 443, 203, 228, 423, 424, 425, 296, 297, |
| 2890 | -76, -75, -74, 431, 7, 8, 9, 10, 46, 12, |
| 2891 | 47, -73, -79, 48, 313, -80, 314, 445, 446, 363, |
| 2892 | 358, 337, 414, 458, 459, 460, 461, 462, 360, 364, |
| 2893 | 365, 366, 367, 589, 368, 369, 470, 471, 472, 473, |
| 2894 | 474, 370, 385, 371, 375, 380, 383, 376, 386, 387, |
| 2895 | 226, 434, 226, 226, 226, 438, 439, 394, 466, 388, |
| 2896 | 226, 444, 395, 396, 397, 406, 486, 398, 488, 407, |
| 2897 | 408, 409, 492, 410, 411, 418, 421, 422, 429, 432, |
| 2898 | 496, 497, 498, 440, 441, 504, 505, 450, 456, 442, |
| 2899 | 447, 479, 511, 481, 335, 478, 457, 477, 350, 482, |
| 2900 | 483, 484, 485, 350, 350, 487, 491, 493, 494, 502, |
| 2901 | 536, 537, 538, 499, 226, 350, 501, 495, 518, 507, |
| 2902 | 508, 524, 525, 509, 528, 529, 510, 514, 515, 512, |
| 2903 | 516, 534, 500, 517, 452, 523, 544, 545, 546, 547, |
| 2904 | 540, 530, 533, 549, 550, 551, 552, 535, 350, 543, |
| 2905 | 560, 548, 475, 541, 542, 554, 556, 557, 350, 350, |
| 2906 | 350, 427, 414, 558, 575, 576, 566, 568, 226, 241, |
| 2907 | 564, 565, 242, 559, 561, 562, 563, 569, 226, 226, |
| 2908 | 226, 567, 570, 571, 226, 572, 256, 257, 573, 574, |
| 2909 | 241, 580, 582, 242, 581, 584, 583, 585, 586, 591, |
| 2910 | 592, 593, 594, 553, 245, 246, 247, 248, 249, 250, |
| 2911 | 251, 252, 253, 254, 595, 598, 587, 599, 226, 233, |
| 2912 | 234, 235, 236, 237, 238, 239, 240, 350, 350, 350, |
| 2913 | 176, 597, 602, 603, 177, 350, 178, 179, 601, 392, |
| 2914 | 180, 65, 604, 605, 49, 521, 393, 73, 224, 350, |
| 2915 | 350, 27, 334, 520, 37, 600, 490, 539, 506, 0, |
| 2916 | 0, 0, 0, 0, 74, 75, 0, 199, 208, 209, |
| 2917 | 210, 211, 212, 213, 214, 215, 216, 217, 218, 0, |
| 2918 | 88, 20, 0, 21, 258, 259, 260, 261, 262, 263, |
| 2919 | 264, 265, 266, 267, 268, 269, 270, 271, 350, 0, |
| 2920 | 350, 74, 75, 0, 350, 0, 0, 89, 0, 0, |
| 2921 | 0, 0, 350, 350, 350, 0, 0, -82, 20, 20, |
| 2922 | 21, 21, 315, 0, 0, 0, 0, 0, 6, -82, |
| 2923 | -82, 0, 0, 0, 316, 317, 0, 0, -82, -82, |
| 2924 | -82, -82, -82, -82, -82, 0, 0, -82, 22, 0, |
| 2925 | 0, 0, 0, 350, 350, 23, 350, 350, 0, 24, |
| 2926 | 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2927 | 0, 0, 350, 0, 0, 125, 126, 127, 128, 129, |
| 2928 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2929 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
| 2930 | 319, 0, 0, 0, 0, 0, 320, 350, 321, 0, |
| 2931 | 322, 323, 324, 90, 0, 0, 91, 0, 0, 92, |
| 2932 | 0, 93, 404, 0, 0, 0, 0, 0, 0, 0, |
| 2933 | 0, 0, 0, 0, 0, 163, 164, 165, 166, 167, |
| 2934 | 168, 169, 170, 171, 172, 173, 174, 175, 350, 0, |
| 2935 | 0, 0, 0, 325, 0, 0, 326, 0, 327, 0, |
| 2936 | 0, 328, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2937 | 350, 0, 0, 0, 350, 350, 74, 75, 0, 199, |
| 2938 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, |
| 2939 | 218, 0, 88, 20, 0, 21, 0, 0, 0, 338, |
| 2940 | 339, 74, 75, 340, 0, 0, 0, 0, 0, 0, |
| 2941 | 0, 0, 0, 0, 0, 0, 0, 0, 20, 89, |
| 2942 | 21, 0, 341, 342, 343, 0, 0, 0, 0, 0, |
| 2943 | 0, 0, 0, 0, 344, 345, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2944 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2945 | 0, 0, 0, 0, 0, 0, 0, 346, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2946 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2947 | 0, 0, 0, 0, 0, 125, 126, 127, 128, 129, |
| 2948 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2949 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2950 | 319, 0, 0, 0, 0, 0, 320, 0, 321, 0, |
| 2951 | 322, 323, 324, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2952 | 0, 0, 0, 0, 0, 90, 338, 339, 91, 0, |
| 2953 | 340, 92, 0, 93, 465, 163, 164, 165, 166, 167, |
| 2954 | 168, 169, 170, 171, 172, 173, 174, 175, 0, 341, |
| 2955 | 342, 343, 0, 0, 0, 0, 347, 0, 0, 0, |
| 2956 | 0, 344, 345, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2957 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2958 | 0, 0, 0, 0, 346, 0, 0, 0, 0, 0, |
| 2959 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2960 | 0, 0, 125, 126, 127, 128, 129, 130, 131, 132, |
| 2961 | 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, |
| 2962 | 143, 144, 145, 146, 147, 148, 318, 319, 0, 0, |
| 2963 | 0, 0, 0, 320, 0, 321, 0, 322, 323, 324, |
| 2964 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2965 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2966 | 0, 0, 163, 164, 165, 166, 167, 168, 169, 170, |
| 2967 | 171, 172, 173, 174, 175, 0, 0, 0, 0, 0, |
| 2968 | 0, 74, 75, 347, 199, 77, 78, 79, 80, 81, |
| 2969 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 2970 | 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2971 | 0, 0, 0, 302, 0, 0, 0, 0, 0, 0, |
| 2972 | 0, 0, 74, 75, 89, 199, 208, 209, 210, 211, |
| 2973 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 2974 | 0, 21, 74, 75, 0, 199, 77, 78, 79, 80, |
| 2975 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 2976 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 0, |
| 2977 | 0, 0, 0, 0, 413, 0, 0, 0, 0, 0, |
| 2978 | 0, 0, 0, 74, 75, 89, 199, 77, 78, 79, |
| 2979 | 80, 81, 82, 83, 84, 85, 86, 87, 0, 88, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2980 | 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2981 | 0, 0, 0, 0, 0, 451, 0, 0, 0, 0, |
| 2982 | 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, |
| 2983 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
| 2984 | 74, 75, 0, 199, 77, 78, 79, 80, 81, 82, |
| 2985 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2986 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2987 | 0, 90, 519, 0, 91, 0, 399, 92, 0, 93, |
| 2988 | 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, |
| 2989 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 93, |
| 2990 | 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, |
| 2991 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
| 2992 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2993 | 0, 0, 90, 0, 0, 91, 0, 0, 92, 0, |
| 2994 | 93, 74, 75, 89, 199, 77, 78, 79, 80, 81, |
| 2995 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 2996 | 21, 74, 75, 0, 199, 208, 209, 210, 211, 212, |
| 2997 | 213, 214, 215, 216, 217, 218, 0, 88, 20, 0, |
| 2998 | 21, 0, 0, 0, 89, 0, 0, 0, 0, 90, |
| 2999 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 3000 | 0, 0, 74, 75, 89, 229, 77, 78, 79, 80, |
| 3001 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 3002 | 0, 21, 74, 75, 0, 199, 208, 209, 210, 211, |
| 3003 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 3004 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 90, |
| 3005 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 3006 | 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3007 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3008 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3009 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3010 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3011 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3012 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3013 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3014 | 0, 0, 0, 0, 114, 0, 0, 0, 0, 0, |
| 3015 | 0, 90, 0, 0, 91, 0, 0, 92, 115, 93, |
| 3016 | 0, 0, 0, 0, 0, 0, 0, 0, 116, 117, |
| 3017 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 402, |
| 3018 | 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 3019 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3020 | 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3021 | 147, 148, 149, 150, 151, 152, 153, 0, 0, 154, |
| 3022 | 155, 156, 157, 158, 159, 160, 161, 162, 0, 0, |
| 3023 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 3024 | 0, 0, 0, 0, 0, 0, 0, 0, 163, 164, |
| 3025 | 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 3026 | 175 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3027 | }; |
| 3028 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3029 | static const short yycheck[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3030 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3031 | 45, 120, 115, 63, 120, 118, 107, 274, 4, 23, |
| 3032 | 29, 3, 161, 0, 121, 164, 30, 558, 63, 93, |
| 3033 | 5, 6, 15, 8, 9, 10, 11, 12, 13, 14, |
| 3034 | 15, 16, 17, 18, 19, 15, 21, 22, 579, 24, |
| 3035 | 153, 33, 23, 156, 157, 158, 159, 160, 161, 162, |
| 3036 | 578, 10, 11, 12, 13, 14, 15, 16, 17, 104, |
| 3037 | 105, 106, 590, 48, 57, 152, 179, 180, 306, 307, |
| 3038 | 115, 153, 153, 118, 326, 327, 183, 57, 34, 161, |
| 3039 | 5, 6, 163, 8, 9, 10, 11, 12, 13, 14, |
| 3040 | 15, 16, 17, 18, 19, 347, 21, 22, 336, 24, |
| 3041 | 159, 57, 52, 53, 54, 164, 151, 152, 153, 154, |
| 3042 | 155, 156, 157, 158, 159, 160, 161, 162, 110, 153, |
| 3043 | 22, 71, 24, 48, 198, 9, 153, 161, 153, 203, |
| 3044 | 155, 176, 177, 178, 179, 180, 163, 21, 163, 164, |
| 3045 | 153, 231, 232, 162, 61, 153, 159, 198, 61, 163, |
| 3046 | 402, 159, 203, 243, 10, 11, 12, 13, 14, 15, |
| 3047 | 16, 17, 0, 153, 153, 24, 162, 155, 45, 154, |
| 3048 | 47, 157, 157, 163, 163, 160, 164, 162, 163, 152, |
| 3049 | 293, 47, 48, 49, 244, 152, 276, 25, 32, 33, |
| 3050 | 55, 56, 152, 31, 108, 109, 286, 287, 288, 244, |
| 3051 | 159, 27, 28, 41, 42, 43, 44, 45, 46, 47, |
| 3052 | 255, 3, 4, 3, 4, 3, 4, 455, 152, 486, |
| 3053 | 152, 488, 296, 297, 62, 4, 300, 272, 24, 154, |
| 3054 | 4, 291, 157, 3, 4, 160, 155, 162, 163, 64, |
| 3055 | 65, 66, 67, 68, 69, 70, 291, 292, 293, 3, |
| 3056 | 4, 24, 365, 20, 367, 368, 369, 77, 78, 24, |
| 3057 | 4, 4, 375, 155, 59, 355, 356, 357, 158, 158, |
| 3058 | 4, 4, 4, 363, 41, 42, 43, 44, 45, 46, |
| 3059 | 47, 4, 7, 50, 4, 7, 7, 377, 378, 157, |
| 3060 | 153, 155, 337, 394, 395, 396, 397, 398, 153, 153, |
| 3061 | 153, 153, 153, 159, 153, 153, 407, 408, 409, 410, |
| 3062 | 411, 153, 386, 153, 153, 24, 161, 36, 153, 156, |
| 3063 | 365, 366, 367, 368, 369, 370, 371, 155, 402, 153, |
| 3064 | 375, 376, 155, 155, 155, 24, 426, 155, 428, 155, |
| 3065 | 155, 155, 432, 155, 155, 63, 153, 153, 153, 157, |
| 3066 | 440, 441, 442, 153, 153, 456, 457, 161, 155, 153, |
| 3067 | 153, 24, 463, 21, 222, 156, 155, 153, 226, 21, |
| 3068 | 155, 153, 153, 231, 232, 4, 153, 153, 153, 4, |
| 3069 | 493, 494, 495, 155, 429, 243, 24, 153, 36, 153, |
| 3070 | 153, 481, 482, 153, 484, 485, 153, 153, 153, 161, |
| 3071 | 153, 491, 447, 153, 34, 153, 507, 508, 509, 510, |
| 3072 | 500, 153, 153, 514, 515, 516, 517, 153, 276, 156, |
| 3073 | 533, 161, 414, 153, 153, 57, 24, 153, 286, 287, |
| 3074 | 288, 57, 477, 157, 4, 21, 153, 153, 483, 558, |
| 3075 | 541, 542, 558, 156, 159, 535, 156, 153, 493, 494, |
| 3076 | 495, 156, 156, 156, 499, 156, 27, 28, 156, 156, |
| 3077 | 579, 36, 156, 579, 159, 566, 156, 568, 569, 21, |
| 3078 | 156, 156, 156, 518, 119, 120, 121, 122, 123, 124, |
| 3079 | 125, 126, 127, 128, 153, 21, 576, 153, 533, 10, |
| 3080 | 11, 12, 13, 14, 15, 16, 17, 355, 356, 357, |
| 3081 | 65, 591, 21, 21, 65, 363, 65, 65, 598, 318, |
| 3082 | 65, 33, 602, 603, 25, 478, 319, 44, 108, 377, |
| 3083 | 378, 3, 222, 477, 19, 597, 429, 499, 458, -1, |
| 3084 | -1, -1, -1, -1, 5, 6, -1, 8, 9, 10, |
| 3085 | 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, |
| 3086 | 21, 22, -1, 24, 125, 126, 127, 128, 129, 130, |
| 3087 | 131, 132, 133, 134, 135, 136, 137, 138, 426, -1, |
| 3088 | 428, 5, 6, -1, 432, -1, -1, 48, -1, -1, |
| 3089 | -1, -1, 440, 441, 442, -1, -1, 20, 22, 22, |
| 3090 | 24, 24, 26, -1, -1, -1, -1, -1, 31, 32, |
| 3091 | 33, -1, -1, -1, 38, 39, -1, -1, 41, 42, |
| 3092 | 43, 44, 45, 46, 47, -1, -1, 50, 51, -1, |
| 3093 | -1, -1, -1, 481, 482, 58, 484, 485, -1, 62, |
| 3094 | -1, -1, -1, 491, -1, -1, -1, -1, -1, -1, |
| 3095 | -1, -1, 500, -1, -1, 79, 80, 81, 82, 83, |
| 3096 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3097 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3098 | 104, -1, -1, -1, -1, -1, 110, 535, 112, -1, |
| 3099 | 114, 115, 116, 154, -1, -1, 157, -1, -1, 160, |
| 3100 | -1, 162, 163, -1, -1, -1, -1, -1, -1, -1, |
| 3101 | -1, -1, -1, -1, -1, 139, 140, 141, 142, 143, |
| 3102 | 144, 145, 146, 147, 148, 149, 150, 151, 576, -1, |
| 3103 | -1, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3104 | -1, 165, -1, 591, -1, -1, -1, -1, -1, -1, |
| 3105 | 598, -1, -1, -1, 602, 603, 5, 6, -1, 8, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3106 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3107 | 19, -1, 21, 22, -1, 24, -1, -1, -1, 3, |
| 3108 | 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, |
| 3109 | -1, -1, -1, -1, -1, -1, -1, -1, 22, 48, |
| 3110 | 24, -1, 26, 27, 28, -1, -1, -1, -1, -1, |
| 3111 | -1, -1, -1, -1, 38, 39, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3112 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3113 | -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, |
| 3114 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3115 | -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, |
| 3116 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3117 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3118 | 104, -1, -1, -1, -1, -1, 110, -1, 112, -1, |
| 3119 | 114, 115, 116, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3120 | -1, -1, -1, -1, -1, 154, 3, 4, 157, -1, |
| 3121 | 7, 160, -1, 162, 163, 139, 140, 141, 142, 143, |
| 3122 | 144, 145, 146, 147, 148, 149, 150, 151, -1, 26, |
| 3123 | 27, 28, -1, -1, -1, -1, 160, -1, -1, -1, |
| 3124 | -1, 38, 39, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3125 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3126 | -1, -1, -1, -1, 61, -1, -1, -1, -1, -1, |
| 3127 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3128 | -1, -1, 79, 80, 81, 82, 83, 84, 85, 86, |
| 3129 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 3130 | 97, 98, 99, 100, 101, 102, 103, 104, -1, -1, |
| 3131 | -1, -1, -1, 110, -1, 112, -1, 114, 115, 116, |
| 3132 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3133 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3134 | -1, -1, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3135 | 147, 148, 149, 150, 151, -1, -1, -1, -1, -1, |
| 3136 | -1, 5, 6, 160, 8, 9, 10, 11, 12, 13, |
| 3137 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3138 | 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3139 | -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, |
| 3140 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3141 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3142 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3143 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3144 | -1, 24, -1, -1, -1, 48, -1, -1, -1, -1, |
| 3145 | -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, |
| 3146 | -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3147 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 3148 | 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3149 | -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, |
| 3150 | -1, -1, -1, -1, -1, -1, 48, -1, -1, -1, |
| 3151 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3152 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3153 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 3154 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3155 | -1, 154, 37, -1, 157, -1, 159, 160, -1, 162, |
| 3156 | -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3157 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3158 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3159 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3160 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3161 | -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3162 | 162, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 3163 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3164 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 3165 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3166 | 24, -1, -1, -1, 48, -1, -1, -1, -1, 154, |
| 3167 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3168 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 3169 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3170 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3171 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3172 | -1, 24, -1, -1, -1, 48, -1, -1, -1, 154, |
| 3173 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3174 | -1, -1, -1, -1, -1, 48, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3175 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3176 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3177 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3178 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3179 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3180 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3181 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3182 | -1, -1, -1, -1, 35, -1, -1, -1, -1, -1, |
| 3183 | -1, 154, -1, -1, 157, -1, -1, 160, 49, 162, |
| 3184 | -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, |
| 3185 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 3186 | -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 3187 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 3188 | 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, |
| 3189 | 101, 102, 103, 104, 105, 106, 107, -1, -1, 110, |
| 3190 | 111, 112, 113, 114, 115, 116, 117, 118, -1, -1, |
| 3191 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3192 | -1, -1, -1, -1, -1, -1, -1, -1, 139, 140, |
| 3193 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, |
| 3194 | 151 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3195 | }; |
| 3196 | |
| 3197 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 3198 | symbol of state STATE-NUM. */ |
| 3199 | static const unsigned char yystos[] = |
| 3200 | { |
| 3201 | 0, 200, 201, 202, 0, 25, 31, 41, 42, 43, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3202 | 44, 45, 46, 47, 62, 181, 219, 222, 224, 232, |
| 3203 | 22, 24, 51, 58, 62, 180, 212, 224, 225, 61, |
| 3204 | 220, 23, 233, 234, 30, 163, 221, 233, 52, 53, |
| 3205 | 54, 71, 209, 152, 61, 20, 45, 47, 50, 181, |
| 3206 | 152, 45, 47, 223, 24, 207, 64, 65, 66, 67, |
| 3207 | 68, 69, 70, 182, 217, 180, 238, 152, 152, 152, |
| 3208 | 152, 157, 210, 207, 5, 6, 8, 9, 10, 11, |
| 3209 | 12, 13, 14, 15, 16, 17, 18, 19, 21, 48, |
| 3210 | 154, 157, 160, 162, 167, 189, 190, 191, 192, 193, |
| 3211 | 212, 229, 32, 33, 199, 199, 199, 199, 226, 4, |
| 3212 | 189, 29, 162, 218, 35, 49, 59, 60, 72, 73, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3213 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 3214 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3215 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3216 | 104, 105, 106, 107, 110, 111, 112, 113, 114, 115, |
| 3217 | 116, 117, 118, 139, 140, 141, 142, 143, 144, 145, |
| 3218 | 146, 147, 148, 149, 150, 151, 169, 170, 171, 174, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3219 | 175, 235, 236, 242, 243, 245, 246, 24, 55, 56, |
| 3220 | 208, 4, 24, 24, 211, 4, 4, 4, 162, 8, |
| 3221 | 163, 193, 194, 155, 164, 191, 191, 191, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3222 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 176, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3223 | 177, 179, 191, 196, 217, 212, 191, 231, 59, 8, |
| 3224 | 231, 9, 21, 10, 11, 12, 13, 14, 15, 16, |
| 3225 | 17, 176, 177, 178, 182, 119, 120, 121, 122, 123, |
| 3226 | 124, 125, 126, 127, 128, 172, 27, 28, 125, 126, |
| 3227 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3228 | 137, 138, 173, 191, 191, 231, 191, 191, 239, 231, |
| 3229 | 231, 231, 231, 231, 231, 231, 191, 191, 191, 231, |
| 3230 | 231, 182, 108, 109, 153, 159, 158, 158, 163, 194, |
| 3231 | 153, 163, 37, 194, 195, 205, 206, 204, 27, 28, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3232 | 3, 4, 168, 4, 7, 26, 38, 39, 103, 104, |
| 3233 | 110, 112, 114, 115, 116, 157, 160, 162, 165, 169, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3234 | 170, 171, 174, 175, 197, 229, 203, 155, 3, 4, |
| 3235 | 7, 26, 27, 28, 38, 39, 61, 160, 197, 228, |
| 3236 | 229, 230, 230, 230, 230, 189, 191, 191, 153, 184, |
| 3237 | 153, 184, 230, 157, 153, 153, 153, 153, 153, 153, |
| 3238 | 153, 153, 230, 230, 230, 153, 36, 189, 191, 231, |
| 3239 | 24, 193, 193, 161, 163, 193, 153, 156, 153, 187, |
| 3240 | 187, 187, 172, 173, 155, 155, 155, 155, 155, 159, |
| 3241 | 196, 198, 162, 198, 163, 198, 24, 155, 155, 155, |
| 3242 | 155, 155, 187, 37, 191, 214, 215, 216, 63, 227, |
| 3243 | 198, 153, 153, 230, 230, 230, 15, 57, 15, 153, |
| 3244 | 244, 230, 157, 231, 191, 231, 231, 231, 191, 191, |
| 3245 | 153, 153, 153, 231, 191, 230, 230, 153, 159, 161, |
| 3246 | 161, 37, 34, 57, 185, 188, 155, 155, 196, 196, |
| 3247 | 196, 196, 196, 153, 159, 163, 193, 198, 161, 163, |
| 3248 | 196, 196, 196, 196, 196, 212, 213, 153, 156, 24, |
| 3249 | 161, 21, 21, 155, 153, 153, 230, 4, 230, 231, |
| 3250 | 240, 153, 230, 153, 153, 153, 230, 230, 230, 155, |
| 3251 | 191, 24, 4, 187, 196, 196, 244, 153, 153, 153, |
| 3252 | 153, 196, 161, 163, 153, 153, 153, 153, 36, 37, |
| 3253 | 214, 185, 186, 153, 230, 230, 240, 241, 230, 230, |
| 3254 | 153, 184, 184, 153, 230, 153, 231, 231, 231, 241, |
| 3255 | 230, 153, 153, 156, 196, 196, 196, 196, 161, 196, |
| 3256 | 196, 196, 196, 191, 57, 183, 24, 153, 157, 156, |
| 3257 | 231, 159, 230, 156, 196, 196, 153, 156, 153, 153, |
| 3258 | 156, 156, 156, 156, 156, 4, 21, 159, 178, 237, |
| 3259 | 36, 159, 156, 156, 196, 196, 196, 230, 228, 159, |
| 3260 | 178, 21, 156, 156, 156, 153, 228, 230, 21, 153, |
| 3261 | 235, 230, 21, 21, 230, 230 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3262 | }; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3263 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3264 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 3265 | # define YYSIZE_T __SIZE_TYPE__ |
| 3266 | #endif |
| 3267 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 3268 | # define YYSIZE_T size_t |
| 3269 | #endif |
| 3270 | #if ! defined (YYSIZE_T) |
| 3271 | # if defined (__STDC__) || defined (__cplusplus) |
| 3272 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 3273 | # define YYSIZE_T size_t |
| 3274 | # endif |
| 3275 | #endif |
| 3276 | #if ! defined (YYSIZE_T) |
| 3277 | # define YYSIZE_T unsigned int |
| 3278 | #endif |
| 3279 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3280 | #define yyerrok (yyerrstatus = 0) |
| 3281 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3282 | #define YYEMPTY (-2) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3283 | #define YYEOF 0 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3284 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3285 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3286 | #define YYABORT goto yyabortlab |
| 3287 | #define YYERROR goto yyerrorlab |
| 3288 | |
| 3289 | |
| 3290 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 3291 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3292 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3293 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3294 | #define YYFAIL goto yyerrlab |
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 YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3297 | |
| 3298 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3299 | do \ |
| 3300 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3301 | { \ |
| 3302 | yychar = (Token); \ |
| 3303 | yylval = (Value); \ |
| 3304 | yytoken = YYTRANSLATE (yychar); \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3305 | YYPOPSTACK; \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3306 | goto yybackup; \ |
| 3307 | } \ |
| 3308 | else \ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3309 | { \ |
| 3310 | yyerror ("syntax error: cannot back up");\ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3311 | YYERROR; \ |
| 3312 | } \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3313 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3314 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3315 | #define YYTERROR 1 |
| 3316 | #define YYERRCODE 256 |
| 3317 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3318 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions |
| 3319 | are run). */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3320 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3321 | #ifndef YYLLOC_DEFAULT |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3322 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 3323 | ((Current).first_line = (Rhs)[1].first_line, \ |
| 3324 | (Current).first_column = (Rhs)[1].first_column, \ |
| 3325 | (Current).last_line = (Rhs)[N].last_line, \ |
| 3326 | (Current).last_column = (Rhs)[N].last_column) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3327 | #endif |
| 3328 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3329 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 3330 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3331 | #ifdef YYLEX_PARAM |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3332 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3333 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3334 | # define YYLEX yylex () |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3335 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3336 | |
| 3337 | /* Enable debugging if requested. */ |
| 3338 | #if YYDEBUG |
| 3339 | |
| 3340 | # ifndef YYFPRINTF |
| 3341 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 3342 | # define YYFPRINTF fprintf |
| 3343 | # endif |
| 3344 | |
| 3345 | # define YYDPRINTF(Args) \ |
| 3346 | do { \ |
| 3347 | if (yydebug) \ |
| 3348 | YYFPRINTF Args; \ |
| 3349 | } while (0) |
| 3350 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3351 | # define YYDSYMPRINT(Args) \ |
| 3352 | do { \ |
| 3353 | if (yydebug) \ |
| 3354 | yysymprint Args; \ |
| 3355 | } while (0) |
| 3356 | |
| 3357 | # define YYDSYMPRINTF(Title, Token, Value, Location) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3358 | do { \ |
| 3359 | if (yydebug) \ |
| 3360 | { \ |
| 3361 | YYFPRINTF (stderr, "%s ", Title); \ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3362 | yysymprint (stderr, \ |
| 3363 | Token, Value); \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3364 | YYFPRINTF (stderr, "\n"); \ |
| 3365 | } \ |
| 3366 | } while (0) |
| 3367 | |
| 3368 | /*------------------------------------------------------------------. |
| 3369 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 3370 | | TOP (included). | |
| 3371 | `------------------------------------------------------------------*/ |
| 3372 | |
| 3373 | #if defined (__STDC__) || defined (__cplusplus) |
| 3374 | static void |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3375 | yy_stack_print (short *bottom, short *top) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3376 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3377 | static void |
| 3378 | yy_stack_print (bottom, top) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3379 | short *bottom; |
| 3380 | short *top; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3381 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3382 | { |
| 3383 | YYFPRINTF (stderr, "Stack now"); |
| 3384 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 3385 | YYFPRINTF (stderr, " %d", *bottom); |
| 3386 | YYFPRINTF (stderr, "\n"); |
| 3387 | } |
| 3388 | |
| 3389 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 3390 | do { \ |
| 3391 | if (yydebug) \ |
| 3392 | yy_stack_print ((Bottom), (Top)); \ |
| 3393 | } while (0) |
| 3394 | |
| 3395 | |
| 3396 | /*------------------------------------------------. |
| 3397 | | Report that the YYRULE is going to be reduced. | |
| 3398 | `------------------------------------------------*/ |
| 3399 | |
| 3400 | #if defined (__STDC__) || defined (__cplusplus) |
| 3401 | static void |
| 3402 | yy_reduce_print (int yyrule) |
| 3403 | #else |
| 3404 | static void |
| 3405 | yy_reduce_print (yyrule) |
| 3406 | int yyrule; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3407 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3408 | { |
| 3409 | int yyi; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3410 | unsigned int yylno = yyrline[yyrule]; |
| 3411 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3412 | yyrule - 1, yylno); |
| 3413 | /* Print the symbols being reduced, and their result. */ |
| 3414 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3415 | YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); |
| 3416 | YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3417 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3418 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3419 | # define YY_REDUCE_PRINT(Rule) \ |
| 3420 | do { \ |
| 3421 | if (yydebug) \ |
| 3422 | yy_reduce_print (Rule); \ |
| 3423 | } while (0) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3424 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3425 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 3426 | multiple parsers can coexist. */ |
| 3427 | int yydebug; |
| 3428 | #else /* !YYDEBUG */ |
| 3429 | # define YYDPRINTF(Args) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3430 | # define YYDSYMPRINT(Args) |
| 3431 | # define YYDSYMPRINTF(Title, Token, Value, Location) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3432 | # define YY_STACK_PRINT(Bottom, Top) |
| 3433 | # define YY_REDUCE_PRINT(Rule) |
| 3434 | #endif /* !YYDEBUG */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3435 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3436 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3437 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3438 | #ifndef YYINITDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3439 | # define YYINITDEPTH 200 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3440 | #endif |
| 3441 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3442 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 3443 | if the built-in stack extension method is used). |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3444 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3445 | Do not make this value too large; the results are undefined if |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3446 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3447 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3448 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3449 | #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 |
| 3450 | # undef YYMAXDEPTH |
| 3451 | #endif |
| 3452 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3453 | #ifndef YYMAXDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3454 | # define YYMAXDEPTH 10000 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3455 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3456 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3457 | |
| 3458 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3459 | #if YYERROR_VERBOSE |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3460 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3461 | # ifndef yystrlen |
| 3462 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 3463 | # define yystrlen strlen |
| 3464 | # else |
| 3465 | /* Return the length of YYSTR. */ |
| 3466 | static YYSIZE_T |
| 3467 | # if defined (__STDC__) || defined (__cplusplus) |
| 3468 | yystrlen (const char *yystr) |
| 3469 | # else |
| 3470 | yystrlen (yystr) |
| 3471 | const char *yystr; |
| 3472 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3473 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3474 | register const char *yys = yystr; |
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 | while (*yys++ != '\0') |
| 3477 | continue; |
| 3478 | |
| 3479 | return yys - yystr - 1; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3480 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3481 | # endif |
| 3482 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3483 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3484 | # ifndef yystpcpy |
| 3485 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 3486 | # define yystpcpy stpcpy |
| 3487 | # else |
| 3488 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 3489 | YYDEST. */ |
| 3490 | static char * |
| 3491 | # if defined (__STDC__) || defined (__cplusplus) |
| 3492 | yystpcpy (char *yydest, const char *yysrc) |
| 3493 | # else |
| 3494 | yystpcpy (yydest, yysrc) |
| 3495 | char *yydest; |
| 3496 | const char *yysrc; |
| 3497 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3498 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3499 | register char *yyd = yydest; |
| 3500 | register const char *yys = yysrc; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3501 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3502 | while ((*yyd++ = *yys++) != '\0') |
| 3503 | continue; |
| 3504 | |
| 3505 | return yyd - 1; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3506 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3507 | # endif |
| 3508 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3509 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3510 | #endif /* !YYERROR_VERBOSE */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3511 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3512 | |
| 3513 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3514 | #if YYDEBUG |
| 3515 | /*--------------------------------. |
| 3516 | | Print this symbol on YYOUTPUT. | |
| 3517 | `--------------------------------*/ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3518 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3519 | #if defined (__STDC__) || defined (__cplusplus) |
| 3520 | static void |
| 3521 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3522 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3523 | static void |
| 3524 | yysymprint (yyoutput, yytype, yyvaluep) |
| 3525 | FILE *yyoutput; |
| 3526 | int yytype; |
| 3527 | YYSTYPE *yyvaluep; |
| 3528 | #endif |
| 3529 | { |
| 3530 | /* Pacify ``unused variable'' warnings. */ |
| 3531 | (void) yyvaluep; |
| 3532 | |
| 3533 | if (yytype < YYNTOKENS) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3534 | { |
| 3535 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 3536 | # ifdef YYPRINT |
| 3537 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 3538 | # endif |
| 3539 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3540 | else |
| 3541 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 3542 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3543 | switch (yytype) |
| 3544 | { |
| 3545 | default: |
| 3546 | break; |
| 3547 | } |
| 3548 | YYFPRINTF (yyoutput, ")"); |
| 3549 | } |
| 3550 | |
| 3551 | #endif /* ! YYDEBUG */ |
| 3552 | /*-----------------------------------------------. |
| 3553 | | Release the memory associated to this symbol. | |
| 3554 | `-----------------------------------------------*/ |
| 3555 | |
| 3556 | #if defined (__STDC__) || defined (__cplusplus) |
| 3557 | static void |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3558 | yydestruct (int yytype, YYSTYPE *yyvaluep) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3559 | #else |
| 3560 | static void |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3561 | yydestruct (yytype, yyvaluep) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3562 | int yytype; |
| 3563 | YYSTYPE *yyvaluep; |
| 3564 | #endif |
| 3565 | { |
| 3566 | /* Pacify ``unused variable'' warnings. */ |
| 3567 | (void) yyvaluep; |
| 3568 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3569 | switch (yytype) |
| 3570 | { |
| 3571 | |
| 3572 | default: |
| 3573 | break; |
| 3574 | } |
| 3575 | } |
| 3576 | |
| 3577 | |
| 3578 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 3579 | |
| 3580 | #ifdef YYPARSE_PARAM |
| 3581 | # if defined (__STDC__) || defined (__cplusplus) |
| 3582 | int yyparse (void *YYPARSE_PARAM); |
| 3583 | # else |
| 3584 | int yyparse (); |
| 3585 | # endif |
| 3586 | #else /* ! YYPARSE_PARAM */ |
| 3587 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3588 | int yyparse (void); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3589 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3590 | int yyparse (); |
| 3591 | #endif |
| 3592 | #endif /* ! YYPARSE_PARAM */ |
| 3593 | |
| 3594 | |
| 3595 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3596 | /* The lookahead symbol. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3597 | int yychar; |
| 3598 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3599 | /* The semantic value of the lookahead symbol. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3600 | YYSTYPE yylval; |
| 3601 | |
| 3602 | /* Number of syntax errors so far. */ |
| 3603 | int yynerrs; |
| 3604 | |
| 3605 | |
| 3606 | |
| 3607 | /*----------. |
| 3608 | | yyparse. | |
| 3609 | `----------*/ |
| 3610 | |
| 3611 | #ifdef YYPARSE_PARAM |
| 3612 | # if defined (__STDC__) || defined (__cplusplus) |
| 3613 | int yyparse (void *YYPARSE_PARAM) |
| 3614 | # else |
| 3615 | int yyparse (YYPARSE_PARAM) |
| 3616 | void *YYPARSE_PARAM; |
| 3617 | # endif |
| 3618 | #else /* ! YYPARSE_PARAM */ |
| 3619 | #if defined (__STDC__) || defined (__cplusplus) |
| 3620 | int |
| 3621 | yyparse (void) |
| 3622 | #else |
| 3623 | int |
| 3624 | yyparse () |
| 3625 | |
| 3626 | #endif |
| 3627 | #endif |
| 3628 | { |
| 3629 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3630 | register int yystate; |
| 3631 | register int yyn; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3632 | int yyresult; |
| 3633 | /* Number of tokens to shift before error messages enabled. */ |
| 3634 | int yyerrstatus; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3635 | /* Lookahead token as an internal (translated) token number. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3636 | int yytoken = 0; |
| 3637 | |
| 3638 | /* Three stacks and their tools: |
| 3639 | `yyss': related to states, |
| 3640 | `yyvs': related to semantic values, |
| 3641 | `yyls': related to locations. |
| 3642 | |
| 3643 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 3644 | to reallocate them elsewhere. */ |
| 3645 | |
| 3646 | /* The state stack. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3647 | short yyssa[YYINITDEPTH]; |
| 3648 | short *yyss = yyssa; |
| 3649 | register short *yyssp; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3650 | |
| 3651 | /* The semantic value stack. */ |
| 3652 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 3653 | YYSTYPE *yyvs = yyvsa; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3654 | register YYSTYPE *yyvsp; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3655 | |
| 3656 | |
| 3657 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3658 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3659 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3660 | YYSIZE_T yystacksize = YYINITDEPTH; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3661 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3662 | /* The variables used to return semantic value and location from the |
| 3663 | action routines. */ |
| 3664 | YYSTYPE yyval; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3665 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3666 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3667 | /* When reducing, the number of symbols on the RHS of the reduced |
| 3668 | rule. */ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3669 | int yylen; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3670 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3671 | YYDPRINTF ((stderr, "Starting parse\n")); |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3672 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3673 | yystate = 0; |
| 3674 | yyerrstatus = 0; |
| 3675 | yynerrs = 0; |
| 3676 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 3677 | |
| 3678 | /* Initialize stack pointers. |
| 3679 | Waste one element of value and location stack |
| 3680 | so that they stay on the same level as the state stack. |
| 3681 | The wasted elements are never initialized. */ |
| 3682 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3683 | yyssp = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3684 | yyvsp = yyvs; |
| 3685 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3686 | goto yysetstate; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3687 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3688 | /*------------------------------------------------------------. |
| 3689 | | yynewstate -- Push a new state, which is found in yystate. | |
| 3690 | `------------------------------------------------------------*/ |
| 3691 | yynewstate: |
| 3692 | /* In all cases, when you get here, the value and location stacks |
| 3693 | have just been pushed. so pushing a state here evens the stacks. |
| 3694 | */ |
| 3695 | yyssp++; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3696 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3697 | yysetstate: |
| 3698 | *yyssp = yystate; |
| 3699 | |
| 3700 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3701 | { |
| 3702 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3703 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3704 | |
| 3705 | #ifdef yyoverflow |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3706 | { |
| 3707 | /* Give user a chance to reallocate the stack. Use copies of |
| 3708 | these so that the &'s don't force the real ones into |
| 3709 | memory. */ |
| 3710 | YYSTYPE *yyvs1 = yyvs; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3711 | short *yyss1 = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3712 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3713 | |
| 3714 | /* Each stack pointer address is followed by the size of the |
| 3715 | data in use in that stack, in bytes. This used to be a |
| 3716 | conditional around just the two extra args, but that might |
| 3717 | be undefined if yyoverflow is a macro. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3718 | yyoverflow ("parser stack overflow", |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3719 | &yyss1, yysize * sizeof (*yyssp), |
| 3720 | &yyvs1, yysize * sizeof (*yyvsp), |
| 3721 | |
| 3722 | &yystacksize); |
| 3723 | |
| 3724 | yyss = yyss1; |
| 3725 | yyvs = yyvs1; |
| 3726 | } |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3727 | #else /* no yyoverflow */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3728 | # ifndef YYSTACK_RELOCATE |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3729 | goto yyoverflowlab; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3730 | # else |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3731 | /* Extend the stack our own way. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3732 | if (YYMAXDEPTH <= yystacksize) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3733 | goto yyoverflowlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3734 | yystacksize *= 2; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3735 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3736 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3737 | |
| 3738 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3739 | short *yyss1 = yyss; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3740 | union yyalloc *yyptr = |
| 3741 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 3742 | if (! yyptr) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3743 | goto yyoverflowlab; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3744 | YYSTACK_RELOCATE (yyss); |
| 3745 | YYSTACK_RELOCATE (yyvs); |
| 3746 | |
| 3747 | # undef YYSTACK_RELOCATE |
| 3748 | if (yyss1 != yyssa) |
| 3749 | YYSTACK_FREE (yyss1); |
| 3750 | } |
| 3751 | # endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3752 | #endif /* no yyoverflow */ |
| 3753 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3754 | yyssp = yyss + yysize - 1; |
| 3755 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3756 | |
| 3757 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3758 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 3759 | (unsigned long int) yystacksize)); |
| 3760 | |
| 3761 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3762 | YYABORT; |
| 3763 | } |
| 3764 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3765 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3766 | |
| 3767 | goto yybackup; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3768 | |
| 3769 | /*-----------. |
| 3770 | | yybackup. | |
| 3771 | `-----------*/ |
| 3772 | yybackup: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3773 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3774 | /* Do appropriate processing given the current state. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3775 | /* Read a lookahead token if we need one and don't already have one. */ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3776 | /* yyresume: */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3777 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3778 | /* First try to decide what to do without reference to lookahead token. */ |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3779 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3780 | yyn = yypact[yystate]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3781 | if (yyn == YYPACT_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3782 | goto yydefault; |
| 3783 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3784 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3785 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3786 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3787 | if (yychar == YYEMPTY) |
| 3788 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3789 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3790 | yychar = YYLEX; |
| 3791 | } |
| 3792 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3793 | if (yychar <= YYEOF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3794 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3795 | yychar = yytoken = YYEOF; |
| 3796 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3797 | } |
| 3798 | else |
| 3799 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3800 | yytoken = YYTRANSLATE (yychar); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3801 | YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3802 | } |
| 3803 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3804 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 3805 | detect an error, take that action. */ |
| 3806 | yyn += yytoken; |
| 3807 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3808 | goto yydefault; |
| 3809 | yyn = yytable[yyn]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3810 | if (yyn <= 0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3811 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3812 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3813 | goto yyerrlab; |
| 3814 | yyn = -yyn; |
| 3815 | goto yyreduce; |
| 3816 | } |
| 3817 | |
| 3818 | if (yyn == YYFINAL) |
| 3819 | YYACCEPT; |
| 3820 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3821 | /* Shift the lookahead token. */ |
| 3822 | YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3823 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3824 | /* Discard the token being shifted unless it is eof. */ |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3825 | if (yychar != YYEOF) |
| 3826 | yychar = YYEMPTY; |
| 3827 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3828 | *++yyvsp = yylval; |
| 3829 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3830 | |
| 3831 | /* Count tokens shifted since error; after three, turn off error |
| 3832 | status. */ |
| 3833 | if (yyerrstatus) |
| 3834 | yyerrstatus--; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3835 | |
| 3836 | yystate = yyn; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3837 | goto yynewstate; |
| 3838 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3839 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3840 | /*-----------------------------------------------------------. |
| 3841 | | yydefault -- do the default action for the current state. | |
| 3842 | `-----------------------------------------------------------*/ |
| 3843 | yydefault: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3844 | yyn = yydefact[yystate]; |
| 3845 | if (yyn == 0) |
| 3846 | goto yyerrlab; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3847 | goto yyreduce; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3848 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3849 | |
| 3850 | /*-----------------------------. |
| 3851 | | yyreduce -- Do a reduction. | |
| 3852 | `-----------------------------*/ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3853 | yyreduce: |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3854 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3855 | yylen = yyr2[yyn]; |
| 3856 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3857 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3858 | `$$ = $1'. |
| 3859 | |
| 3860 | Otherwise, the following line sets YYVAL to garbage. |
| 3861 | This behavior is undocumented and Bison |
| 3862 | users should not rely upon it. Assigning to YYVAL |
| 3863 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3864 | GCC warning that YYVAL may be used uninitialized. */ |
| 3865 | yyval = yyvsp[1-yylen]; |
| 3866 | |
| 3867 | |
| 3868 | YY_REDUCE_PRINT (yyn); |
| 3869 | switch (yyn) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3870 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3871 | case 3: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3872 | #line 1917 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3873 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3874 | if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3875 | error("Value too large for type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3876 | yyval.SIntVal = (int32_t)yyvsp[0].UIntVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3877 | ;} |
| 3878 | break; |
| 3879 | |
| 3880 | case 5: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3881 | #line 1926 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3882 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3883 | if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3884 | error("Value too large for type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3885 | yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3886 | ;} |
| 3887 | break; |
| 3888 | |
| 3889 | case 26: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3890 | #line 1948 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3891 | { yyval.IPred = ICmpInst::ICMP_EQ; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3892 | break; |
| 3893 | |
| 3894 | case 27: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3895 | #line 1948 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3896 | { yyval.IPred = ICmpInst::ICMP_NE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3897 | break; |
| 3898 | |
| 3899 | case 28: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3900 | #line 1949 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3901 | { yyval.IPred = ICmpInst::ICMP_SLT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3902 | break; |
| 3903 | |
| 3904 | case 29: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3905 | #line 1949 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3906 | { yyval.IPred = ICmpInst::ICMP_SGT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3907 | break; |
| 3908 | |
| 3909 | case 30: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3910 | #line 1950 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3911 | { yyval.IPred = ICmpInst::ICMP_SLE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3912 | break; |
| 3913 | |
| 3914 | case 31: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3915 | #line 1950 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3916 | { yyval.IPred = ICmpInst::ICMP_SGE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3917 | break; |
| 3918 | |
| 3919 | case 32: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3920 | #line 1951 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3921 | { yyval.IPred = ICmpInst::ICMP_ULT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3922 | break; |
| 3923 | |
| 3924 | case 33: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3925 | #line 1951 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3926 | { yyval.IPred = ICmpInst::ICMP_UGT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3927 | break; |
| 3928 | |
| 3929 | case 34: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3930 | #line 1952 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3931 | { yyval.IPred = ICmpInst::ICMP_ULE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3932 | break; |
| 3933 | |
| 3934 | case 35: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3935 | #line 1952 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3936 | { yyval.IPred = ICmpInst::ICMP_UGE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3937 | break; |
| 3938 | |
| 3939 | case 36: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3940 | #line 1956 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3941 | { yyval.FPred = FCmpInst::FCMP_OEQ; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3942 | break; |
| 3943 | |
| 3944 | case 37: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3945 | #line 1956 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3946 | { yyval.FPred = FCmpInst::FCMP_ONE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3947 | break; |
| 3948 | |
| 3949 | case 38: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3950 | #line 1957 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3951 | { yyval.FPred = FCmpInst::FCMP_OLT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3952 | break; |
| 3953 | |
| 3954 | case 39: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3955 | #line 1957 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3956 | { yyval.FPred = FCmpInst::FCMP_OGT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3957 | break; |
| 3958 | |
| 3959 | case 40: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3960 | #line 1958 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3961 | { yyval.FPred = FCmpInst::FCMP_OLE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3962 | break; |
| 3963 | |
| 3964 | case 41: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3965 | #line 1958 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3966 | { yyval.FPred = FCmpInst::FCMP_OGE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3967 | break; |
| 3968 | |
| 3969 | case 42: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3970 | #line 1959 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3971 | { yyval.FPred = FCmpInst::FCMP_ORD; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3972 | break; |
| 3973 | |
| 3974 | case 43: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3975 | #line 1959 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3976 | { yyval.FPred = FCmpInst::FCMP_UNO; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3977 | break; |
| 3978 | |
| 3979 | case 44: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3980 | #line 1960 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3981 | { yyval.FPred = FCmpInst::FCMP_UEQ; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3982 | break; |
| 3983 | |
| 3984 | case 45: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3985 | #line 1960 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3986 | { yyval.FPred = FCmpInst::FCMP_UNE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3987 | break; |
| 3988 | |
| 3989 | case 46: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3990 | #line 1961 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3991 | { yyval.FPred = FCmpInst::FCMP_ULT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3992 | break; |
| 3993 | |
| 3994 | case 47: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 3995 | #line 1961 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3996 | { yyval.FPred = FCmpInst::FCMP_UGT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3997 | break; |
| 3998 | |
| 3999 | case 48: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4000 | #line 1962 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4001 | { yyval.FPred = FCmpInst::FCMP_ULE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4002 | break; |
| 4003 | |
| 4004 | case 49: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4005 | #line 1962 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4006 | { yyval.FPred = FCmpInst::FCMP_UGE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4007 | break; |
| 4008 | |
| 4009 | case 50: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4010 | #line 1963 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4011 | { yyval.FPred = FCmpInst::FCMP_TRUE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4012 | break; |
| 4013 | |
| 4014 | case 51: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4015 | #line 1964 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4016 | { yyval.FPred = FCmpInst::FCMP_FALSE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4017 | break; |
| 4018 | |
| 4019 | case 81: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4020 | #line 1995 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4021 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4022 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4023 | ;} |
| 4024 | break; |
| 4025 | |
| 4026 | case 82: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4027 | #line 1998 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4028 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4029 | yyval.StrVal = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4030 | ;} |
| 4031 | break; |
| 4032 | |
| 4033 | case 83: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4034 | #line 2003 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4035 | { yyval.Linkage = GlobalValue::InternalLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4036 | break; |
| 4037 | |
| 4038 | case 84: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4039 | #line 2004 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4040 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4041 | break; |
| 4042 | |
| 4043 | case 85: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4044 | #line 2005 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4045 | { yyval.Linkage = GlobalValue::WeakLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4046 | break; |
| 4047 | |
| 4048 | case 86: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4049 | #line 2006 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4050 | { yyval.Linkage = GlobalValue::AppendingLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4051 | break; |
| 4052 | |
| 4053 | case 87: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4054 | #line 2007 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4055 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4056 | break; |
| 4057 | |
| 4058 | case 88: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4059 | #line 2008 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4060 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4061 | break; |
| 4062 | |
| 4063 | case 89: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4064 | #line 2009 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4065 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4066 | break; |
| 4067 | |
| 4068 | case 90: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4069 | #line 2010 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4070 | { yyval.Linkage = GlobalValue::ExternalLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4071 | break; |
| 4072 | |
| 4073 | case 91: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4074 | #line 2014 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4075 | { yyval.UIntVal = lastCallingConv = OldCallingConv::C; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4076 | break; |
| 4077 | |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4078 | case 92: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4079 | #line 2015 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4080 | { yyval.UIntVal = lastCallingConv = OldCallingConv::C; ;} |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4081 | break; |
| 4082 | |
| 4083 | case 93: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4084 | #line 2016 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4085 | { yyval.UIntVal = lastCallingConv = OldCallingConv::CSRet; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4086 | break; |
| 4087 | |
| 4088 | case 94: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4089 | #line 2017 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4090 | { yyval.UIntVal = lastCallingConv = OldCallingConv::Fast; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4091 | break; |
| 4092 | |
| 4093 | case 95: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4094 | #line 2018 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4095 | { yyval.UIntVal = lastCallingConv = OldCallingConv::Cold; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4096 | break; |
| 4097 | |
| 4098 | case 96: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4099 | #line 2019 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4100 | { yyval.UIntVal = lastCallingConv = OldCallingConv::X86_StdCall; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4101 | break; |
| 4102 | |
| 4103 | case 97: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4104 | #line 2020 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4105 | { yyval.UIntVal = lastCallingConv = OldCallingConv::X86_FastCall; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4106 | break; |
| 4107 | |
| 4108 | case 98: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4109 | #line 2021 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4110 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4111 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4112 | error("Calling conv too large"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4113 | yyval.UIntVal = lastCallingConv = yyvsp[0].UInt64Val; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4114 | ;} |
| 4115 | break; |
| 4116 | |
| 4117 | case 99: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4118 | #line 2031 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4119 | { yyval.UIntVal = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4120 | break; |
| 4121 | |
| 4122 | case 100: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4123 | #line 2032 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4124 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4125 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 4126 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4127 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4128 | ;} |
| 4129 | break; |
| 4130 | |
| 4131 | case 101: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4132 | #line 2040 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4133 | { yyval.UIntVal = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4134 | break; |
| 4135 | |
| 4136 | case 102: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4137 | #line 2041 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4138 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4139 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 4140 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4141 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4142 | ;} |
| 4143 | break; |
| 4144 | |
| 4145 | case 103: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4146 | #line 2049 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4147 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4148 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 4149 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4150 | error("Invalid character in section name"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4151 | yyval.StrVal = yyvsp[0].StrVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4152 | ;} |
| 4153 | break; |
| 4154 | |
| 4155 | case 104: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4156 | #line 2058 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4157 | { yyval.StrVal = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4158 | break; |
| 4159 | |
| 4160 | case 105: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4161 | #line 2059 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4162 | { yyval.StrVal = yyvsp[0].StrVal; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4163 | break; |
| 4164 | |
| 4165 | case 106: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4166 | #line 2066 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4167 | {;} |
| 4168 | break; |
| 4169 | |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4170 | case 107: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4171 | #line 2067 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4172 | {;} |
| 4173 | break; |
| 4174 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4175 | case 108: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4176 | #line 2071 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4177 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4178 | CurGV->setSection(yyvsp[0].StrVal); |
| 4179 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4180 | ;} |
| 4181 | break; |
| 4182 | |
| 4183 | case 109: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4184 | #line 2075 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4185 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4186 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4187 | error("Alignment must be a power of two"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4188 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4189 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4190 | ;} |
| 4191 | break; |
| 4192 | |
| 4193 | case 111: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4194 | #line 2092 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4195 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4196 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 4197 | yyval.TypeVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4198 | ;} |
| 4199 | break; |
| 4200 | |
| 4201 | case 113: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4202 | #line 2100 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4203 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4204 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 4205 | yyval.TypeVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4206 | ;} |
| 4207 | break; |
| 4208 | |
| 4209 | case 114: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4210 | #line 2107 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4211 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4212 | if (!UpRefs.empty()) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4213 | error("Invalid upreference in type: " + (*yyvsp[0].TypeVal.PAT)->getDescription()); |
| 4214 | yyval.TypeVal = yyvsp[0].TypeVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4215 | ;} |
| 4216 | break; |
| 4217 | |
| 4218 | case 127: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4219 | #line 2121 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4220 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4221 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 4222 | yyval.TypeVal.S.copy(yyvsp[0].PrimType.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4223 | ;} |
| 4224 | break; |
| 4225 | |
| 4226 | case 128: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4227 | #line 2125 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4228 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4229 | yyval.TypeVal.PAT = new PATypeHolder(OpaqueType::get()); |
| 4230 | yyval.TypeVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4231 | ;} |
| 4232 | break; |
| 4233 | |
| 4234 | case 129: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4235 | #line 2129 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4236 | { // Named types are also simple types... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4237 | yyval.TypeVal.S.copy(getTypeSign(yyvsp[0].ValIDVal)); |
| 4238 | const Type* tmp = getType(yyvsp[0].ValIDVal); |
| 4239 | yyval.TypeVal.PAT = new PATypeHolder(tmp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4240 | ;} |
| 4241 | break; |
| 4242 | |
| 4243 | case 130: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4244 | #line 2134 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4245 | { // Type UpReference |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4246 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4247 | error("Value out of range"); |
| 4248 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4249 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 4250 | yyval.TypeVal.PAT = new PATypeHolder(OT); |
| 4251 | yyval.TypeVal.S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4252 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4253 | ;} |
| 4254 | break; |
| 4255 | |
| 4256 | case 131: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4257 | #line 2143 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4258 | { // Function derived type? |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4259 | yyval.TypeVal.S.makeComposite(yyvsp[-3].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4260 | std::vector<const Type*> Params; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4261 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(), |
| 4262 | E = yyvsp[-1].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4263 | Params.push_back(I->PAT->get()); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4264 | yyval.TypeVal.S.add(I->S); |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4265 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4266 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 4267 | if (isVarArg) Params.pop_back(); |
| 4268 | |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 4269 | ParamAttrsList *PAL = 0; |
| 4270 | if (lastCallingConv == OldCallingConv::CSRet) { |
| 4271 | ParamAttrsVector Attrs; |
| 4272 | ParamAttrsWithIndex PAWI; |
| 4273 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 4274 | Attrs.push_back(PAWI); |
| 4275 | PAL = ParamAttrsList::get(Attrs); |
| 4276 | } |
| 4277 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4278 | const FunctionType *FTy = |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4279 | FunctionType::get(yyvsp[-3].TypeVal.PAT->get(), Params, isVarArg, PAL); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4280 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4281 | yyval.TypeVal.PAT = new PATypeHolder( HandleUpRefs(FTy, yyval.TypeVal.S) ); |
| 4282 | delete yyvsp[-3].TypeVal.PAT; // Delete the return type handle |
| 4283 | delete yyvsp[-1].TypeList; // Delete the argument list |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4284 | ;} |
| 4285 | break; |
| 4286 | |
| 4287 | case 132: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4288 | #line 2170 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4289 | { // Sized array type? |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4290 | yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 4291 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(ArrayType::get(yyvsp[-1].TypeVal.PAT->get(), |
| 4292 | (unsigned)yyvsp[-3].UInt64Val), yyval.TypeVal.S)); |
| 4293 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4294 | ;} |
| 4295 | break; |
| 4296 | |
| 4297 | case 133: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4298 | #line 2176 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4299 | { // Vector type? |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4300 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal.PAT->get(); |
| 4301 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4302 | error("Unsigned result not equal to signed result"); |
| 4303 | if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint())) |
| 4304 | error("Elements of a VectorType must be integer or floating point"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4305 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4306 | error("VectorType length should be a power of 2"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4307 | yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 4308 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, |
| 4309 | (unsigned)yyvsp[-3].UInt64Val), yyval.TypeVal.S)); |
| 4310 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4311 | ;} |
| 4312 | break; |
| 4313 | |
| 4314 | case 134: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4315 | #line 2189 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4316 | { // Structure type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4317 | std::vector<const Type*> Elements; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4318 | yyval.TypeVal.S.makeComposite(); |
| 4319 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(), |
| 4320 | E = yyvsp[-1].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4321 | Elements.push_back(I->PAT->get()); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4322 | yyval.TypeVal.S.add(I->S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4323 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4324 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), yyval.TypeVal.S)); |
| 4325 | delete yyvsp[-1].TypeList; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4326 | ;} |
| 4327 | break; |
| 4328 | |
| 4329 | case 135: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4330 | #line 2200 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4331 | { // Empty structure type? |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4332 | yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
| 4333 | yyval.TypeVal.S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4334 | ;} |
| 4335 | break; |
| 4336 | |
| 4337 | case 136: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4338 | #line 2204 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4339 | { // Packed Structure type? |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4340 | yyval.TypeVal.S.makeComposite(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4341 | std::vector<const Type*> Elements; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4342 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-2].TypeList->begin(), |
| 4343 | E = yyvsp[-2].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4344 | Elements.push_back(I->PAT->get()); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4345 | yyval.TypeVal.S.add(I->S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4346 | delete I->PAT; |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4347 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4348 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true), |
| 4349 | yyval.TypeVal.S)); |
| 4350 | delete yyvsp[-2].TypeList; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4351 | ;} |
| 4352 | break; |
| 4353 | |
| 4354 | case 137: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4355 | #line 2217 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4356 | { // Empty packed structure type? |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4357 | yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true)); |
| 4358 | yyval.TypeVal.S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4359 | ;} |
| 4360 | break; |
| 4361 | |
| 4362 | case 138: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4363 | #line 2221 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4364 | { // Pointer type? |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4365 | if (yyvsp[-1].TypeVal.PAT->get() == Type::LabelTy) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4366 | error("Cannot form a pointer to a basic block"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4367 | yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 4368 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(PointerType::get(yyvsp[-1].TypeVal.PAT->get()), |
| 4369 | yyval.TypeVal.S)); |
| 4370 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4371 | ;} |
| 4372 | break; |
| 4373 | |
| 4374 | case 139: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4375 | #line 2235 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4376 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4377 | yyval.TypeList = new std::list<PATypeInfo>(); |
| 4378 | yyval.TypeList->push_back(yyvsp[0].TypeVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4379 | ;} |
| 4380 | break; |
| 4381 | |
| 4382 | case 140: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4383 | #line 2239 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4384 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4385 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4386 | ;} |
| 4387 | break; |
| 4388 | |
| 4389 | case 142: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4390 | #line 2247 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4391 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4392 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4393 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4394 | VoidTI.S.makeSignless(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4395 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(VoidTI); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4396 | ;} |
| 4397 | break; |
| 4398 | |
| 4399 | case 143: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4400 | #line 2253 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4401 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4402 | yyval.TypeList = new std::list<PATypeInfo>(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4403 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4404 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4405 | VoidTI.S.makeSignless(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4406 | yyval.TypeList->push_back(VoidTI); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4407 | ;} |
| 4408 | break; |
| 4409 | |
| 4410 | case 144: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4411 | #line 2260 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4412 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4413 | yyval.TypeList = new std::list<PATypeInfo>(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4414 | ;} |
| 4415 | break; |
| 4416 | |
| 4417 | case 145: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4418 | #line 2272 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4419 | { // Nonempty unsized arr |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4420 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4421 | if (ATy == 0) |
| 4422 | error("Cannot make array constant with type: '" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4423 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4424 | const Type *ETy = ATy->getElementType(); |
| 4425 | int NumElements = ATy->getNumElements(); |
| 4426 | |
| 4427 | // Verify that we have the correct size... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4428 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4429 | error("Type mismatch: constant sized array initialized with " + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4430 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4431 | itostr(NumElements) + ""); |
| 4432 | |
| 4433 | // Verify all elements are correct type! |
| 4434 | std::vector<Constant*> Elems; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4435 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4436 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4437 | const Type* ValTy = C->getType(); |
| 4438 | if (ETy != ValTy) |
| 4439 | error("Element #" + utostr(i) + " is not of type '" + |
| 4440 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4441 | ValTy->getDescription() + "'"); |
| 4442 | Elems.push_back(C); |
| 4443 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4444 | yyval.ConstVal.C = ConstantArray::get(ATy, Elems); |
| 4445 | yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 4446 | delete yyvsp[-3].TypeVal.PAT; |
| 4447 | delete yyvsp[-1].ConstVector; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4448 | ;} |
| 4449 | break; |
| 4450 | |
| 4451 | case 146: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4452 | #line 2302 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4453 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4454 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4455 | if (ATy == 0) |
| 4456 | error("Cannot make array constant with type: '" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4457 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4458 | int NumElements = ATy->getNumElements(); |
| 4459 | if (NumElements != -1 && NumElements != 0) |
| 4460 | error("Type mismatch: constant sized array initialized with 0" |
| 4461 | " arguments, but has size of " + itostr(NumElements) +""); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4462 | yyval.ConstVal.C = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 4463 | yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S); |
| 4464 | delete yyvsp[-2].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4465 | ;} |
| 4466 | break; |
| 4467 | |
| 4468 | case 147: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4469 | #line 2315 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4470 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4471 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4472 | if (ATy == 0) |
| 4473 | error("Cannot make array constant with type: '" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4474 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4475 | int NumElements = ATy->getNumElements(); |
| 4476 | const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType()); |
| 4477 | if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8) |
| 4478 | error("String arrays require type i8, not '" + ETy->getDescription() + |
| 4479 | "'"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4480 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4481 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4482 | error("Can't build string constant of size " + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4483 | itostr((int)(EndStr-yyvsp[0].StrVal)) + " when array has size " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4484 | itostr(NumElements) + ""); |
| 4485 | std::vector<Constant*> Vals; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4486 | for (char *C = (char *)yyvsp[0].StrVal; C != (char *)EndStr; ++C) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4487 | Vals.push_back(ConstantInt::get(ETy, *C)); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4488 | free(yyvsp[0].StrVal); |
| 4489 | yyval.ConstVal.C = ConstantArray::get(ATy, Vals); |
| 4490 | yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S); |
| 4491 | delete yyvsp[-2].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4492 | ;} |
| 4493 | break; |
| 4494 | |
| 4495 | case 148: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4496 | #line 2338 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4497 | { // Nonempty unsized arr |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4498 | const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4499 | if (PTy == 0) |
| 4500 | error("Cannot make packed constant with type: '" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4501 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4502 | const Type *ETy = PTy->getElementType(); |
| 4503 | int NumElements = PTy->getNumElements(); |
| 4504 | // Verify that we have the correct size... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4505 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4506 | error("Type mismatch: constant sized packed initialized with " + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4507 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4508 | itostr(NumElements) + ""); |
| 4509 | // Verify all elements are correct type! |
| 4510 | std::vector<Constant*> Elems; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4511 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4512 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4513 | const Type* ValTy = C->getType(); |
| 4514 | if (ETy != ValTy) |
| 4515 | error("Element #" + utostr(i) + " is not of type '" + |
| 4516 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4517 | ValTy->getDescription() + "'"); |
| 4518 | Elems.push_back(C); |
| 4519 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4520 | yyval.ConstVal.C = ConstantVector::get(PTy, Elems); |
| 4521 | yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 4522 | delete yyvsp[-3].TypeVal.PAT; |
| 4523 | delete yyvsp[-1].ConstVector; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4524 | ;} |
| 4525 | break; |
| 4526 | |
| 4527 | case 149: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4528 | #line 2366 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4529 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4530 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4531 | if (STy == 0) |
| 4532 | error("Cannot make struct constant with type: '" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4533 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
| 4534 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4535 | error("Illegal number of initializers for structure type"); |
| 4536 | |
| 4537 | // Check to ensure that constants are compatible with the type initializer! |
| 4538 | std::vector<Constant*> Fields; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4539 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) { |
| 4540 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4541 | if (C->getType() != STy->getElementType(i)) |
| 4542 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4543 | "' for element #" + utostr(i) + " of structure initializer"); |
| 4544 | Fields.push_back(C); |
| 4545 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4546 | yyval.ConstVal.C = ConstantStruct::get(STy, Fields); |
| 4547 | yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 4548 | delete yyvsp[-3].TypeVal.PAT; |
| 4549 | delete yyvsp[-1].ConstVector; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4550 | ;} |
| 4551 | break; |
| 4552 | |
| 4553 | case 150: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4554 | #line 2388 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4555 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4556 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4557 | if (STy == 0) |
| 4558 | error("Cannot make struct constant with type: '" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4559 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4560 | if (STy->getNumContainedTypes() != 0) |
| 4561 | error("Illegal number of initializers for structure type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4562 | yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4563 | yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S); |
| 4564 | delete yyvsp[-2].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4565 | ;} |
| 4566 | break; |
| 4567 | |
| 4568 | case 151: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4569 | #line 2399 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4570 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4571 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4572 | if (STy == 0) |
| 4573 | error("Cannot make packed struct constant with type: '" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4574 | yyvsp[-5].TypeVal.PAT->get()->getDescription() + "'"); |
| 4575 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4576 | error("Illegal number of initializers for packed structure type"); |
| 4577 | |
| 4578 | // Check to ensure that constants are compatible with the type initializer! |
| 4579 | std::vector<Constant*> Fields; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4580 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) { |
| 4581 | Constant *C = (*yyvsp[-2].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4582 | if (C->getType() != STy->getElementType(i)) |
| 4583 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4584 | "' for element #" + utostr(i) + " of packed struct initializer"); |
| 4585 | Fields.push_back(C); |
| 4586 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4587 | yyval.ConstVal.C = ConstantStruct::get(STy, Fields); |
| 4588 | yyval.ConstVal.S.copy(yyvsp[-5].TypeVal.S); |
| 4589 | delete yyvsp[-5].TypeVal.PAT; |
| 4590 | delete yyvsp[-2].ConstVector; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4591 | ;} |
| 4592 | break; |
| 4593 | |
| 4594 | case 152: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4595 | #line 2421 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4596 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4597 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4598 | if (STy == 0) |
| 4599 | error("Cannot make packed struct constant with type: '" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4600 | yyvsp[-4].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4601 | if (STy->getNumContainedTypes() != 0) |
| 4602 | error("Illegal number of initializers for packed structure type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4603 | yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4604 | yyval.ConstVal.S.copy(yyvsp[-4].TypeVal.S); |
| 4605 | delete yyvsp[-4].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4606 | ;} |
| 4607 | break; |
| 4608 | |
| 4609 | case 153: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4610 | #line 2432 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4611 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4612 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4613 | if (PTy == 0) |
| 4614 | error("Cannot make null pointer constant with type: '" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4615 | yyvsp[-1].TypeVal.PAT->get()->getDescription() + "'"); |
| 4616 | yyval.ConstVal.C = ConstantPointerNull::get(PTy); |
| 4617 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4618 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4619 | ;} |
| 4620 | break; |
| 4621 | |
| 4622 | case 154: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4623 | #line 2441 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4624 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4625 | yyval.ConstVal.C = UndefValue::get(yyvsp[-1].TypeVal.PAT->get()); |
| 4626 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4627 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4628 | ;} |
| 4629 | break; |
| 4630 | |
| 4631 | case 155: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4632 | #line 2446 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4633 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4634 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4635 | if (Ty == 0) |
| 4636 | error("Global const reference must be a pointer type, not" + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4637 | yyvsp[-1].TypeVal.PAT->get()->getDescription()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4638 | |
| 4639 | // ConstExprs can exist in the body of a function, thus creating |
| 4640 | // GlobalValues whenever they refer to a variable. Because we are in |
| 4641 | // the context of a function, getExistingValue will search the functions |
| 4642 | // symbol table instead of the module symbol table for the global symbol, |
| 4643 | // which throws things all off. To get around this, we just tell |
| 4644 | // getExistingValue that we are at global scope here. |
| 4645 | // |
| 4646 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 4647 | CurFun.CurrentFunction = 0; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4648 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4649 | Value *V = getExistingValue(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4650 | CurFun.CurrentFunction = SavedCurFn; |
| 4651 | |
| 4652 | // If this is an initializer for a constant pointer, which is referencing a |
| 4653 | // (currently) undefined variable, create a stub now that shall be replaced |
| 4654 | // in the future with the right type of variable. |
| 4655 | // |
| 4656 | if (V == 0) { |
| 4657 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers"); |
| 4658 | const PointerType *PT = cast<PointerType>(Ty); |
| 4659 | |
| 4660 | // First check to see if the forward references value is already created! |
| 4661 | PerModuleInfo::GlobalRefsType::iterator I = |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4662 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4663 | |
| 4664 | if (I != CurModule.GlobalRefs.end()) { |
| 4665 | V = I->second; // Placeholder already exists, use it... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4666 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4667 | } else { |
| 4668 | std::string Name; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4669 | if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4670 | |
| 4671 | // Create the forward referenced global. |
| 4672 | GlobalValue *GV; |
| 4673 | if (const FunctionType *FTy = |
| 4674 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 4675 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 4676 | CurModule.CurrentModule); |
| 4677 | } else { |
| 4678 | GV = new GlobalVariable(PT->getElementType(), false, |
| 4679 | GlobalValue::ExternalLinkage, 0, |
| 4680 | Name, CurModule.CurrentModule); |
| 4681 | } |
| 4682 | |
| 4683 | // Keep track of the fact that we have a forward ref to recycle it |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4684 | 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] | 4685 | V = GV; |
| 4686 | } |
| 4687 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4688 | yyval.ConstVal.C = cast<GlobalValue>(V); |
| 4689 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4690 | delete yyvsp[-1].TypeVal.PAT; // Free the type handle |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4691 | ;} |
| 4692 | break; |
| 4693 | |
| 4694 | case 156: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4695 | #line 2505 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4696 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4697 | if (yyvsp[-1].TypeVal.PAT->get() != yyvsp[0].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4698 | error("Mismatched types for constant expression"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4699 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 4700 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4701 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4702 | ;} |
| 4703 | break; |
| 4704 | |
| 4705 | case 157: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4706 | #line 2512 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4707 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4708 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4709 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 4710 | error("Cannot create a null initialized value of this type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4711 | yyval.ConstVal.C = Constant::getNullValue(Ty); |
| 4712 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4713 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4714 | ;} |
| 4715 | break; |
| 4716 | |
| 4717 | case 158: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4718 | #line 2520 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4719 | { // integral constants |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4720 | const Type *Ty = yyvsp[-1].PrimType.T; |
| 4721 | if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].SInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4722 | error("Constant value doesn't fit in type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4723 | yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].SInt64Val); |
| 4724 | yyval.ConstVal.S.makeSigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4725 | ;} |
| 4726 | break; |
| 4727 | |
| 4728 | case 159: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4729 | #line 2527 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4730 | { // integral constants |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4731 | const Type *Ty = yyvsp[-1].PrimType.T; |
| 4732 | if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4733 | error("Constant value doesn't fit in type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4734 | yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].UInt64Val); |
| 4735 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4736 | ;} |
| 4737 | break; |
| 4738 | |
| 4739 | case 160: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4740 | #line 2534 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4741 | { // Boolean constants |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4742 | yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, true); |
| 4743 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4744 | ;} |
| 4745 | break; |
| 4746 | |
| 4747 | case 161: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4748 | #line 2538 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4749 | { // Boolean constants |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4750 | yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, false); |
| 4751 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4752 | ;} |
| 4753 | break; |
| 4754 | |
| 4755 | case 162: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4756 | #line 2542 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4757 | { // Float & Double constants |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4758 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType.T, yyvsp[0].FPVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4759 | error("Floating point constant invalid for type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4760 | yyval.ConstVal.C = ConstantFP::get(yyvsp[-1].PrimType.T, yyvsp[0].FPVal); |
| 4761 | yyval.ConstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4762 | ;} |
| 4763 | break; |
| 4764 | |
| 4765 | case 163: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4766 | #line 2551 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4767 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4768 | const Type* SrcTy = yyvsp[-3].ConstVal.C->getType(); |
| 4769 | const Type* DstTy = yyvsp[-1].TypeVal.PAT->get(); |
| 4770 | Signedness SrcSign(yyvsp[-3].ConstVal.S); |
| 4771 | Signedness DstSign(yyvsp[-1].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4772 | if (!SrcTy->isFirstClassType()) |
| 4773 | error("cast constant expression from a non-primitive type: '" + |
| 4774 | SrcTy->getDescription() + "'"); |
| 4775 | if (!DstTy->isFirstClassType()) |
| 4776 | error("cast constant expression to a non-primitive type: '" + |
| 4777 | DstTy->getDescription() + "'"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4778 | yyval.ConstVal.C = cast<Constant>(getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal.C, SrcSign, DstTy, DstSign)); |
| 4779 | yyval.ConstVal.S.copy(DstSign); |
| 4780 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4781 | ;} |
| 4782 | break; |
| 4783 | |
| 4784 | case 164: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4785 | #line 2566 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4786 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4787 | const Type *Ty = yyvsp[-2].ConstVal.C->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4788 | if (!isa<PointerType>(Ty)) |
| 4789 | error("GetElementPtr requires a pointer operand"); |
| 4790 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4791 | std::vector<Constant*> CIndices; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4792 | upgradeGEPCEIndices(yyvsp[-2].ConstVal.C->getType(), yyvsp[-1].ValueList, CIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4793 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4794 | delete yyvsp[-1].ValueList; |
| 4795 | yyval.ConstVal.C = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal.C, &CIndices[0], CIndices.size()); |
| 4796 | yyval.ConstVal.S.copy(getElementSign(yyvsp[-2].ConstVal, CIndices)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4797 | ;} |
| 4798 | break; |
| 4799 | |
| 4800 | case 165: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4801 | #line 2578 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4802 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4803 | if (!yyvsp[-5].ConstVal.C->getType()->isInteger() || |
| 4804 | cast<IntegerType>(yyvsp[-5].ConstVal.C->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4805 | error("Select condition must be bool type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4806 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4807 | error("Select operand types must match"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4808 | yyval.ConstVal.C = ConstantExpr::getSelect(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4809 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4810 | ;} |
| 4811 | break; |
| 4812 | |
| 4813 | case 166: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4814 | #line 2587 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4815 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4816 | const Type *Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4817 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4818 | error("Binary operator types must match"); |
| 4819 | // First, make sure we're dealing with the right opcode by upgrading from |
| 4820 | // obsolete versions. |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4821 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4822 | |
| 4823 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 4824 | // To retain backward compatibility with these early compilers, we emit a |
| 4825 | // cast to the appropriate integer type automatically if we are in the |
| 4826 | // broken case. See PR424 for more information. |
| 4827 | if (!isa<PointerType>(Ty)) { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4828 | 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] | 4829 | } else { |
| 4830 | const Type *IntPtrTy = 0; |
| 4831 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 4832 | case Module::Pointer32: IntPtrTy = Type::Int32Ty; break; |
| 4833 | case Module::Pointer64: IntPtrTy = Type::Int64Ty; break; |
| 4834 | default: error("invalid pointer binary constant expr"); |
| 4835 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4836 | yyval.ConstVal.C = ConstantExpr::get(Opcode, |
| 4837 | ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-3].ConstVal.C, IntPtrTy), |
| 4838 | ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-1].ConstVal.C, IntPtrTy)); |
| 4839 | yyval.ConstVal.C = ConstantExpr::getCast(Instruction::IntToPtr, yyval.ConstVal.C, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4840 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4841 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4842 | ;} |
| 4843 | break; |
| 4844 | |
| 4845 | case 167: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4846 | #line 2615 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4847 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4848 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4849 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4850 | error("Logical operator types must match"); |
| 4851 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4852 | if (!isa<VectorType>(Ty) || |
| 4853 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4854 | error("Logical operator requires integer operands"); |
| 4855 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4856 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); |
| 4857 | yyval.ConstVal.C = ConstantExpr::get(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4858 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4859 | ;} |
| 4860 | break; |
| 4861 | |
| 4862 | case 168: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4863 | #line 2628 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4864 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4865 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4866 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4867 | error("setcc operand types must match"); |
| 4868 | unsigned short pred; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4869 | Instruction::OtherOps Opcode = getCompareOp(yyvsp[-5].BinaryOpVal, pred, Ty, yyvsp[-3].ConstVal.S); |
| 4870 | yyval.ConstVal.C = ConstantExpr::getCompare(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4871 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4872 | ;} |
| 4873 | break; |
| 4874 | |
| 4875 | case 169: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4876 | #line 2637 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4877 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4878 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4879 | error("icmp operand types must match"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4880 | yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].IPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4881 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4882 | ;} |
| 4883 | break; |
| 4884 | |
| 4885 | case 170: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4886 | #line 2643 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4887 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4888 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4889 | error("fcmp operand types must match"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4890 | yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].FPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4891 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4892 | ;} |
| 4893 | break; |
| 4894 | |
| 4895 | case 171: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4896 | #line 2649 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4897 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4898 | if (!yyvsp[-1].ConstVal.C->getType()->isInteger() || |
| 4899 | cast<IntegerType>(yyvsp[-1].ConstVal.C->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4900 | error("Shift count for shift constant must be unsigned byte"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4901 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4902 | if (!yyvsp[-3].ConstVal.C->getType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4903 | error("Shift constant expression requires integer operand"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4904 | Constant *ShiftAmt = ConstantExpr::getZExt(yyvsp[-1].ConstVal.C, Ty); |
| 4905 | yyval.ConstVal.C = ConstantExpr::get(getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S), yyvsp[-3].ConstVal.C, ShiftAmt); |
| 4906 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4907 | ;} |
| 4908 | break; |
| 4909 | |
| 4910 | case 172: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4911 | #line 2660 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4912 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4913 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4914 | error("Invalid extractelement operands"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4915 | yyval.ConstVal.C = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4916 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4917 | ;} |
| 4918 | break; |
| 4919 | |
| 4920 | case 173: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4921 | #line 2666 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4922 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4923 | 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] | 4924 | error("Invalid insertelement operands"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4925 | yyval.ConstVal.C = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4926 | yyval.ConstVal.S.copy(yyvsp[-5].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4927 | ;} |
| 4928 | break; |
| 4929 | |
| 4930 | case 174: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4931 | #line 2672 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4932 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4933 | 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] | 4934 | error("Invalid shufflevector operands"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4935 | yyval.ConstVal.C = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4936 | yyval.ConstVal.S.copy(yyvsp[-5].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4937 | ;} |
| 4938 | break; |
| 4939 | |
| 4940 | case 175: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4941 | #line 2683 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4942 | { (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4943 | break; |
| 4944 | |
| 4945 | case 176: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4946 | #line 2684 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4947 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4948 | yyval.ConstVector = new std::vector<ConstInfo>(); |
| 4949 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4950 | ;} |
| 4951 | break; |
| 4952 | |
| 4953 | case 177: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4954 | #line 2693 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4955 | { yyval.BoolVal = false; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4956 | break; |
| 4957 | |
| 4958 | case 178: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4959 | #line 2694 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4960 | { yyval.BoolVal = true; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4961 | break; |
| 4962 | |
| 4963 | case 179: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4964 | #line 2706 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4965 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4966 | yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4967 | CurModule.ModuleDone(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4968 | ;} |
| 4969 | break; |
| 4970 | |
| 4971 | case 180: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4972 | #line 2715 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4973 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; CurFun.FunctionDone(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4974 | break; |
| 4975 | |
| 4976 | case 181: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4977 | #line 2716 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4978 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4979 | break; |
| 4980 | |
| 4981 | case 182: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4982 | #line 2717 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4983 | { yyval.ModuleVal = yyvsp[-3].ModuleVal; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4984 | break; |
| 4985 | |
| 4986 | case 183: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4987 | #line 2718 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4988 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4989 | break; |
| 4990 | |
| 4991 | case 184: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4992 | #line 2719 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4993 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 4994 | yyval.ModuleVal = CurModule.CurrentModule; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4995 | // Emit an error if there are any unresolved types left. |
| 4996 | if (!CurModule.LateResolveTypes.empty()) { |
| 4997 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 4998 | if (DID.Type == ValID::NameVal) { |
| 4999 | error("Reference to an undefined type: '"+DID.getName() + "'"); |
| 5000 | } else { |
| 5001 | error("Reference to an undefined type: #" + itostr(DID.Num)); |
| 5002 | } |
| 5003 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5004 | ;} |
| 5005 | break; |
| 5006 | |
| 5007 | case 185: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5008 | #line 2735 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5009 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5010 | // Eagerly resolve types. This is not an optimization, this is a |
| 5011 | // requirement that is due to the fact that we could have this: |
| 5012 | // |
| 5013 | // %list = type { %list * } |
| 5014 | // %list = type { %list * } ; repeated type decl |
| 5015 | // |
| 5016 | // If types are not resolved eagerly, then the two types will not be |
| 5017 | // determined to be the same type! |
| 5018 | // |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5019 | 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] | 5020 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5021 | if (!setTypeName(yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5022 | // If this is a numbered type that is not a redefinition, add it to the |
| 5023 | // slot table. |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5024 | CurModule.Types.push_back(yyvsp[0].TypeVal.PAT->get()); |
| 5025 | CurModule.TypeSigns.push_back(yyvsp[0].TypeVal.S); |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 5026 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5027 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5028 | ;} |
| 5029 | break; |
| 5030 | |
| 5031 | case 186: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5032 | #line 2755 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5033 | { // Function prototypes can be in const pool |
| 5034 | ;} |
| 5035 | break; |
| 5036 | |
| 5037 | case 187: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5038 | #line 2757 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5039 | { // Asm blocks can be in the const pool |
| 5040 | ;} |
| 5041 | break; |
| 5042 | |
| 5043 | case 188: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5044 | #line 2759 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5045 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5046 | if (yyvsp[0].ConstVal.C == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5047 | error("Global value initializer is not a constant"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5048 | 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] | 5049 | ;} |
| 5050 | break; |
| 5051 | |
| 5052 | case 189: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5053 | #line 2763 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5054 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5055 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5056 | ;} |
| 5057 | break; |
| 5058 | |
| 5059 | case 190: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5060 | #line 2766 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5061 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5062 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
| 5063 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, Ty, 0, |
| 5064 | yyvsp[0].TypeVal.S); |
| 5065 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5066 | ;} |
| 5067 | break; |
| 5068 | |
| 5069 | case 191: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5070 | #line 2771 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5071 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5072 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5073 | ;} |
| 5074 | break; |
| 5075 | |
| 5076 | case 192: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5077 | #line 2774 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5078 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5079 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
| 5080 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, Ty, 0, |
| 5081 | yyvsp[0].TypeVal.S); |
| 5082 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5083 | ;} |
| 5084 | break; |
| 5085 | |
| 5086 | case 193: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5087 | #line 2779 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5088 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5089 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5090 | ;} |
| 5091 | break; |
| 5092 | |
| 5093 | case 194: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5094 | #line 2782 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5095 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5096 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5097 | CurGV = |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5098 | ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, Ty, 0, |
| 5099 | yyvsp[0].TypeVal.S); |
| 5100 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5101 | ;} |
| 5102 | break; |
| 5103 | |
| 5104 | case 195: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5105 | #line 2788 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5106 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5107 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5108 | ;} |
| 5109 | break; |
| 5110 | |
| 5111 | case 196: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5112 | #line 2791 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5113 | { |
| 5114 | ;} |
| 5115 | break; |
| 5116 | |
| 5117 | case 197: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5118 | #line 2793 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5119 | { |
| 5120 | ;} |
| 5121 | break; |
| 5122 | |
| 5123 | case 198: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5124 | #line 2795 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5125 | { |
| 5126 | ;} |
| 5127 | break; |
| 5128 | |
| 5129 | case 199: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5130 | #line 2800 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5131 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5132 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5133 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 5134 | std::string NewAsm(yyvsp[0].StrVal, EndStr); |
| 5135 | free(yyvsp[0].StrVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5136 | |
| 5137 | if (AsmSoFar.empty()) |
| 5138 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 5139 | else |
| 5140 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5141 | ;} |
| 5142 | break; |
| 5143 | |
| 5144 | case 200: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5145 | #line 2814 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5146 | { yyval.Endianness = Module::BigEndian; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5147 | break; |
| 5148 | |
| 5149 | case 201: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5150 | #line 2815 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5151 | { yyval.Endianness = Module::LittleEndian; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5152 | break; |
| 5153 | |
| 5154 | case 202: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5155 | #line 2819 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5156 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5157 | CurModule.setEndianness(yyvsp[0].Endianness); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5158 | ;} |
| 5159 | break; |
| 5160 | |
| 5161 | case 203: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5162 | #line 2822 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5163 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5164 | if (yyvsp[0].UInt64Val == 32) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5165 | CurModule.setPointerSize(Module::Pointer32); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5166 | else if (yyvsp[0].UInt64Val == 64) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5167 | CurModule.setPointerSize(Module::Pointer64); |
| 5168 | else |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5169 | error("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5170 | ;} |
| 5171 | break; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5172 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5173 | case 204: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5174 | #line 2830 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5175 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5176 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 5177 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5178 | ;} |
| 5179 | break; |
| 5180 | |
| 5181 | case 205: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5182 | #line 2834 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5183 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5184 | CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); |
| 5185 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5186 | ;} |
| 5187 | break; |
| 5188 | |
| 5189 | case 207: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5190 | #line 2845 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5191 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5192 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 5193 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5194 | ;} |
| 5195 | break; |
| 5196 | |
| 5197 | case 208: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5198 | #line 2849 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5199 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5200 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 5201 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5202 | ;} |
| 5203 | break; |
| 5204 | |
| 5205 | case 209: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5206 | #line 2853 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5207 | { ;} |
| 5208 | break; |
| 5209 | |
| 5210 | case 213: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5211 | #line 2866 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5212 | { yyval.StrVal = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5213 | break; |
| 5214 | |
| 5215 | case 214: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5216 | #line 2870 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5217 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5218 | if (yyvsp[-1].TypeVal.PAT->get() == Type::VoidTy) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5219 | error("void typed arguments are invalid"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5220 | yyval.ArgVal = new std::pair<PATypeInfo, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5221 | ;} |
| 5222 | break; |
| 5223 | |
| 5224 | case 215: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5225 | #line 2878 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5226 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5227 | yyval.ArgList = yyvsp[-2].ArgList; |
| 5228 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 5229 | delete yyvsp[0].ArgVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5230 | ;} |
| 5231 | break; |
| 5232 | |
| 5233 | case 216: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5234 | #line 2883 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5235 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5236 | yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5237 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 5238 | delete yyvsp[0].ArgVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5239 | ;} |
| 5240 | break; |
| 5241 | |
| 5242 | case 217: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5243 | #line 2891 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5244 | { yyval.ArgList = yyvsp[0].ArgList; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5245 | break; |
| 5246 | |
| 5247 | case 218: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5248 | #line 2892 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5249 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5250 | yyval.ArgList = yyvsp[-2].ArgList; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5251 | PATypeInfo VoidTI; |
| 5252 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5253 | VoidTI.S.makeSignless(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5254 | yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5255 | ;} |
| 5256 | break; |
| 5257 | |
| 5258 | case 219: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5259 | #line 2899 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5260 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5261 | yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5262 | PATypeInfo VoidTI; |
| 5263 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5264 | VoidTI.S.makeSignless(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5265 | yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5266 | ;} |
| 5267 | break; |
| 5268 | |
| 5269 | case 220: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5270 | #line 2906 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5271 | { yyval.ArgList = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5272 | break; |
| 5273 | |
| 5274 | case 221: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5275 | #line 2910 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5276 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5277 | UnEscapeLexed(yyvsp[-5].StrVal); |
| 5278 | std::string FunctionName(yyvsp[-5].StrVal); |
| 5279 | free(yyvsp[-5].StrVal); // Free strdup'd memory! |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5280 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5281 | const Type* RetTy = yyvsp[-6].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5282 | |
| 5283 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 5284 | error("LLVM functions cannot return aggregate types"); |
| 5285 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5286 | Signedness FTySign; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5287 | FTySign.makeComposite(yyvsp[-6].TypeVal.S); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5288 | std::vector<const Type*> ParamTyList; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5289 | |
| 5290 | // In LLVM 2.0 the signatures of three varargs intrinsics changed to take |
| 5291 | // i8*. We check here for those names and override the parameter list |
| 5292 | // types to ensure the prototype is correct. |
| 5293 | if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5294 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5295 | } else if (FunctionName == "llvm.va_copy") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5296 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
| 5297 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5298 | } else if (yyvsp[-3].ArgList) { // If there are arguments... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5299 | for (std::vector<std::pair<PATypeInfo,char*> >::iterator |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5300 | 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] | 5301 | const Type *Ty = I->first.PAT->get(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5302 | ParamTyList.push_back(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5303 | FTySign.add(I->first.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5304 | } |
| 5305 | } |
| 5306 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5307 | bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy; |
| 5308 | if (isVarArg) |
| 5309 | ParamTyList.pop_back(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5310 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5311 | // Convert the CSRet calling convention into the corresponding parameter |
| 5312 | // attribute. |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5313 | ParamAttrsList *PAL = 0; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5314 | if (yyvsp[-7].UIntVal == OldCallingConv::CSRet) { |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5315 | ParamAttrsVector Attrs; |
| 5316 | ParamAttrsWithIndex PAWI; |
| 5317 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 5318 | Attrs.push_back(PAWI); |
| 5319 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5320 | } |
| 5321 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5322 | const FunctionType *FT = |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5323 | FunctionType::get(RetTy, ParamTyList, isVarArg, PAL); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5324 | const PointerType *PFT = PointerType::get(FT); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5325 | delete yyvsp[-6].TypeVal.PAT; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5326 | |
| 5327 | ValID ID; |
| 5328 | if (!FunctionName.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5329 | ID = ValID::create((char*)FunctionName.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5330 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5331 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5332 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5333 | ID.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5334 | |
| 5335 | Function *Fn = 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5336 | Module* M = CurModule.CurrentModule; |
| 5337 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5338 | // See if this function was forward referenced. If so, recycle the object. |
| 5339 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 5340 | // Move the function to the end of the list, from whereever it was |
| 5341 | // previously inserted. |
| 5342 | Fn = cast<Function>(FWRef); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5343 | M->getFunctionList().remove(Fn); |
| 5344 | M->getFunctionList().push_back(Fn); |
| 5345 | } else if (!FunctionName.empty()) { |
| 5346 | GlobalValue *Conflict = M->getFunction(FunctionName); |
| 5347 | if (!Conflict) |
| 5348 | Conflict = M->getNamedGlobal(FunctionName); |
| 5349 | if (Conflict && PFT == Conflict->getType()) { |
| 5350 | if (!CurFun.isDeclare && !Conflict->isDeclaration()) { |
| 5351 | // We have two function definitions that conflict, same type, same |
| 5352 | // name. We should really check to make sure that this is the result |
| 5353 | // of integer type planes collapsing and generate an error if it is |
| 5354 | // not, but we'll just rename on the assumption that it is. However, |
| 5355 | // let's do it intelligently and rename the internal linkage one |
| 5356 | // if there is one. |
| 5357 | std::string NewName(makeNameUnique(FunctionName)); |
| 5358 | if (Conflict->hasInternalLinkage()) { |
| 5359 | Conflict->setName(NewName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5360 | RenameMapKey Key = |
| 5361 | makeRenameMapKey(FunctionName, Conflict->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5362 | CurModule.RenameMap[Key] = NewName; |
| 5363 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5364 | InsertValue(Fn, CurModule.Values); |
| 5365 | } else { |
| 5366 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5367 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5368 | RenameMapKey Key = |
| 5369 | makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5370 | CurModule.RenameMap[Key] = NewName; |
| 5371 | } |
| 5372 | } else { |
| 5373 | // If they are not both definitions, then just use the function we |
| 5374 | // found since the types are the same. |
| 5375 | Fn = cast<Function>(Conflict); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5376 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5377 | // Make sure to strip off any argument names so we can't get |
| 5378 | // conflicts. |
| 5379 | if (Fn->isDeclaration()) |
| 5380 | for (Function::arg_iterator AI = Fn->arg_begin(), |
| 5381 | AE = Fn->arg_end(); AI != AE; ++AI) |
| 5382 | AI->setName(""); |
| 5383 | } |
| 5384 | } else if (Conflict) { |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 5385 | // We have two globals with the same name and different types. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5386 | // Previously, this was permitted because the symbol table had |
| 5387 | // "type planes" and names only needed to be distinct within a |
| 5388 | // type plane. After PR411 was fixed, this is no loner the case. |
| 5389 | // To resolve this we must rename one of the two. |
| 5390 | if (Conflict->hasInternalLinkage()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5391 | // We can safely rename the Conflict. |
| 5392 | RenameMapKey Key = |
| 5393 | makeRenameMapKey(Conflict->getName(), Conflict->getType(), |
| 5394 | CurModule.NamedValueSigns[Conflict->getName()]); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5395 | Conflict->setName(makeNameUnique(Conflict->getName())); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5396 | CurModule.RenameMap[Key] = Conflict->getName(); |
| 5397 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5398 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5399 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5400 | // We can't quietly rename either of these things, but we must |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5401 | // rename one of them. Only if the function's linkage is internal can |
| 5402 | // we forgo a warning message about the renamed function. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5403 | std::string NewName = makeNameUnique(FunctionName); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5404 | if (CurFun.Linkage != GlobalValue::InternalLinkage) { |
| 5405 | warning("Renaming function '" + FunctionName + "' as '" + NewName + |
| 5406 | "' may cause linkage errors"); |
| 5407 | } |
| 5408 | // Elect to rename the thing we're now defining. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5409 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5410 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5411 | RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5412 | CurModule.RenameMap[Key] = NewName; |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5413 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5414 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5415 | // There's no conflict, just define the function |
| 5416 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5417 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5418 | } |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 5419 | } else { |
| 5420 | // There's no conflict, just define the function |
| 5421 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5422 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5423 | } |
| 5424 | |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 5425 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5426 | CurFun.FunctionStart(Fn); |
| 5427 | |
| 5428 | if (CurFun.isDeclare) { |
| 5429 | // If we have declaration, always overwrite linkage. This will allow us |
| 5430 | // to correctly handle cases, when pointer to function is passed as |
| 5431 | // argument to another function. |
| 5432 | Fn->setLinkage(CurFun.Linkage); |
| 5433 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5434 | Fn->setCallingConv(upgradeCallingConv(yyvsp[-7].UIntVal)); |
| 5435 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 5436 | if (yyvsp[-1].StrVal) { |
| 5437 | Fn->setSection(yyvsp[-1].StrVal); |
| 5438 | free(yyvsp[-1].StrVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5439 | } |
| 5440 | |
| 5441 | // Add all of the arguments we parsed to the function... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5442 | if (yyvsp[-3].ArgList) { // Is null if empty... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5443 | if (isVarArg) { // Nuke the last entry |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5444 | assert(yyvsp[-3].ArgList->back().first.PAT->get() == Type::VoidTy && |
| 5445 | yyvsp[-3].ArgList->back().second == 0 && "Not a varargs marker"); |
| 5446 | delete yyvsp[-3].ArgList->back().first.PAT; |
| 5447 | yyvsp[-3].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5448 | } |
| 5449 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5450 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5451 | std::vector<std::pair<PATypeInfo,char*> >::iterator I = yyvsp[-3].ArgList->begin(); |
| 5452 | std::vector<std::pair<PATypeInfo,char*> >::iterator E = yyvsp[-3].ArgList->end(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5453 | for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5454 | delete I->first.PAT; // Delete the typeholder... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5455 | ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S); |
| 5456 | setValueName(VI, I->second); // Insert arg into symtab... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5457 | InsertValue(ArgIt); |
| 5458 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5459 | delete yyvsp[-3].ArgList; // We're now done with the argument list |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5460 | } |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5461 | lastCallingConv = OldCallingConv::C; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5462 | ;} |
| 5463 | break; |
| 5464 | |
| 5465 | case 224: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5466 | #line 3104 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5467 | { CurFun.Linkage = yyvsp[0].Linkage; ;} |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5468 | break; |
| 5469 | |
| 5470 | case 225: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5471 | #line 3104 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5472 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5473 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5474 | |
| 5475 | // Make sure that we keep track of the linkage type even if there was a |
| 5476 | // previous "declare". |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5477 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5478 | ;} |
| 5479 | break; |
| 5480 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5481 | case 228: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5482 | #line 3118 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5483 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5484 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5485 | ;} |
| 5486 | break; |
| 5487 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5488 | case 229: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5489 | #line 3123 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5490 | { yyval.Linkage = GlobalValue::ExternalLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5491 | break; |
| 5492 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5493 | case 230: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5494 | #line 3124 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5495 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5496 | break; |
| 5497 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5498 | case 231: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5499 | #line 3125 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5500 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5501 | break; |
| 5502 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5503 | case 232: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5504 | #line 3129 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5505 | { CurFun.isDeclare = true; ;} |
| 5506 | break; |
| 5507 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5508 | case 233: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5509 | #line 3130 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5510 | { CurFun.Linkage = yyvsp[0].Linkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5511 | break; |
| 5512 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5513 | case 234: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5514 | #line 3130 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5515 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5516 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5517 | CurFun.FunctionDone(); |
| 5518 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5519 | ;} |
| 5520 | break; |
| 5521 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5522 | case 235: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5523 | #line 3142 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5524 | { yyval.BoolVal = false; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5525 | break; |
| 5526 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5527 | case 236: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5528 | #line 3143 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5529 | { yyval.BoolVal = true; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5530 | break; |
| 5531 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5532 | case 237: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5533 | #line 3148 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5534 | { yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5535 | break; |
| 5536 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5537 | case 238: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5538 | #line 3149 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5539 | { yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5540 | break; |
| 5541 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5542 | case 239: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5543 | #line 3150 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5544 | { yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5545 | break; |
| 5546 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5547 | case 240: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5548 | #line 3151 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5549 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5550 | yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, true)); |
| 5551 | yyval.ValIDVal.S.makeUnsigned(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5552 | ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5553 | break; |
| 5554 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5555 | case 241: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5556 | #line 3155 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5557 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5558 | yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, false)); |
| 5559 | yyval.ValIDVal.S.makeUnsigned(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5560 | ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5561 | break; |
| 5562 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5563 | case 242: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5564 | #line 3159 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5565 | { yyval.ValIDVal = ValID::createNull(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5566 | break; |
| 5567 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5568 | case 243: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5569 | #line 3160 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5570 | { yyval.ValIDVal = ValID::createUndef(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5571 | break; |
| 5572 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5573 | case 244: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5574 | #line 3161 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5575 | { yyval.ValIDVal = ValID::createZeroInit(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5576 | break; |
| 5577 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5578 | case 245: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5579 | #line 3162 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5580 | { // Nonempty unsized packed vector |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5581 | const Type *ETy = (*yyvsp[-1].ConstVector)[0].C->getType(); |
| 5582 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5583 | VectorType* pt = VectorType::get(ETy, NumElements); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5584 | yyval.ValIDVal.S.makeComposite((*yyvsp[-1].ConstVector)[0].S); |
| 5585 | PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, yyval.ValIDVal.S)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5586 | |
| 5587 | // Verify all elements are correct type! |
| 5588 | std::vector<Constant*> Elems; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5589 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 5590 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5591 | const Type *CTy = C->getType(); |
| 5592 | if (ETy != CTy) |
| 5593 | error("Element #" + utostr(i) + " is not of type '" + |
| 5594 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 5595 | CTy->getDescription() + "'"); |
| 5596 | Elems.push_back(C); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 5597 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5598 | yyval.ValIDVal = ValID::create(ConstantVector::get(pt, Elems)); |
| 5599 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5600 | ;} |
| 5601 | break; |
| 5602 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5603 | case 246: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5604 | #line 3183 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5605 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5606 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal.C); |
| 5607 | yyval.ValIDVal.S.copy(yyvsp[0].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5608 | ;} |
| 5609 | break; |
| 5610 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5611 | case 247: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5612 | #line 3187 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5613 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5614 | char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); |
| 5615 | std::string AsmStr = std::string(yyvsp[-2].StrVal, End); |
| 5616 | End = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 5617 | std::string Constraints = std::string(yyvsp[0].StrVal, End); |
| 5618 | yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); |
| 5619 | free(yyvsp[-2].StrVal); |
| 5620 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5621 | ;} |
| 5622 | break; |
| 5623 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5624 | case 248: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5625 | #line 3201 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5626 | { yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); yyval.ValIDVal.S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5627 | break; |
| 5628 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5629 | case 249: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5630 | #line 3202 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5631 | { yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); yyval.ValIDVal.S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5632 | break; |
| 5633 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5634 | case 252: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5635 | #line 3215 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5636 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5637 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 5638 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
| 5639 | yyval.ValueVal.V = getVal(Ty, yyvsp[0].ValIDVal); |
| 5640 | yyval.ValueVal.S.copy(yyvsp[-1].TypeVal.S); |
| 5641 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5642 | ;} |
| 5643 | break; |
| 5644 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5645 | case 253: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5646 | #line 3225 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5647 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5648 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5649 | ;} |
| 5650 | break; |
| 5651 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5652 | case 254: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5653 | #line 3228 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5654 | { // Do not allow functions with 0 basic blocks |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5655 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5656 | ;} |
| 5657 | break; |
| 5658 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5659 | case 255: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5660 | #line 3237 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5661 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5662 | ValueInfo VI; VI.V = yyvsp[0].TermInstVal.TI; VI.S.copy(yyvsp[0].TermInstVal.S); |
| 5663 | setValueName(VI, yyvsp[-1].StrVal); |
| 5664 | InsertValue(yyvsp[0].TermInstVal.TI); |
| 5665 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal.TI); |
| 5666 | InsertValue(yyvsp[-2].BasicBlockVal); |
| 5667 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5668 | ;} |
| 5669 | break; |
| 5670 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5671 | case 256: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5672 | #line 3248 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5673 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5674 | if (yyvsp[0].InstVal.I) |
| 5675 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal.I); |
| 5676 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5677 | ;} |
| 5678 | break; |
| 5679 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5680 | case 257: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5681 | #line 3253 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5682 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5683 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5684 | // Make sure to move the basic block to the correct location in the |
| 5685 | // function, instead of leaving it inserted wherever it was first |
| 5686 | // referenced. |
| 5687 | Function::BasicBlockListType &BBL = |
| 5688 | CurFun.CurrentFunction->getBasicBlockList(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5689 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5690 | ;} |
| 5691 | break; |
| 5692 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5693 | case 258: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5694 | #line 3262 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5695 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5696 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5697 | // Make sure to move the basic block to the correct location in the |
| 5698 | // function, instead of leaving it inserted wherever it was first |
| 5699 | // referenced. |
| 5700 | Function::BasicBlockListType &BBL = |
| 5701 | CurFun.CurrentFunction->getBasicBlockList(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5702 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5703 | ;} |
| 5704 | break; |
| 5705 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5706 | case 261: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5707 | #line 3276 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5708 | { // Return with a result... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5709 | yyval.TermInstVal.TI = new ReturnInst(yyvsp[0].ValueVal.V); |
| 5710 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5711 | ;} |
| 5712 | break; |
| 5713 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5714 | case 262: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5715 | #line 3280 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5716 | { // Return with no result... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5717 | yyval.TermInstVal.TI = new ReturnInst(); |
| 5718 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5719 | ;} |
| 5720 | break; |
| 5721 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5722 | case 263: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5723 | #line 3284 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5724 | { // Unconditional Branch... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5725 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 5726 | yyval.TermInstVal.TI = new BranchInst(tmpBB); |
| 5727 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5728 | ;} |
| 5729 | break; |
| 5730 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5731 | case 264: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5732 | #line 3289 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5733 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5734 | yyvsp[-3].ValIDVal.S.makeSignless(); |
| 5735 | yyvsp[0].ValIDVal.S.makeSignless(); |
| 5736 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 5737 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 5738 | yyvsp[-6].ValIDVal.S.makeUnsigned(); |
| 5739 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 5740 | yyval.TermInstVal.TI = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 5741 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5742 | ;} |
| 5743 | break; |
| 5744 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5745 | case 265: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5746 | #line 3299 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5747 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5748 | yyvsp[-6].ValIDVal.S.copy(yyvsp[-7].PrimType.S); |
| 5749 | Value* tmpVal = getVal(yyvsp[-7].PrimType.T, yyvsp[-6].ValIDVal); |
| 5750 | yyvsp[-3].ValIDVal.S.makeSignless(); |
| 5751 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 5752 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 5753 | yyval.TermInstVal.TI = S; |
| 5754 | yyval.TermInstVal.S.makeSignless(); |
| 5755 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 5756 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5757 | for (; I != E; ++I) { |
| 5758 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 5759 | S->addCase(CI, I->second); |
| 5760 | else |
| 5761 | error("Switch case is constant, but not a simple integer"); |
| 5762 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5763 | delete yyvsp[-1].JumpTable; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5764 | ;} |
| 5765 | break; |
| 5766 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5767 | case 266: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5768 | #line 3317 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5769 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5770 | yyvsp[-5].ValIDVal.S.copy(yyvsp[-6].PrimType.S); |
| 5771 | Value* tmpVal = getVal(yyvsp[-6].PrimType.T, yyvsp[-5].ValIDVal); |
| 5772 | yyvsp[-2].ValIDVal.S.makeSignless(); |
| 5773 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5774 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5775 | yyval.TermInstVal.TI = S; |
| 5776 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5777 | ;} |
| 5778 | break; |
| 5779 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5780 | case 267: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5781 | #line 3327 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5782 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5783 | const PointerType *PFTy; |
| 5784 | const FunctionType *Ty; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5785 | Signedness FTySign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5786 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5787 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal.PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5788 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5789 | // Pull out the types of all of the arguments... |
| 5790 | std::vector<const Type*> ParamTypes; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5791 | FTySign.makeComposite(yyvsp[-10].TypeVal.S); |
| 5792 | if (yyvsp[-7].ValueList) { |
| 5793 | 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] | 5794 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5795 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5796 | FTySign.add(I->S); |
| 5797 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5798 | } |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5799 | ParamAttrsList *PAL = 0; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5800 | if (yyvsp[-11].UIntVal == OldCallingConv::CSRet) { |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5801 | ParamAttrsVector Attrs; |
| 5802 | ParamAttrsWithIndex PAWI; |
| 5803 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 5804 | Attrs.push_back(PAWI); |
| 5805 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5806 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5807 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5808 | if (isVarArg) ParamTypes.pop_back(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5809 | Ty = FunctionType::get(yyvsp[-10].TypeVal.PAT->get(), ParamTypes, isVarArg, PAL); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5810 | PFTy = PointerType::get(Ty); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5811 | yyval.TermInstVal.S.copy(yyvsp[-10].TypeVal.S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5812 | } else { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5813 | FTySign = yyvsp[-10].TypeVal.S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 5814 | // Get the signedness of the result type. $3 is the pointer to the |
| 5815 | // function type so we get the 0th element to extract the function type, |
| 5816 | // and then the 0th element again to get the result type. |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5817 | yyval.TermInstVal.S.copy(yyvsp[-10].TypeVal.S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5818 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5819 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5820 | yyvsp[-9].ValIDVal.S.makeComposite(FTySign); |
| 5821 | Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling... |
| 5822 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
| 5823 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5824 | |
| 5825 | // Create the call node... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5826 | if (!yyvsp[-7].ValueList) { // Has no arguments? |
| 5827 | yyval.TermInstVal.TI = new InvokeInst(V, Normal, Except, 0, 0); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5828 | } else { // Has arguments? |
| 5829 | // Loop through FunctionType's arguments and ensure they are specified |
| 5830 | // correctly! |
| 5831 | // |
| 5832 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5833 | FunctionType::param_iterator E = Ty->param_end(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5834 | 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] | 5835 | |
| 5836 | std::vector<Value*> Args; |
| 5837 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5838 | if ((*ArgI).V->getType() != *I) |
| 5839 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 5840 | (*I)->getDescription() + "'"); |
| 5841 | Args.push_back((*ArgI).V); |
| 5842 | } |
| 5843 | |
| 5844 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 5845 | error("Invalid number of parameters detected"); |
| 5846 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5847 | yyval.TermInstVal.TI = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5848 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5849 | cast<InvokeInst>(yyval.TermInstVal.TI)->setCallingConv(upgradeCallingConv(yyvsp[-11].UIntVal)); |
| 5850 | delete yyvsp[-10].TypeVal.PAT; |
| 5851 | delete yyvsp[-7].ValueList; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5852 | lastCallingConv = OldCallingConv::C; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5853 | ;} |
| 5854 | break; |
| 5855 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5856 | case 268: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5857 | #line 3399 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5858 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5859 | yyval.TermInstVal.TI = new UnwindInst(); |
| 5860 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5861 | ;} |
| 5862 | break; |
| 5863 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5864 | case 269: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5865 | #line 3403 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5866 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5867 | yyval.TermInstVal.TI = new UnreachableInst(); |
| 5868 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5869 | ;} |
| 5870 | break; |
| 5871 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5872 | case 270: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5873 | #line 3410 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5874 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5875 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 5876 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-4].PrimType.S); |
| 5877 | Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5878 | |
| 5879 | if (V == 0) |
| 5880 | error("May only switch on a constant pool value"); |
| 5881 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5882 | yyvsp[0].ValIDVal.S.makeSignless(); |
| 5883 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 5884 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5885 | ;} |
| 5886 | break; |
| 5887 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5888 | case 271: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5889 | #line 3422 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5890 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5891 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 5892 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-4].PrimType.S); |
| 5893 | Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5894 | |
| 5895 | if (V == 0) |
| 5896 | error("May only switch on a constant pool value"); |
| 5897 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5898 | yyvsp[0].ValIDVal.S.makeSignless(); |
| 5899 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 5900 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5901 | ;} |
| 5902 | break; |
| 5903 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5904 | case 272: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5905 | #line 3437 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5906 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5907 | bool omit = false; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5908 | if (yyvsp[-1].StrVal) |
| 5909 | if (BitCastInst *BCI = dyn_cast<BitCastInst>(yyvsp[0].InstVal.I)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5910 | if (BCI->getSrcTy() == BCI->getDestTy() && |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5911 | BCI->getOperand(0)->getName() == yyvsp[-1].StrVal) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5912 | // This is a useless bit cast causing a name redefinition. It is |
| 5913 | // a bit cast from a type to the same type of an operand with the |
| 5914 | // same name as the name we would give this instruction. Since this |
| 5915 | // instruction results in no code generation, it is safe to omit |
| 5916 | // the instruction. This situation can occur because of collapsed |
| 5917 | // type planes. For example: |
| 5918 | // %X = add int %Y, %Z |
| 5919 | // %X = cast int %Y to uint |
| 5920 | // After upgrade, this looks like: |
| 5921 | // %X = add i32 %Y, %Z |
| 5922 | // %X = bitcast i32 to i32 |
| 5923 | // The bitcast is clearly useless so we omit it. |
| 5924 | omit = true; |
| 5925 | if (omit) { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5926 | yyval.InstVal.I = 0; |
| 5927 | yyval.InstVal.S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5928 | } else { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5929 | ValueInfo VI; VI.V = yyvsp[0].InstVal.I; VI.S.copy(yyvsp[0].InstVal.S); |
| 5930 | setValueName(VI, yyvsp[-1].StrVal); |
| 5931 | InsertValue(yyvsp[0].InstVal.I); |
| 5932 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5933 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5934 | ;} |
| 5935 | break; |
| 5936 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5937 | case 273: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5938 | #line 3467 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5939 | { // Used for PHI nodes |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5940 | yyval.PHIList.P = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 5941 | yyval.PHIList.S.copy(yyvsp[-5].TypeVal.S); |
| 5942 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-5].TypeVal.S); |
| 5943 | Value* tmpVal = getVal(yyvsp[-5].TypeVal.PAT->get(), yyvsp[-3].ValIDVal); |
| 5944 | yyvsp[-1].ValIDVal.S.makeSignless(); |
| 5945 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
| 5946 | yyval.PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5947 | delete yyvsp[-5].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5948 | ;} |
| 5949 | break; |
| 5950 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5951 | case 274: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5952 | #line 3477 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5953 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5954 | yyval.PHIList = yyvsp[-6].PHIList; |
| 5955 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-6].PHIList.S); |
| 5956 | Value* tmpVal = getVal(yyvsp[-6].PHIList.P->front().first->getType(), yyvsp[-3].ValIDVal); |
| 5957 | yyvsp[-1].ValIDVal.S.makeSignless(); |
| 5958 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
| 5959 | yyvsp[-6].PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5960 | ;} |
| 5961 | break; |
| 5962 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5963 | case 275: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5964 | #line 3487 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5965 | { // Used for call statements, and memory insts... |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5966 | yyval.ValueList = new std::vector<ValueInfo>(); |
| 5967 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5968 | ;} |
| 5969 | break; |
| 5970 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5971 | case 276: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5972 | #line 3491 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5973 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5974 | yyval.ValueList = yyvsp[-2].ValueList; |
| 5975 | yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5976 | ;} |
| 5977 | break; |
| 5978 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5979 | case 278: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5980 | #line 3499 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5981 | { yyval.ValueList = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5982 | break; |
| 5983 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5984 | case 279: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5985 | #line 3503 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5986 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5987 | yyval.BoolVal = true; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5988 | ;} |
| 5989 | break; |
| 5990 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5991 | case 280: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5992 | #line 3506 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5993 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5994 | yyval.BoolVal = false; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5995 | ;} |
| 5996 | break; |
| 5997 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5998 | case 281: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 5999 | #line 3512 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6000 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6001 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6002 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6003 | const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6004 | if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6005 | error("Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6006 | if (isa<VectorType>(Ty) && |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6007 | (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] | 6008 | error("Remainder not supported on vector types"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6009 | // Upgrade the opcode from obsolete versions before we do anything with it. |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6010 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); |
| 6011 | Value* val1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 6012 | Value* val2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 6013 | yyval.InstVal.I = BinaryOperator::create(Opcode, val1, val2); |
| 6014 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6015 | error("binary operator returned null"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6016 | yyval.InstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6017 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6018 | ;} |
| 6019 | break; |
| 6020 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6021 | case 282: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6022 | #line 3531 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6023 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6024 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6025 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6026 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6027 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6028 | if (!isa<VectorType>(Ty) || |
| 6029 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6030 | error("Logical operator requires integral operands"); |
| 6031 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6032 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); |
| 6033 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 6034 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 6035 | yyval.InstVal.I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); |
| 6036 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6037 | error("binary operator returned null"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6038 | yyval.InstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6039 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6040 | ;} |
| 6041 | break; |
| 6042 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6043 | case 283: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6044 | #line 3549 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6045 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6046 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6047 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6048 | const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6049 | if(isa<VectorType>(Ty)) |
| 6050 | error("VectorTypes currently not supported in setcc instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6051 | unsigned short pred; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6052 | Instruction::OtherOps Opcode = getCompareOp(yyvsp[-4].BinaryOpVal, pred, Ty, yyvsp[-3].TypeVal.S); |
| 6053 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 6054 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 6055 | yyval.InstVal.I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); |
| 6056 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6057 | error("binary operator returned null"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6058 | yyval.InstVal.S.makeUnsigned(); |
| 6059 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6060 | ;} |
| 6061 | break; |
| 6062 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6063 | case 284: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6064 | #line 3565 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6065 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6066 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6067 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6068 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6069 | if (isa<VectorType>(Ty)) |
| 6070 | error("VectorTypes currently not supported in icmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6071 | else if (!Ty->isInteger() && !isa<PointerType>(Ty)) |
| 6072 | error("icmp requires integer or pointer typed operands"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6073 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 6074 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 6075 | yyval.InstVal.I = new ICmpInst(yyvsp[-4].IPred, tmpVal1, tmpVal2); |
| 6076 | yyval.InstVal.S.makeUnsigned(); |
| 6077 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6078 | ;} |
| 6079 | break; |
| 6080 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6081 | case 285: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6082 | #line 3579 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6083 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6084 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6085 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6086 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6087 | if (isa<VectorType>(Ty)) |
| 6088 | error("VectorTypes currently not supported in fcmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6089 | else if (!Ty->isFloatingPoint()) |
| 6090 | error("fcmp instruction requires floating point operands"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6091 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 6092 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 6093 | yyval.InstVal.I = new FCmpInst(yyvsp[-4].FPred, tmpVal1, tmpVal2); |
| 6094 | yyval.InstVal.S.makeUnsigned(); |
| 6095 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6096 | ;} |
| 6097 | break; |
| 6098 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6099 | case 286: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6100 | #line 3593 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6101 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6102 | warning("Use of obsolete 'not' instruction: Replacing with 'xor"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6103 | const Type *Ty = yyvsp[0].ValueVal.V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6104 | Value *Ones = ConstantInt::getAllOnesValue(Ty); |
| 6105 | if (Ones == 0) |
| 6106 | error("Expected integral type for not instruction"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6107 | yyval.InstVal.I = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal.V, Ones); |
| 6108 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6109 | error("Could not create a xor instruction"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6110 | yyval.InstVal.S.copy(yyvsp[0].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6111 | ;} |
| 6112 | break; |
| 6113 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6114 | case 287: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6115 | #line 3604 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6116 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6117 | if (!yyvsp[0].ValueVal.V->getType()->isInteger() || |
| 6118 | cast<IntegerType>(yyvsp[0].ValueVal.V->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6119 | error("Shift amount must be int8"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6120 | const Type* Ty = yyvsp[-2].ValueVal.V->getType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6121 | if (!Ty->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6122 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6123 | Value* ShiftAmt = 0; |
| 6124 | if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth()) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6125 | if (Constant *C = dyn_cast<Constant>(yyvsp[0].ValueVal.V)) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6126 | ShiftAmt = ConstantExpr::getZExt(C, Ty); |
| 6127 | else |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6128 | ShiftAmt = new ZExtInst(yyvsp[0].ValueVal.V, Ty, makeNameUnique("shift"), CurBB); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6129 | else |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6130 | ShiftAmt = yyvsp[0].ValueVal.V; |
| 6131 | yyval.InstVal.I = BinaryOperator::create(getBinaryOp(yyvsp[-3].BinaryOpVal, Ty, yyvsp[-2].ValueVal.S), yyvsp[-2].ValueVal.V, ShiftAmt); |
| 6132 | yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6133 | ;} |
| 6134 | break; |
| 6135 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6136 | case 288: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6137 | #line 3622 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6138 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6139 | const Type *DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6140 | if (!DstTy->isFirstClassType()) |
| 6141 | error("cast instruction to a non-primitive type: '" + |
| 6142 | DstTy->getDescription() + "'"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6143 | yyval.InstVal.I = cast<Instruction>(getCast(yyvsp[-3].CastOpVal, yyvsp[-2].ValueVal.V, yyvsp[-2].ValueVal.S, DstTy, yyvsp[0].TypeVal.S, true)); |
| 6144 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 6145 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6146 | ;} |
| 6147 | break; |
| 6148 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6149 | case 289: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6150 | #line 3631 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6151 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6152 | if (!yyvsp[-4].ValueVal.V->getType()->isInteger() || |
| 6153 | cast<IntegerType>(yyvsp[-4].ValueVal.V->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6154 | error("select condition must be bool"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6155 | if (yyvsp[-2].ValueVal.V->getType() != yyvsp[0].ValueVal.V->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6156 | error("select value types should match"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6157 | yyval.InstVal.I = new SelectInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 6158 | yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6159 | ;} |
| 6160 | break; |
| 6161 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6162 | case 290: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6163 | #line 3640 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6164 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6165 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6166 | NewVarArgs = true; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6167 | yyval.InstVal.I = new VAArgInst(yyvsp[-2].ValueVal.V, Ty); |
| 6168 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 6169 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6170 | ;} |
| 6171 | break; |
| 6172 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6173 | case 291: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6174 | #line 3647 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6175 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6176 | const Type* ArgTy = yyvsp[-2].ValueVal.V->getType(); |
| 6177 | const Type* DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6178 | ObsoleteVarArgs = true; |
| 6179 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6180 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6181 | |
| 6182 | //b = vaarg a, t -> |
| 6183 | //foo = alloca 1 of t |
| 6184 | //bar = vacopy a |
| 6185 | //store bar -> foo |
| 6186 | //b = vaarg foo, t |
| 6187 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 6188 | CurBB->getInstList().push_back(foo); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6189 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6190 | CurBB->getInstList().push_back(bar); |
| 6191 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6192 | yyval.InstVal.I = new VAArgInst(foo, DstTy); |
| 6193 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 6194 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6195 | ;} |
| 6196 | break; |
| 6197 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6198 | case 292: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6199 | #line 3668 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6200 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6201 | const Type* ArgTy = yyvsp[-2].ValueVal.V->getType(); |
| 6202 | const Type* DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6203 | ObsoleteVarArgs = true; |
| 6204 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6205 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6206 | |
| 6207 | //b = vanext a, t -> |
| 6208 | //foo = alloca 1 of t |
| 6209 | //bar = vacopy a |
| 6210 | //store bar -> foo |
| 6211 | //tmp = vaarg foo, t |
| 6212 | //b = load foo |
| 6213 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 6214 | CurBB->getInstList().push_back(foo); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6215 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6216 | CurBB->getInstList().push_back(bar); |
| 6217 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 6218 | Instruction* tmp = new VAArgInst(foo, DstTy); |
| 6219 | CurBB->getInstList().push_back(tmp); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6220 | yyval.InstVal.I = new LoadInst(foo); |
| 6221 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 6222 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6223 | ;} |
| 6224 | break; |
| 6225 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6226 | case 293: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6227 | #line 3692 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6228 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6229 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6230 | error("Invalid extractelement operands"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6231 | yyval.InstVal.I = new ExtractElementInst(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 6232 | yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6233 | ;} |
| 6234 | break; |
| 6235 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6236 | case 294: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6237 | #line 3698 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6238 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6239 | 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] | 6240 | error("Invalid insertelement operands"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6241 | yyval.InstVal.I = new InsertElementInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 6242 | yyval.InstVal.S.copy(yyvsp[-4].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6243 | ;} |
| 6244 | break; |
| 6245 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6246 | case 295: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6247 | #line 3704 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6248 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6249 | 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] | 6250 | error("Invalid shufflevector operands"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6251 | yyval.InstVal.I = new ShuffleVectorInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 6252 | yyval.InstVal.S.copy(yyvsp[-4].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6253 | ;} |
| 6254 | break; |
| 6255 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6256 | case 296: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6257 | #line 3710 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6258 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6259 | const Type *Ty = yyvsp[0].PHIList.P->front().first->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6260 | if (!Ty->isFirstClassType()) |
| 6261 | error("PHI node operands must be of first class type"); |
| 6262 | PHINode *PHI = new PHINode(Ty); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6263 | PHI->reserveOperandSpace(yyvsp[0].PHIList.P->size()); |
| 6264 | while (yyvsp[0].PHIList.P->begin() != yyvsp[0].PHIList.P->end()) { |
| 6265 | if (yyvsp[0].PHIList.P->front().first->getType() != Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6266 | error("All elements of a PHI node must be of the same type"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6267 | PHI->addIncoming(yyvsp[0].PHIList.P->front().first, yyvsp[0].PHIList.P->front().second); |
| 6268 | yyvsp[0].PHIList.P->pop_front(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6269 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6270 | yyval.InstVal.I = PHI; |
| 6271 | yyval.InstVal.S.copy(yyvsp[0].PHIList.S); |
| 6272 | delete yyvsp[0].PHIList.P; // Free the list... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6273 | ;} |
| 6274 | break; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6275 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6276 | case 297: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6277 | #line 3726 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6278 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6279 | // Handle the short call syntax |
| 6280 | const PointerType *PFTy; |
| 6281 | const FunctionType *FTy; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6282 | Signedness FTySign; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6283 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal.PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6284 | !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 6285 | // Pull out the types of all of the arguments... |
| 6286 | std::vector<const Type*> ParamTypes; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6287 | FTySign.makeComposite(yyvsp[-4].TypeVal.S); |
| 6288 | if (yyvsp[-1].ValueList) { |
| 6289 | 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] | 6290 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6291 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6292 | FTySign.add(I->S); |
| 6293 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6294 | } |
| 6295 | |
| 6296 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 6297 | if (isVarArg) ParamTypes.pop_back(); |
| 6298 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6299 | const Type *RetTy = yyvsp[-4].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6300 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 6301 | error("Functions cannot return aggregate types"); |
| 6302 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 6303 | // Deal with CSRetCC |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6304 | ParamAttrsList *PAL = 0; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6305 | if (yyvsp[-5].UIntVal == OldCallingConv::CSRet) { |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6306 | ParamAttrsVector Attrs; |
| 6307 | ParamAttrsWithIndex PAWI; |
| 6308 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 6309 | Attrs.push_back(PAWI); |
| 6310 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 6311 | } |
| 6312 | |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6313 | FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, PAL); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6314 | PFTy = PointerType::get(FTy); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6315 | yyval.InstVal.S.copy(yyvsp[-4].TypeVal.S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6316 | } else { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6317 | FTySign = yyvsp[-4].TypeVal.S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 6318 | // Get the signedness of the result type. $3 is the pointer to the |
| 6319 | // function type so we get the 0th element to extract the function type, |
| 6320 | // and then the 0th element again to get the result type. |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6321 | yyval.InstVal.S.copy(yyvsp[-4].TypeVal.S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6322 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6323 | yyvsp[-3].ValIDVal.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6324 | |
| 6325 | // First upgrade any intrinsic calls. |
| 6326 | std::vector<Value*> Args; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6327 | if (yyvsp[-1].ValueList) |
| 6328 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i < e; ++i) |
| 6329 | Args.push_back((*yyvsp[-1].ValueList)[i].V); |
| 6330 | Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), yyvsp[-3].ValIDVal, Args); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6331 | |
| 6332 | // If we got an upgraded intrinsic |
| 6333 | if (Inst) { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6334 | yyval.InstVal.I = Inst; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6335 | } else { |
| 6336 | // Get the function we're calling |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6337 | Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6338 | |
| 6339 | // Check the argument values match |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6340 | if (!yyvsp[-1].ValueList) { // Has no arguments? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6341 | // Make sure no arguments is a good thing! |
| 6342 | if (FTy->getNumParams() != 0) |
| 6343 | error("No arguments passed to a function that expects arguments"); |
| 6344 | } else { // Has arguments? |
| 6345 | // Loop through FunctionType's arguments and ensure they are specified |
| 6346 | // correctly! |
| 6347 | // |
| 6348 | FunctionType::param_iterator I = FTy->param_begin(); |
| 6349 | FunctionType::param_iterator E = FTy->param_end(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6350 | 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] | 6351 | |
| 6352 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 6353 | if ((*ArgI).V->getType() != *I) |
| 6354 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 6355 | (*I)->getDescription() + "'"); |
| 6356 | |
| 6357 | if (I != E || (ArgI != ArgE && !FTy->isVarArg())) |
| 6358 | error("Invalid number of parameters detected"); |
| 6359 | } |
| 6360 | |
| 6361 | // Create the call instruction |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6362 | CallInst *CI = new CallInst(V, Args.begin(), Args.end()); |
| 6363 | CI->setTailCall(yyvsp[-6].BoolVal); |
| 6364 | CI->setCallingConv(upgradeCallingConv(yyvsp[-5].UIntVal)); |
| 6365 | yyval.InstVal.I = CI; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6366 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6367 | delete yyvsp[-4].TypeVal.PAT; |
| 6368 | delete yyvsp[-1].ValueList; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6369 | lastCallingConv = OldCallingConv::C; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6370 | ;} |
| 6371 | break; |
| 6372 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6373 | case 298: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6374 | #line 3819 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6375 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6376 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6377 | ;} |
| 6378 | break; |
| 6379 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6380 | case 299: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6381 | #line 3827 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 6382 | { yyval.ValueList = yyvsp[0].ValueList; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6383 | break; |
| 6384 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6385 | case 300: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6386 | #line 3828 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 6387 | { yyval.ValueList = new std::vector<ValueInfo>(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6388 | break; |
| 6389 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6390 | case 301: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6391 | #line 3832 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 6392 | { yyval.BoolVal = true; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6393 | break; |
| 6394 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6395 | case 302: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6396 | #line 3833 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 6397 | { yyval.BoolVal = false; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6398 | break; |
| 6399 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6400 | case 303: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6401 | #line 3837 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6402 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6403 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 6404 | yyval.InstVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 6405 | yyval.InstVal.I = new MallocInst(Ty, 0, yyvsp[0].UIntVal); |
| 6406 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6407 | ;} |
| 6408 | break; |
| 6409 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6410 | case 304: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6411 | #line 3843 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6412 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6413 | const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); |
| 6414 | yyvsp[-1].ValIDVal.S.makeUnsigned(); |
| 6415 | yyval.InstVal.S.makeComposite(yyvsp[-4].TypeVal.S); |
| 6416 | yyval.InstVal.I = new MallocInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 6417 | delete yyvsp[-4].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6418 | ;} |
| 6419 | break; |
| 6420 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6421 | case 305: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6422 | #line 3850 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6423 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6424 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 6425 | yyval.InstVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 6426 | yyval.InstVal.I = new AllocaInst(Ty, 0, yyvsp[0].UIntVal); |
| 6427 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6428 | ;} |
| 6429 | break; |
| 6430 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6431 | case 306: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6432 | #line 3856 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6433 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6434 | const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); |
| 6435 | yyvsp[-1].ValIDVal.S.makeUnsigned(); |
| 6436 | yyval.InstVal.S.makeComposite(yyvsp[-2].PrimType.S); |
| 6437 | yyval.InstVal.I = new AllocaInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 6438 | delete yyvsp[-4].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6439 | ;} |
| 6440 | break; |
| 6441 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6442 | case 307: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6443 | #line 3863 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6444 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6445 | const Type *PTy = yyvsp[0].ValueVal.V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6446 | if (!isa<PointerType>(PTy)) |
| 6447 | error("Trying to free nonpointer type '" + PTy->getDescription() + "'"); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6448 | yyval.InstVal.I = new FreeInst(yyvsp[0].ValueVal.V); |
| 6449 | yyval.InstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6450 | ;} |
| 6451 | break; |
| 6452 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6453 | case 308: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6454 | #line 3870 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6455 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6456 | const Type* Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 6457 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6458 | if (!isa<PointerType>(Ty)) |
| 6459 | error("Can't load from nonpointer type: " + Ty->getDescription()); |
| 6460 | if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType()) |
| 6461 | error("Can't load from pointer of non-first-class type: " + |
| 6462 | Ty->getDescription()); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6463 | Value* tmpVal = getVal(Ty, yyvsp[0].ValIDVal); |
| 6464 | yyval.InstVal.I = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal); |
| 6465 | yyval.InstVal.S.copy(yyvsp[-1].TypeVal.S.get(0)); |
| 6466 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6467 | ;} |
| 6468 | break; |
| 6469 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6470 | case 309: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6471 | #line 3883 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6472 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6473 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
| 6474 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6475 | if (!PTy) |
| 6476 | error("Can't store to a nonpointer type: " + |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6477 | yyvsp[-1].TypeVal.PAT->get()->getDescription()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6478 | const Type *ElTy = PTy->getElementType(); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6479 | Value *StoreVal = yyvsp[-3].ValueVal.V; |
| 6480 | Value* tmpVal = getVal(PTy, yyvsp[0].ValIDVal); |
| 6481 | if (ElTy != yyvsp[-3].ValueVal.V->getType()) { |
| 6482 | StoreVal = handleSRetFuncTypeMerge(yyvsp[-3].ValueVal.V, ElTy); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6483 | if (!StoreVal) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6484 | error("Can't store '" + yyvsp[-3].ValueVal.V->getType()->getDescription() + |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6485 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 6486 | else { |
| 6487 | PTy = PointerType::get(StoreVal->getType()); |
| 6488 | if (Constant *C = dyn_cast<Constant>(tmpVal)) |
| 6489 | tmpVal = ConstantExpr::getBitCast(C, PTy); |
| 6490 | else |
| 6491 | tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB); |
| 6492 | } |
| 6493 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6494 | yyval.InstVal.I = new StoreInst(StoreVal, tmpVal, yyvsp[-5].BoolVal); |
| 6495 | yyval.InstVal.S.makeSignless(); |
| 6496 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6497 | ;} |
| 6498 | break; |
| 6499 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6500 | case 310: |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6501 | #line 3909 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6502 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6503 | yyvsp[-1].ValIDVal.S.copy(yyvsp[-2].TypeVal.S); |
| 6504 | const Type* Ty = yyvsp[-2].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6505 | if (!isa<PointerType>(Ty)) |
| 6506 | error("getelementptr insn requires pointer operand"); |
| 6507 | |
| 6508 | std::vector<Value*> VIndices; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6509 | upgradeGEPInstIndices(Ty, yyvsp[0].ValueList, VIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6510 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6511 | Value* tmpVal = getVal(Ty, yyvsp[-1].ValIDVal); |
| 6512 | yyval.InstVal.I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size()); |
| 6513 | ValueInfo VI; VI.V = tmpVal; VI.S.copy(yyvsp[-2].TypeVal.S); |
| 6514 | yyval.InstVal.S.copy(getElementSign(VI, VIndices)); |
| 6515 | delete yyvsp[-2].TypeVal.PAT; |
| 6516 | delete yyvsp[0].ValueList; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6517 | ;} |
| 6518 | break; |
| 6519 | |
| 6520 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6521 | } |
| 6522 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6523 | /* Line 993 of yacc.c. */ |
| 6524 | #line 6525 "UpgradeParser.tab.c" |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6525 | |
| 6526 | yyvsp -= yylen; |
| 6527 | yyssp -= yylen; |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 6528 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6529 | |
| 6530 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6531 | |
| 6532 | *++yyvsp = yyval; |
| 6533 | |
| 6534 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6535 | /* Now `shift' the result of the reduction. Determine what state |
| 6536 | that goes to, based on the state we popped back to and the rule |
| 6537 | number reduced by. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6538 | |
| 6539 | yyn = yyr1[yyn]; |
| 6540 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6541 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 6542 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6543 | yystate = yytable[yystate]; |
| 6544 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6545 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6546 | |
| 6547 | goto yynewstate; |
| 6548 | |
| 6549 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6550 | /*------------------------------------. |
| 6551 | | yyerrlab -- here on detecting error | |
| 6552 | `------------------------------------*/ |
| 6553 | yyerrlab: |
| 6554 | /* If not already recovering from an error, report this error. */ |
| 6555 | if (!yyerrstatus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6556 | { |
| 6557 | ++yynerrs; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6558 | #if YYERROR_VERBOSE |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6559 | yyn = yypact[yystate]; |
| 6560 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6561 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6562 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6563 | YYSIZE_T yysize = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6564 | int yytype = YYTRANSLATE (yychar); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6565 | const char* yyprefix; |
| 6566 | char *yymsg; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6567 | int yyx; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6568 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6569 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 6570 | YYCHECK. */ |
| 6571 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 6572 | |
| 6573 | /* Stay within bounds of both yycheck and yytname. */ |
| 6574 | int yychecklim = YYLAST - yyn; |
| 6575 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6576 | int yycount = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6577 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6578 | yyprefix = ", expecting "; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6579 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 6580 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 6581 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6582 | yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); |
| 6583 | yycount += 1; |
| 6584 | if (yycount == 5) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6585 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6586 | yysize = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6587 | break; |
| 6588 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6589 | } |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6590 | yysize += (sizeof ("syntax error, unexpected ") |
| 6591 | + yystrlen (yytname[yytype])); |
| 6592 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 6593 | if (yymsg != 0) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6594 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6595 | char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); |
| 6596 | yyp = yystpcpy (yyp, yytname[yytype]); |
| 6597 | |
| 6598 | if (yycount < 5) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6599 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6600 | yyprefix = ", expecting "; |
| 6601 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 6602 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 6603 | { |
| 6604 | yyp = yystpcpy (yyp, yyprefix); |
| 6605 | yyp = yystpcpy (yyp, yytname[yyx]); |
| 6606 | yyprefix = " or "; |
| 6607 | } |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6608 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6609 | yyerror (yymsg); |
| 6610 | YYSTACK_FREE (yymsg); |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6611 | } |
| 6612 | else |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6613 | yyerror ("syntax error; also virtual memory exhausted"); |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 6614 | } |
| 6615 | else |
| 6616 | #endif /* YYERROR_VERBOSE */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6617 | yyerror ("syntax error"); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6618 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6619 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6620 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6621 | |
| 6622 | if (yyerrstatus == 3) |
| 6623 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6624 | /* If just tried and failed to reuse lookahead token after an |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6625 | error, discard it. */ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6626 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6627 | if (yychar <= YYEOF) |
| 6628 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6629 | /* If at end of input, pop the error token, |
| 6630 | then the rest of the stack, then return failure. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6631 | if (yychar == YYEOF) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6632 | for (;;) |
| 6633 | { |
| 6634 | YYPOPSTACK; |
| 6635 | if (yyssp == yyss) |
| 6636 | YYABORT; |
| 6637 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); |
| 6638 | yydestruct (yystos[*yyssp], yyvsp); |
| 6639 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6640 | } |
| 6641 | else |
| 6642 | { |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6643 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); |
| 6644 | yydestruct (yytoken, &yylval); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6645 | yychar = YYEMPTY; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6646 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6647 | } |
| 6648 | } |
| 6649 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6650 | /* Else will try to reuse lookahead token after shifting the error |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6651 | token. */ |
| 6652 | goto yyerrlab1; |
| 6653 | |
| 6654 | |
| 6655 | /*---------------------------------------------------. |
| 6656 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 6657 | `---------------------------------------------------*/ |
| 6658 | yyerrorlab: |
| 6659 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6660 | #ifdef __GNUC__ |
| 6661 | /* Pacify GCC when the user code never invokes YYERROR and the label |
| 6662 | yyerrorlab therefore never appears in user code. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6663 | if (0) |
| 6664 | goto yyerrorlab; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6665 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6666 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6667 | yyvsp -= yylen; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6668 | yyssp -= yylen; |
| 6669 | yystate = *yyssp; |
| 6670 | goto yyerrlab1; |
| 6671 | |
| 6672 | |
| 6673 | /*-------------------------------------------------------------. |
| 6674 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 6675 | `-------------------------------------------------------------*/ |
| 6676 | yyerrlab1: |
| 6677 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 6678 | |
| 6679 | for (;;) |
| 6680 | { |
| 6681 | yyn = yypact[yystate]; |
| 6682 | if (yyn != YYPACT_NINF) |
| 6683 | { |
| 6684 | yyn += YYTERROR; |
| 6685 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 6686 | { |
| 6687 | yyn = yytable[yyn]; |
| 6688 | if (0 < yyn) |
| 6689 | break; |
| 6690 | } |
| 6691 | } |
| 6692 | |
| 6693 | /* Pop the current state because it cannot handle the error token. */ |
| 6694 | if (yyssp == yyss) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6695 | YYABORT; |
| 6696 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6697 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); |
| 6698 | yydestruct (yystos[yystate], yyvsp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6699 | YYPOPSTACK; |
| 6700 | yystate = *yyssp; |
| 6701 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6702 | } |
| 6703 | |
| 6704 | if (yyn == YYFINAL) |
| 6705 | YYACCEPT; |
| 6706 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6707 | YYDPRINTF ((stderr, "Shifting error token, ")); |
| 6708 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6709 | *++yyvsp = yylval; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6710 | |
| 6711 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6712 | yystate = yyn; |
| 6713 | goto yynewstate; |
| 6714 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6715 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6716 | /*-------------------------------------. |
| 6717 | | yyacceptlab -- YYACCEPT comes here. | |
| 6718 | `-------------------------------------*/ |
| 6719 | yyacceptlab: |
| 6720 | yyresult = 0; |
| 6721 | goto yyreturn; |
| 6722 | |
| 6723 | /*-----------------------------------. |
| 6724 | | yyabortlab -- YYABORT comes here. | |
| 6725 | `-----------------------------------*/ |
| 6726 | yyabortlab: |
| 6727 | yyresult = 1; |
| 6728 | goto yyreturn; |
| 6729 | |
| 6730 | #ifndef yyoverflow |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6731 | /*----------------------------------------------. |
| 6732 | | yyoverflowlab -- parser overflow comes here. | |
| 6733 | `----------------------------------------------*/ |
| 6734 | yyoverflowlab: |
| 6735 | yyerror ("parser stack overflow"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6736 | yyresult = 2; |
| 6737 | /* Fall through. */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6738 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6739 | |
| 6740 | yyreturn: |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6741 | #ifndef yyoverflow |
| 6742 | if (yyss != yyssa) |
| 6743 | YYSTACK_FREE (yyss); |
| 6744 | #endif |
| 6745 | return yyresult; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6746 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6747 | |
| 6748 | |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame^] | 6749 | #line 3927 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6750 | |
| 6751 | |
| 6752 | int yyerror(const char *ErrorMsg) { |
| 6753 | std::string where |
| 6754 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6755 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6756 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 6757 | if (yychar != YYEMPTY && yychar != 0) |
| 6758 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6759 | "'."; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 6760 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6761 | std::cout << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6762 | exit(1); |
| 6763 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6764 | |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 6765 | void warning(const std::string& ErrorMsg) { |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6766 | std::string where |
| 6767 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6768 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6769 | std::string errMsg = where + "warning: " + std::string(ErrorMsg); |
| 6770 | if (yychar != YYEMPTY && yychar != 0) |
| 6771 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6772 | "'."; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6773 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
| 6774 | } |
| 6775 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6776 | void error(const std::string& ErrorMsg, int LineNo) { |
| 6777 | if (LineNo == -1) LineNo = Upgradelineno; |
| 6778 | Upgradelineno = LineNo; |
| 6779 | yyerror(ErrorMsg.c_str()); |
| 6780 | } |
| 6781 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6782 | |