David Greene | 5fd22a8 | 2007-09-04 18:46:50 +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 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3 | /* Skeleton parser for Yacc-like parsing with Bison, |
| 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 | 5fd22a8 | 2007-09-04 18:46:50 +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 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 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. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 25 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 26 | /* Written by Richard Stallman by simplifying the original so called |
| 27 | ``semantic'' parser. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 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 | 5fd22a8 | 2007-09-04 18:46:50 +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 | 5fd22a8 | 2007-09-04 18:46:50 +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; |
Reid Spencer | 8166a6c | 2007-04-02 02:08:35 +0000 | [diff] [blame] | 1832 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1833 | case 'v' : { |
| 1834 | const Type* PtrTy = PointerType::get(Type::Int8Ty); |
| 1835 | std::vector<const Type*> Params; |
| 1836 | if (Name == "llvm.va_start" || Name == "llvm.va_end") { |
| 1837 | if (Args.size() != 1) |
| 1838 | error("Invalid prototype for " + Name + " prototype"); |
| 1839 | Params.push_back(PtrTy); |
| 1840 | const FunctionType *FTy = |
| 1841 | FunctionType::get(Type::VoidTy, Params, false); |
| 1842 | const PointerType *PFTy = PointerType::get(FTy); |
| 1843 | Value* Func = getVal(PFTy, ID); |
| 1844 | Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 1845 | return new CallInst(Func, Args.begin(), Args.end()); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1846 | } else if (Name == "llvm.va_copy") { |
| 1847 | if (Args.size() != 2) |
| 1848 | error("Invalid prototype for " + Name + " prototype"); |
| 1849 | Params.push_back(PtrTy); |
| 1850 | Params.push_back(PtrTy); |
| 1851 | const FunctionType *FTy = |
| 1852 | FunctionType::get(Type::VoidTy, Params, false); |
| 1853 | const PointerType *PFTy = PointerType::get(FTy); |
| 1854 | Value* Func = getVal(PFTy, ID); |
| 1855 | std::string InstName0(makeNameUnique("va0")); |
| 1856 | std::string InstName1(makeNameUnique("va1")); |
| 1857 | Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB); |
| 1858 | Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 1859 | return new CallInst(Func, Args.begin(), Args.end()); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1860 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1861 | } |
| 1862 | } |
| 1863 | return 0; |
| 1864 | } |
| 1865 | |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1866 | const Type* upgradeGEPCEIndices(const Type* PTy, |
| 1867 | std::vector<ValueInfo> *Indices, |
| 1868 | std::vector<Constant*> &Result) { |
| 1869 | const Type *Ty = PTy; |
| 1870 | Result.clear(); |
| 1871 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1872 | Constant *Index = cast<Constant>((*Indices)[i].V); |
| 1873 | |
| 1874 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1875 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1876 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1877 | if (CI->getBitWidth() < 32) |
| 1878 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1879 | } |
| 1880 | |
| 1881 | if (isa<SequentialType>(Ty)) { |
| 1882 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1883 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1884 | // all indices for SequentialType elements. We must retain the same |
| 1885 | // semantic (zext) for unsigned types. |
| 1886 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
| 1887 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
| 1888 | Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty); |
| 1889 | } |
| 1890 | } |
| 1891 | } |
| 1892 | Result.push_back(Index); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 1893 | Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(), |
| 1894 | Result.end(),true); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1895 | if (!Ty) |
| 1896 | error("Index list invalid for constant getelementptr"); |
| 1897 | } |
| 1898 | return Ty; |
| 1899 | } |
| 1900 | |
| 1901 | const Type* upgradeGEPInstIndices(const Type* PTy, |
| 1902 | std::vector<ValueInfo> *Indices, |
| 1903 | std::vector<Value*> &Result) { |
| 1904 | const Type *Ty = PTy; |
| 1905 | Result.clear(); |
| 1906 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1907 | Value *Index = (*Indices)[i].V; |
| 1908 | |
| 1909 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1910 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1911 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1912 | if (CI->getBitWidth() < 32) |
| 1913 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1914 | } |
| 1915 | |
| 1916 | |
| 1917 | if (isa<StructType>(Ty)) { // Only change struct indices |
| 1918 | if (!isa<Constant>(Index)) { |
| 1919 | error("Invalid non-constant structure index"); |
| 1920 | return 0; |
| 1921 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1922 | } else { |
| 1923 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1924 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1925 | // all indices for SequentialType elements. We must retain the same |
| 1926 | // semantic (zext) for unsigned types. |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1927 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1928 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1929 | if (isa<Constant>(Index)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1930 | Index = ConstantExpr::getCast(Instruction::ZExt, |
| 1931 | cast<Constant>(Index), Type::Int64Ty); |
| 1932 | else |
| 1933 | Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty, |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1934 | makeNameUnique("gep"), CurBB); |
Reid Spencer | 38f682b | 2007-01-26 20:31:18 +0000 | [diff] [blame] | 1935 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1936 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1937 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1938 | Result.push_back(Index); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 1939 | Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(), |
| 1940 | Result.end(),true); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1941 | if (!Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1942 | error("Index list invalid for constant getelementptr"); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1943 | } |
| 1944 | return Ty; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1945 | } |
| 1946 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 1947 | unsigned upgradeCallingConv(unsigned CC) { |
| 1948 | switch (CC) { |
| 1949 | case OldCallingConv::C : return CallingConv::C; |
| 1950 | case OldCallingConv::CSRet : return CallingConv::C; |
| 1951 | case OldCallingConv::Fast : return CallingConv::Fast; |
| 1952 | case OldCallingConv::Cold : return CallingConv::Cold; |
| 1953 | case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall; |
| 1954 | case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall; |
| 1955 | default: |
| 1956 | return CC; |
| 1957 | } |
| 1958 | } |
| 1959 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1960 | Module* UpgradeAssembly(const std::string &infile, std::istream& in, |
| 1961 | bool debug, bool addAttrs) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1962 | { |
| 1963 | Upgradelineno = 1; |
| 1964 | CurFilename = infile; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 1965 | LexInput = ∈ |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1966 | yydebug = debug; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 1967 | AddAttributes = addAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1968 | ObsoleteVarArgs = false; |
| 1969 | NewVarArgs = false; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1970 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1971 | CurModule.CurrentModule = new Module(CurFilename); |
| 1972 | |
| 1973 | // Check to make sure the parser succeeded |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1974 | if (yyparse()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1975 | if (ParserResult) |
| 1976 | delete ParserResult; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1977 | std::cerr << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1978 | return 0; |
| 1979 | } |
| 1980 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1981 | // Check to make sure that parsing produced a result |
| 1982 | if (!ParserResult) { |
| 1983 | std::cerr << "llvm-upgrade: no parse result.\n"; |
| 1984 | return 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1985 | } |
| 1986 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1987 | // Reset ParserResult variable while saving its value for the result. |
| 1988 | Module *Result = ParserResult; |
| 1989 | ParserResult = 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1990 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1991 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1992 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1993 | Function* F; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1994 | if ((F = Result->getFunction("llvm.va_start")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1995 | && F->getFunctionType()->getNumParams() == 0) |
| 1996 | ObsoleteVarArgs = true; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1997 | if((F = Result->getFunction("llvm.va_copy")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1998 | && F->getFunctionType()->getNumParams() == 1) |
| 1999 | ObsoleteVarArgs = true; |
Reid Spencer | 280d801 | 2006-12-01 23:40:53 +0000 | [diff] [blame] | 2000 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2001 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2002 | if (ObsoleteVarArgs && NewVarArgs) { |
| 2003 | error("This file is corrupt: it uses both new and old style varargs"); |
| 2004 | return 0; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2005 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2006 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2007 | if(ObsoleteVarArgs) { |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2008 | if(Function* F = Result->getFunction("llvm.va_start")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2009 | if (F->arg_size() != 0) { |
| 2010 | error("Obsolete va_start takes 0 argument"); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2011 | return 0; |
| 2012 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2013 | |
| 2014 | //foo = va_start() |
| 2015 | // -> |
| 2016 | //bar = alloca typeof(foo) |
| 2017 | //va_start(bar) |
| 2018 | //foo = load bar |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2019 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2020 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2021 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2022 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2023 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2024 | "llvm.va_start", RetTy, ArgTyPtr, (Type *)0)); |
| 2025 | |
| 2026 | while (!F->use_empty()) { |
| 2027 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2028 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 2029 | new CallInst(NF, bar, "", CI); |
| 2030 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 2031 | CI->replaceAllUsesWith(foo); |
| 2032 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2033 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2034 | Result->getFunctionList().erase(F); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2035 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2036 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2037 | if(Function* F = Result->getFunction("llvm.va_end")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2038 | if(F->arg_size() != 1) { |
| 2039 | error("Obsolete va_end takes 1 argument"); |
| 2040 | return 0; |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2041 | } |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2042 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2043 | //vaend foo |
| 2044 | // -> |
| 2045 | //bar = alloca 1 of typeof(foo) |
| 2046 | //vaend bar |
| 2047 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2048 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 2049 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2050 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2051 | "llvm.va_end", RetTy, ArgTyPtr, (Type *)0)); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 2052 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2053 | while (!F->use_empty()) { |
| 2054 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 2055 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 2056 | new StoreInst(CI->getOperand(1), bar, CI); |
| 2057 | new CallInst(NF, bar, "", CI); |
| 2058 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2059 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2060 | Result->getFunctionList().erase(F); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2061 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2062 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 2063 | if(Function* F = Result->getFunction("llvm.va_copy")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2064 | if(F->arg_size() != 1) { |
| 2065 | error("Obsolete va_copy takes 1 argument"); |
| 2066 | return 0; |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2067 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2068 | //foo = vacopy(bar) |
| 2069 | // -> |
| 2070 | //a = alloca 1 of typeof(foo) |
| 2071 | //b = alloca 1 of typeof(foo) |
| 2072 | //store bar -> b |
| 2073 | //vacopy(a, b) |
| 2074 | //foo = load a |
| 2075 | |
| 2076 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 2077 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 2078 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 2079 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 2080 | "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0)); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 2081 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2082 | while (!F->use_empty()) { |
| 2083 | CallInst* CI = cast<CallInst>(F->use_back()); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2084 | Value *Args[2] = { |
| 2085 | new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI), |
| 2086 | new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI) |
| 2087 | }; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 2088 | new StoreInst(CI->getOperand(1), Args[1], CI); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2089 | new CallInst(NF, Args, Args + 2, "", CI); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 2090 | Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2091 | CI->replaceAllUsesWith(foo); |
| 2092 | CI->getParent()->getInstList().erase(CI); |
| 2093 | } |
| 2094 | Result->getFunctionList().erase(F); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2095 | } |
| 2096 | } |
| 2097 | |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 2098 | return Result; |
| 2099 | } |
| 2100 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2101 | } // end llvm namespace |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 2102 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2103 | using namespace llvm; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 2104 | |
| 2105 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2106 | |
| 2107 | /* Enabling traces. */ |
| 2108 | #ifndef YYDEBUG |
| 2109 | # define YYDEBUG 0 |
| 2110 | #endif |
| 2111 | |
| 2112 | /* Enabling verbose error messages. */ |
| 2113 | #ifdef YYERROR_VERBOSE |
| 2114 | # undef YYERROR_VERBOSE |
| 2115 | # define YYERROR_VERBOSE 1 |
| 2116 | #else |
| 2117 | # define YYERROR_VERBOSE 0 |
| 2118 | #endif |
| 2119 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2120 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
| 2121 | #line 1750 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 2122 | typedef union YYSTYPE { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2123 | llvm::Module *ModuleVal; |
| 2124 | llvm::Function *FunctionVal; |
| 2125 | std::pair<llvm::PATypeInfo, char*> *ArgVal; |
| 2126 | llvm::BasicBlock *BasicBlockVal; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 2127 | llvm::TermInstInfo TermInstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2128 | llvm::InstrInfo InstVal; |
| 2129 | llvm::ConstInfo ConstVal; |
| 2130 | llvm::ValueInfo ValueVal; |
| 2131 | llvm::PATypeInfo TypeVal; |
| 2132 | llvm::TypeInfo PrimType; |
| 2133 | llvm::PHIListInfo PHIList; |
| 2134 | std::list<llvm::PATypeInfo> *TypeList; |
| 2135 | std::vector<llvm::ValueInfo> *ValueList; |
| 2136 | std::vector<llvm::ConstInfo> *ConstVector; |
| 2137 | |
| 2138 | |
| 2139 | std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList; |
| 2140 | // Represent the RHS of PHI node |
| 2141 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 2142 | |
| 2143 | llvm::GlobalValue::LinkageTypes Linkage; |
| 2144 | int64_t SInt64Val; |
| 2145 | uint64_t UInt64Val; |
| 2146 | int SIntVal; |
| 2147 | unsigned UIntVal; |
| 2148 | double FPVal; |
| 2149 | bool BoolVal; |
| 2150 | |
| 2151 | char *StrVal; // This memory is strdup'd! |
| 2152 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 2153 | |
| 2154 | llvm::BinaryOps BinaryOpVal; |
| 2155 | llvm::TermOps TermOpVal; |
| 2156 | llvm::MemoryOps MemOpVal; |
| 2157 | llvm::OtherOps OtherOpVal; |
| 2158 | llvm::CastOps CastOpVal; |
| 2159 | llvm::ICmpInst::Predicate IPred; |
| 2160 | llvm::FCmpInst::Predicate FPred; |
| 2161 | llvm::Module::Endianness Endianness; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2162 | } YYSTYPE; |
| 2163 | /* Line 191 of yacc.c. */ |
| 2164 | #line 2165 "UpgradeParser.tab.c" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2165 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 2166 | # define YYSTYPE_IS_DECLARED 1 |
| 2167 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2168 | #endif |
| 2169 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2170 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2171 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2172 | /* Copy the second part of user declarations. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2173 | |
| 2174 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2175 | /* Line 214 of yacc.c. */ |
| 2176 | #line 2177 "UpgradeParser.tab.c" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2177 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2178 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2179 | |
| 2180 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 2181 | |
| 2182 | # ifdef YYSTACK_USE_ALLOCA |
| 2183 | # if YYSTACK_USE_ALLOCA |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2184 | # define YYSTACK_ALLOC alloca |
| 2185 | # endif |
| 2186 | # else |
| 2187 | # if defined (alloca) || defined (_ALLOCA_H) |
| 2188 | # define YYSTACK_ALLOC alloca |
| 2189 | # else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2190 | # ifdef __GNUC__ |
| 2191 | # define YYSTACK_ALLOC __builtin_alloca |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2192 | # endif |
| 2193 | # endif |
| 2194 | # endif |
| 2195 | |
| 2196 | # ifdef YYSTACK_ALLOC |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2197 | /* Pacify GCC's `empty if-body' warning. */ |
| 2198 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2199 | # else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2200 | # if defined (__STDC__) || defined (__cplusplus) |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2201 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2202 | # define YYSIZE_T size_t |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 2203 | # endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2204 | # define YYSTACK_ALLOC malloc |
| 2205 | # define YYSTACK_FREE free |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2206 | # endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2207 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2208 | |
| 2209 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2210 | #if (! defined (yyoverflow) \ |
| 2211 | && (! defined (__cplusplus) \ |
| 2212 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2213 | |
| 2214 | /* A type that is properly aligned for any stack member. */ |
| 2215 | union yyalloc |
| 2216 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2217 | short yyss; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2218 | YYSTYPE yyvs; |
| 2219 | }; |
| 2220 | |
| 2221 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 2222 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 2223 | |
| 2224 | /* The size of an array large to enough to hold all stacks, each with |
| 2225 | N elements. */ |
| 2226 | # define YYSTACK_BYTES(N) \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2227 | ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2228 | + YYSTACK_GAP_MAXIMUM) |
| 2229 | |
| 2230 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 2231 | not overlap. */ |
| 2232 | # ifndef YYCOPY |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2233 | # if defined (__GNUC__) && 1 < __GNUC__ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2234 | # define YYCOPY(To, From, Count) \ |
| 2235 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 2236 | # else |
| 2237 | # define YYCOPY(To, From, Count) \ |
| 2238 | do \ |
| 2239 | { \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2240 | register YYSIZE_T yyi; \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2241 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 2242 | (To)[yyi] = (From)[yyi]; \ |
| 2243 | } \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2244 | while (0) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2245 | # endif |
| 2246 | # endif |
| 2247 | |
| 2248 | /* Relocate STACK from its old location to the new one. The |
| 2249 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 2250 | elements in the stack, and YYPTR gives the new location of the |
| 2251 | stack. Advance YYPTR to a properly aligned location for the next |
| 2252 | stack. */ |
| 2253 | # define YYSTACK_RELOCATE(Stack) \ |
| 2254 | do \ |
| 2255 | { \ |
| 2256 | YYSIZE_T yynewbytes; \ |
| 2257 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 2258 | Stack = &yyptr->Stack; \ |
| 2259 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 2260 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 2261 | } \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2262 | while (0) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2263 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2264 | #endif |
| 2265 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2266 | #if defined (__STDC__) || defined (__cplusplus) |
| 2267 | typedef signed char yysigned_char; |
| 2268 | #else |
| 2269 | typedef short yysigned_char; |
| 2270 | #endif |
| 2271 | |
| 2272 | /* YYFINAL -- State number of the termination state. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2273 | #define YYFINAL 4 |
| 2274 | /* YYLAST -- Last index in YYTABLE. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2275 | #define YYLAST 1630 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2276 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2277 | /* YYNTOKENS -- Number of terminals. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2278 | #define YYNTOKENS 166 |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2279 | /* YYNNTS -- Number of nonterminals. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2280 | #define YYNNTS 81 |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2281 | /* YYNRULES -- Number of rules. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2282 | #define YYNRULES 310 |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2283 | /* YYNRULES -- Number of states. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2284 | #define YYNSTATES 606 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2285 | |
| 2286 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 2287 | #define YYUNDEFTOK 2 |
| 2288 | #define YYMAXUTOK 406 |
| 2289 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2290 | #define YYTRANSLATE(YYX) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2291 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 2292 | |
| 2293 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2294 | static const unsigned char yytranslate[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2295 | { |
| 2296 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2297 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2298 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2299 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2300 | 155, 156, 164, 2, 153, 2, 2, 2, 2, 2, |
| 2301 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2302 | 160, 152, 161, 2, 2, 2, 2, 2, 2, 2, |
| 2303 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2304 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2305 | 2, 157, 154, 159, 2, 2, 2, 2, 2, 165, |
| 2306 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2307 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2308 | 158, 2, 2, 162, 2, 163, 2, 2, 2, 2, |
| 2309 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2310 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2311 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2312 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2313 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2314 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2315 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2316 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2317 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2318 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2319 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2320 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2321 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 2322 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 2323 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 2324 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 2325 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 2326 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 2327 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 2328 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 2329 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2330 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2331 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2332 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 2333 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2334 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
| 2335 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 2336 | 145, 146, 147, 148, 149, 150, 151 |
| 2337 | }; |
| 2338 | |
| 2339 | #if YYDEBUG |
| 2340 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 2341 | YYRHS. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2342 | static const unsigned short yyprhs[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2343 | { |
| 2344 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 2345 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 2346 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 2347 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 2348 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 2349 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 2350 | 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, |
| 2351 | 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, |
| 2352 | 159, 161, 164, 165, 167, 169, 171, 173, 175, 177, |
| 2353 | 179, 180, 181, 183, 185, 187, 189, 191, 193, 196, |
| 2354 | 197, 200, 201, 205, 208, 209, 211, 212, 216, 218, |
| 2355 | 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, |
| 2356 | 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, |
| 2357 | 261, 264, 269, 275, 281, 285, 288, 294, 299, 302, |
| 2358 | 304, 308, 310, 314, 316, 317, 322, 326, 330, 335, |
| 2359 | 340, 344, 351, 357, 360, 363, 366, 369, 372, 375, |
| 2360 | 378, 381, 384, 387, 394, 400, 409, 416, 423, 430, |
| 2361 | 438, 446, 453, 460, 469, 478, 482, 484, 486, 488, |
| 2362 | 490, 493, 496, 501, 504, 506, 511, 514, 519, 520, |
| 2363 | 528, 529, 537, 538, 546, 547, 555, 559, 564, 565, |
| 2364 | 567, 569, 571, 575, 579, 583, 587, 591, 595, 597, |
| 2365 | 598, 600, 602, 604, 605, 608, 612, 614, 616, 620, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2366 | 622, 623, 632, 634, 636, 637, 642, 644, 646, 649, |
| 2367 | 650, 652, 654, 655, 656, 662, 663, 665, 667, 669, |
| 2368 | 671, 673, 675, 677, 679, 681, 685, 687, 693, 695, |
| 2369 | 697, 699, 701, 704, 707, 710, 714, 717, 718, 720, |
| 2370 | 722, 724, 727, 730, 734, 744, 754, 763, 777, 779, |
| 2371 | 781, 788, 794, 797, 804, 812, 814, 818, 820, 821, |
| 2372 | 824, 826, 832, 838, 844, 851, 858, 861, 866, 871, |
| 2373 | 878, 883, 888, 893, 898, 905, 912, 915, 923, 925, |
| 2374 | 928, 929, 931, 932, 936, 943, 947, 954, 957, 962, |
| 2375 | 969 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2376 | }; |
| 2377 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2378 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 2379 | static const short yyrhs[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2380 | { |
| 2381 | 200, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
| 2382 | -1, 79, -1, 80, -1, 81, -1, 82, -1, 83, |
| 2383 | -1, 84, -1, 85, -1, 86, -1, 87, -1, 88, |
| 2384 | -1, 89, -1, 90, -1, 91, -1, 92, -1, 97, |
| 2385 | -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, |
| 2386 | -1, 119, -1, 120, -1, 121, -1, 122, -1, 123, |
| 2387 | -1, 124, -1, 125, -1, 126, -1, 127, -1, 128, |
| 2388 | -1, 129, -1, 130, -1, 131, -1, 132, -1, 133, |
| 2389 | -1, 134, -1, 135, -1, 136, -1, 137, -1, 138, |
| 2390 | -1, 125, -1, 126, -1, 127, -1, 128, -1, 27, |
| 2391 | -1, 28, -1, 93, -1, 94, -1, 95, -1, 96, |
| 2392 | -1, 140, -1, 141, -1, 142, -1, 143, -1, 144, |
| 2393 | -1, 145, -1, 146, -1, 147, -1, 148, -1, 149, |
| 2394 | -1, 150, -1, 151, -1, 139, -1, 16, -1, 14, |
| 2395 | -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, |
| 2396 | -1, 11, -1, 176, -1, 177, -1, 18, -1, 19, |
| 2397 | -1, 212, 152, -1, -1, 41, -1, 42, -1, 43, |
| 2398 | -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, |
| 2399 | -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, |
| 2400 | -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, |
| 2401 | -1, 153, 57, 4, -1, 34, 24, -1, -1, 185, |
| 2402 | -1, -1, 153, 188, 187, -1, 185, -1, 57, 4, |
| 2403 | -1, 191, -1, 8, -1, 193, -1, 8, -1, 193, |
| 2404 | -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, |
| 2405 | -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2406 | -1, 19, -1, 21, -1, 192, -1, 48, -1, 229, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2407 | -1, 154, 4, -1, 190, 155, 195, 156, -1, 157, |
| 2408 | 4, 158, 193, 159, -1, 160, 4, 158, 193, 161, |
| 2409 | -1, 162, 194, 163, -1, 162, 163, -1, 160, 162, |
| 2410 | 194, 163, 161, -1, 160, 162, 163, 161, -1, 193, |
| 2411 | 164, -1, 193, -1, 194, 153, 193, -1, 194, -1, |
| 2412 | 194, 153, 37, -1, 37, -1, -1, 191, 157, 198, |
| 2413 | 159, -1, 191, 157, 159, -1, 191, 165, 24, -1, |
| 2414 | 191, 160, 198, 161, -1, 191, 162, 198, 163, -1, |
| 2415 | 191, 162, 163, -1, 191, 160, 162, 198, 163, 161, |
| 2416 | -1, 191, 160, 162, 163, 161, -1, 191, 38, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2417 | 191, 39, -1, 191, 229, -1, 191, 197, -1, 191, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2418 | 26, -1, 176, 168, -1, 177, 4, -1, 9, 27, |
| 2419 | -1, 9, 28, -1, 179, 7, -1, 175, 155, 196, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2420 | 36, 191, 156, -1, 110, 155, 196, 244, 156, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2421 | 112, 155, 196, 153, 196, 153, 196, 156, -1, 169, |
| 2422 | 155, 196, 153, 196, 156, -1, 170, 155, 196, 153, |
| 2423 | 196, 156, -1, 171, 155, 196, 153, 196, 156, -1, |
| 2424 | 103, 172, 155, 196, 153, 196, 156, -1, 104, 173, |
| 2425 | 155, 196, 153, 196, 156, -1, 174, 155, 196, 153, |
| 2426 | 196, 156, -1, 114, 155, 196, 153, 196, 156, -1, |
| 2427 | 115, 155, 196, 153, 196, 153, 196, 156, -1, 116, |
| 2428 | 155, 196, 153, 196, 153, 196, 156, -1, 198, 153, |
| 2429 | 196, -1, 196, -1, 32, -1, 33, -1, 201, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2430 | 201, 222, -1, 201, 224, -1, 201, 62, 61, 207, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2431 | -1, 201, 25, -1, 202, -1, 202, 180, 20, 189, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2432 | -1, 202, 224, -1, 202, 62, 61, 207, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2433 | 202, 180, 181, 199, 196, 203, 187, -1, -1, 202, |
| 2434 | 180, 50, 199, 191, 204, 187, -1, -1, 202, 180, |
| 2435 | 45, 199, 191, 205, 187, -1, -1, 202, 180, 47, |
| 2436 | 199, 191, 206, 187, -1, 202, 51, 209, -1, 202, |
| 2437 | 58, 152, 210, -1, -1, 24, -1, 56, -1, 55, |
| 2438 | -1, 53, 152, 208, -1, 54, 152, 4, -1, 52, |
| 2439 | 152, 24, -1, 71, 152, 24, -1, 157, 211, 159, |
| 2440 | -1, 211, 153, 24, -1, 24, -1, -1, 22, -1, |
| 2441 | 24, -1, 212, -1, -1, 191, 213, -1, 215, 153, |
| 2442 | 214, -1, 214, -1, 215, -1, 215, 153, 37, -1, |
| 2443 | 37, -1, -1, 182, 189, 212, 155, 216, 156, 186, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2444 | 183, -1, 29, -1, 162, -1, -1, 181, 220, 217, |
| 2445 | 218, -1, 30, -1, 163, -1, 232, 221, -1, -1, |
| 2446 | 45, -1, 47, -1, -1, -1, 31, 225, 223, 226, |
| 2447 | 217, -1, -1, 63, -1, 3, -1, 4, -1, 7, |
| 2448 | -1, 27, -1, 28, -1, 38, -1, 39, -1, 26, |
| 2449 | -1, 160, 198, 161, -1, 197, -1, 61, 227, 24, |
| 2450 | 153, 24, -1, 167, -1, 212, -1, 229, -1, 228, |
| 2451 | -1, 191, 230, -1, 232, 233, -1, 219, 233, -1, |
| 2452 | 234, 180, 236, -1, 234, 238, -1, -1, 23, -1, |
| 2453 | 77, -1, 78, -1, 72, 231, -1, 72, 8, -1, |
| 2454 | 73, 21, 230, -1, 73, 9, 230, 153, 21, 230, |
| 2455 | 153, 21, 230, -1, 74, 178, 230, 153, 21, 230, |
| 2456 | 157, 237, 159, -1, 74, 178, 230, 153, 21, 230, |
| 2457 | 157, 159, -1, 75, 182, 189, 230, 155, 241, 156, |
| 2458 | 36, 21, 230, 235, 21, 230, -1, 235, -1, 76, |
| 2459 | -1, 237, 178, 228, 153, 21, 230, -1, 178, 228, |
| 2460 | 153, 21, 230, -1, 180, 243, -1, 191, 157, 230, |
| 2461 | 153, 230, 159, -1, 239, 153, 157, 230, 153, 230, |
| 2462 | 159, -1, 231, -1, 240, 153, 231, -1, 240, -1, |
| 2463 | -1, 60, 59, -1, 59, -1, 169, 191, 230, 153, |
| 2464 | 230, -1, 170, 191, 230, 153, 230, -1, 171, 191, |
| 2465 | 230, 153, 230, -1, 103, 172, 191, 230, 153, 230, |
| 2466 | -1, 104, 173, 191, 230, 153, 230, -1, 49, 231, |
| 2467 | -1, 174, 231, 153, 231, -1, 175, 231, 36, 191, |
| 2468 | -1, 112, 231, 153, 231, 153, 231, -1, 113, 231, |
| 2469 | 153, 191, -1, 117, 231, 153, 191, -1, 118, 231, |
| 2470 | 153, 191, -1, 114, 231, 153, 231, -1, 115, 231, |
| 2471 | 153, 231, 153, 231, -1, 116, 231, 153, 231, 153, |
| 2472 | 231, -1, 111, 239, -1, 242, 182, 189, 230, 155, |
| 2473 | 241, 156, -1, 246, -1, 153, 240, -1, -1, 35, |
| 2474 | -1, -1, 105, 191, 184, -1, 105, 191, 153, 15, |
| 2475 | 230, 184, -1, 106, 191, 184, -1, 106, 191, 153, |
| 2476 | 15, 230, 184, -1, 107, 231, -1, 245, 108, 191, |
| 2477 | 230, -1, 245, 109, 231, 153, 191, 230, -1, 110, |
| 2478 | 191, 230, 244, -1 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2479 | }; |
| 2480 | |
| 2481 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2482 | static const unsigned short yyrline[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2483 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2484 | 0, 1890, 1890, 1891, 1899, 1900, 1910, 1910, 1910, 1910, |
| 2485 | 1910, 1910, 1910, 1910, 1910, 1910, 1910, 1914, 1914, 1914, |
| 2486 | 1918, 1918, 1918, 1918, 1918, 1918, 1922, 1922, 1923, 1923, |
| 2487 | 1924, 1924, 1925, 1925, 1926, 1926, 1930, 1930, 1931, 1931, |
| 2488 | 1932, 1932, 1933, 1933, 1934, 1934, 1935, 1935, 1936, 1936, |
| 2489 | 1937, 1938, 1941, 1941, 1941, 1941, 1945, 1945, 1945, 1945, |
| 2490 | 1945, 1945, 1945, 1946, 1946, 1946, 1946, 1946, 1946, 1952, |
| 2491 | 1952, 1952, 1952, 1956, 1956, 1956, 1956, 1960, 1960, 1964, |
| 2492 | 1964, 1969, 1972, 1977, 1978, 1979, 1980, 1981, 1982, 1983, |
| 2493 | 1984, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 2005, |
| 2494 | 2006, 2014, 2015, 2023, 2032, 2033, 2040, 2041, 2045, 2049, |
| 2495 | 2065, 2066, 2073, 2074, 2081, 2089, 2089, 2089, 2089, 2089, |
| 2496 | 2089, 2089, 2090, 2090, 2090, 2090, 2090, 2095, 2099, 2103, |
| 2497 | 2108, 2117, 2144, 2150, 2163, 2174, 2178, 2191, 2195, 2209, |
| 2498 | 2213, 2220, 2221, 2227, 2234, 2246, 2276, 2289, 2312, 2340, |
| 2499 | 2362, 2373, 2395, 2406, 2415, 2420, 2479, 2486, 2494, 2501, |
| 2500 | 2508, 2512, 2516, 2525, 2540, 2552, 2561, 2589, 2602, 2611, |
| 2501 | 2617, 2623, 2634, 2640, 2646, 2657, 2658, 2667, 2668, 2680, |
| 2502 | 2689, 2690, 2691, 2692, 2693, 2709, 2729, 2731, 2733, 2733, |
| 2503 | 2740, 2740, 2748, 2748, 2756, 2756, 2765, 2767, 2769, 2774, |
| 2504 | 2788, 2789, 2793, 2796, 2804, 2808, 2815, 2819, 2823, 2827, |
| 2505 | 2835, 2835, 2839, 2840, 2844, 2852, 2857, 2865, 2866, 2873, |
| 2506 | 2880, 2884, 3074, 3074, 3078, 3078, 3088, 3088, 3092, 3097, |
| 2507 | 3098, 3099, 3103, 3104, 3103, 3116, 3117, 3122, 3123, 3124, |
| 2508 | 3125, 3129, 3133, 3134, 3135, 3136, 3157, 3161, 3175, 3176, |
| 2509 | 3181, 3181, 3189, 3199, 3202, 3211, 3222, 3227, 3236, 3247, |
| 2510 | 3247, 3250, 3254, 3258, 3263, 3273, 3291, 3300, 3374, 3378, |
| 2511 | 3385, 3397, 3412, 3442, 3452, 3462, 3466, 3473, 3474, 3478, |
| 2512 | 3481, 3487, 3506, 3524, 3540, 3554, 3568, 3579, 3597, 3606, |
| 2513 | 3615, 3622, 3643, 3667, 3673, 3679, 3685, 3701, 3794, 3802, |
| 2514 | 3803, 3807, 3808, 3812, 3818, 3825, 3831, 3838, 3845, 3858, |
| 2515 | 3884 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2516 | }; |
| 2517 | #endif |
| 2518 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2519 | #if YYDEBUG || YYERROR_VERBOSE |
| 2520 | /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 2521 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2522 | static const char *const yytname[] = |
| 2523 | { |
| 2524 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 2525 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 2526 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 2527 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 2528 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 2529 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 2530 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 2531 | "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 2532 | "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", |
| 2533 | "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", |
| 2534 | "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", |
| 2535 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 2536 | "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT", |
| 2537 | "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM", |
| 2538 | "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR", |
| 2539 | "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP", |
| 2540 | "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", |
| 2541 | "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", |
| 2542 | "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", |
| 2543 | "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", |
| 2544 | "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", |
| 2545 | "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR", |
| 2546 | "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", |
| 2547 | "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL", |
| 2548 | "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates", |
| 2549 | "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType", |
| 2550 | "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", |
| 2551 | "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes", |
| 2552 | "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", |
| 2553 | "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", |
| 2554 | "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", |
| 2555 | "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition", |
| 2556 | "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal", |
| 2557 | "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2558 | "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7", |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2559 | "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", |
| 2560 | "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", |
| 2561 | "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList", |
| 2562 | "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList", |
| 2563 | "OptVolatile", "MemoryInst", 0 |
| 2564 | }; |
| 2565 | #endif |
| 2566 | |
| 2567 | # ifdef YYPRINT |
| 2568 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 2569 | token YYLEX-NUM. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2570 | static const unsigned short yytoknum[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2571 | { |
| 2572 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 2573 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 2574 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 2575 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 2576 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 2577 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 2578 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 2579 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 2580 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 2581 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 2582 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 2583 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 2584 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 2585 | 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, |
| 2586 | 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, |
| 2587 | 405, 406, 61, 44, 92, 40, 41, 91, 120, 93, |
| 2588 | 60, 62, 123, 125, 42, 99 |
| 2589 | }; |
| 2590 | # endif |
| 2591 | |
| 2592 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2593 | static const unsigned char yyr1[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2594 | { |
| 2595 | 0, 166, 167, 167, 168, 168, 169, 169, 169, 169, |
| 2596 | 169, 169, 169, 169, 169, 169, 169, 170, 170, 170, |
| 2597 | 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, |
| 2598 | 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, |
| 2599 | 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, |
| 2600 | 173, 173, 174, 174, 174, 174, 175, 175, 175, 175, |
| 2601 | 175, 175, 175, 175, 175, 175, 175, 175, 175, 176, |
| 2602 | 176, 176, 176, 177, 177, 177, 177, 178, 178, 179, |
| 2603 | 179, 180, 180, 181, 181, 181, 181, 181, 181, 181, |
| 2604 | 181, 182, 182, 182, 182, 182, 182, 182, 182, 183, |
| 2605 | 183, 184, 184, 185, 186, 186, 187, 187, 188, 188, |
| 2606 | 189, 189, 190, 190, 191, 192, 192, 192, 192, 192, |
| 2607 | 192, 192, 192, 192, 192, 192, 192, 193, 193, 193, |
| 2608 | 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, |
| 2609 | 194, 195, 195, 195, 195, 196, 196, 196, 196, 196, |
| 2610 | 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, |
| 2611 | 196, 196, 196, 197, 197, 197, 197, 197, 197, 197, |
| 2612 | 197, 197, 197, 197, 197, 198, 198, 199, 199, 200, |
| 2613 | 201, 201, 201, 201, 201, 202, 202, 202, 203, 202, |
| 2614 | 204, 202, 205, 202, 206, 202, 202, 202, 202, 207, |
| 2615 | 208, 208, 209, 209, 209, 209, 210, 211, 211, 211, |
| 2616 | 212, 212, 213, 213, 214, 215, 215, 216, 216, 216, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2617 | 216, 217, 218, 218, 220, 219, 221, 221, 222, 223, |
| 2618 | 223, 223, 225, 226, 224, 227, 227, 228, 228, 228, |
| 2619 | 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, |
| 2620 | 230, 230, 231, 232, 232, 233, 234, 234, 234, 235, |
| 2621 | 235, 236, 236, 236, 236, 236, 236, 236, 236, 236, |
| 2622 | 237, 237, 238, 239, 239, 240, 240, 241, 241, 242, |
| 2623 | 242, 243, 243, 243, 243, 243, 243, 243, 243, 243, |
| 2624 | 243, 243, 243, 243, 243, 243, 243, 243, 243, 244, |
| 2625 | 244, 245, 245, 246, 246, 246, 246, 246, 246, 246, |
| 2626 | 246 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2627 | }; |
| 2628 | |
| 2629 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2630 | static const unsigned char yyr2[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2631 | { |
| 2632 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2633 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2634 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2635 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2636 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2637 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2638 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2639 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2640 | 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, |
| 2641 | 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, |
| 2642 | 2, 0, 3, 2, 0, 1, 0, 3, 1, 2, |
| 2643 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2644 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2645 | 2, 4, 5, 5, 3, 2, 5, 4, 2, 1, |
| 2646 | 3, 1, 3, 1, 0, 4, 3, 3, 4, 4, |
| 2647 | 3, 6, 5, 2, 2, 2, 2, 2, 2, 2, |
| 2648 | 2, 2, 2, 6, 5, 8, 6, 6, 6, 7, |
| 2649 | 7, 6, 6, 8, 8, 3, 1, 1, 1, 1, |
| 2650 | 2, 2, 4, 2, 1, 4, 2, 4, 0, 7, |
| 2651 | 0, 7, 0, 7, 0, 7, 3, 4, 0, 1, |
| 2652 | 1, 1, 3, 3, 3, 3, 3, 3, 1, 0, |
| 2653 | 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2654 | 0, 8, 1, 1, 0, 4, 1, 1, 2, 0, |
| 2655 | 1, 1, 0, 0, 5, 0, 1, 1, 1, 1, |
| 2656 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 2657 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 1, |
| 2658 | 1, 2, 2, 3, 9, 9, 8, 13, 1, 1, |
| 2659 | 6, 5, 2, 6, 7, 1, 3, 1, 0, 2, |
| 2660 | 1, 5, 5, 5, 6, 6, 2, 4, 4, 6, |
| 2661 | 4, 4, 4, 4, 6, 6, 2, 7, 1, 2, |
| 2662 | 0, 1, 0, 3, 6, 3, 6, 2, 4, 6, |
| 2663 | 4 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2664 | }; |
| 2665 | |
| 2666 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 2667 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 2668 | means the default is an error. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2669 | static const unsigned short yydefact[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2670 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2671 | 198, 0, 90, 184, 1, 183, 232, 83, 84, 85, |
| 2672 | 86, 87, 88, 89, 0, 224, 257, 180, 181, 257, |
| 2673 | 210, 211, 0, 0, 0, 90, 0, 186, 229, 0, |
| 2674 | 91, 258, 254, 82, 226, 227, 228, 253, 0, 0, |
| 2675 | 0, 0, 196, 0, 0, 0, 0, 0, 0, 0, |
| 2676 | 81, 230, 231, 233, 199, 182, 0, 92, 93, 94, |
| 2677 | 95, 96, 97, 0, 0, 302, 256, 0, 0, 0, |
| 2678 | 0, 209, 197, 187, 2, 3, 111, 115, 116, 117, |
| 2679 | 118, 119, 120, 121, 122, 123, 124, 125, 126, 128, |
| 2680 | 0, 0, 0, 0, 248, 185, 0, 110, 127, 114, |
| 2681 | 249, 129, 177, 178, 0, 0, 0, 0, 91, 98, |
| 2682 | 0, 222, 223, 225, 301, 0, 280, 0, 0, 0, |
| 2683 | 0, 91, 269, 259, 260, 6, 7, 8, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2684 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 52, |
| 2685 | 53, 54, 55, 20, 21, 22, 23, 24, 25, 0, |
| 2686 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2687 | 0, 0, 0, 68, 56, 57, 58, 59, 60, 61, |
| 2688 | 62, 63, 64, 65, 66, 67, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2689 | 0, 268, 255, 91, 272, 0, 298, 204, 201, 200, |
| 2690 | 202, 203, 205, 208, 0, 130, 0, 0, 0, 113, |
| 2691 | 135, 139, 0, 144, 138, 192, 194, 190, 115, 116, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2692 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2693 | 0, 0, 0, 188, 234, 0, 0, 286, 279, 262, |
| 2694 | 261, 0, 0, 72, 76, 71, 75, 70, 74, 69, |
| 2695 | 73, 77, 78, 0, 0, 26, 27, 28, 29, 30, |
| 2696 | 31, 32, 33, 34, 35, 0, 50, 51, 46, 47, |
| 2697 | 48, 49, 36, 37, 38, 39, 40, 41, 42, 43, |
| 2698 | 44, 45, 0, 101, 101, 307, 0, 0, 296, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2699 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2700 | 0, 0, 0, 0, 0, 206, 0, 0, 0, 0, |
| 2701 | 0, 134, 143, 141, 0, 106, 106, 106, 160, 161, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2702 | 4, 5, 158, 159, 162, 157, 153, 154, 0, 0, |
| 2703 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2704 | 0, 0, 0, 0, 156, 155, 106, 220, 237, 238, |
| 2705 | 239, 244, 240, 241, 242, 243, 235, 0, 246, 251, |
| 2706 | 250, 252, 0, 263, 0, 0, 0, 0, 0, 303, |
| 2707 | 0, 305, 300, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2708 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2709 | 207, 112, 112, 137, 0, 140, 0, 131, 0, 193, |
| 2710 | 195, 191, 0, 0, 0, 0, 0, 0, 0, 146, |
| 2711 | 176, 0, 0, 0, 150, 0, 147, 0, 0, 0, |
| 2712 | 0, 0, 189, 219, 213, 216, 217, 0, 236, 0, |
| 2713 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2714 | 310, 0, 0, 0, 290, 293, 0, 0, 291, 292, |
| 2715 | 0, 0, 0, 287, 288, 0, 308, 0, 132, 133, |
| 2716 | 136, 142, 0, 0, 108, 106, 0, 0, 300, 0, |
| 2717 | 0, 0, 0, 0, 145, 135, 114, 0, 148, 149, |
| 2718 | 0, 0, 0, 0, 0, 212, 214, 0, 104, 0, |
| 2719 | 245, 0, 0, 278, 0, 0, 101, 102, 101, 275, |
| 2720 | 299, 0, 0, 0, 0, 0, 281, 282, 283, 278, |
| 2721 | 0, 103, 109, 107, 0, 0, 0, 0, 0, 0, |
| 2722 | 0, 175, 152, 0, 0, 0, 0, 0, 0, 218, |
| 2723 | 215, 105, 99, 0, 0, 0, 277, 0, 284, 285, |
| 2724 | 0, 304, 306, 0, 0, 0, 289, 294, 295, 0, |
| 2725 | 309, 0, 0, 164, 0, 0, 0, 0, 151, 0, |
| 2726 | 0, 0, 0, 0, 0, 221, 247, 0, 0, 0, |
| 2727 | 276, 273, 0, 297, 0, 0, 0, 172, 0, 0, |
| 2728 | 166, 167, 168, 171, 163, 100, 0, 266, 0, 0, |
| 2729 | 0, 274, 169, 170, 0, 0, 0, 264, 0, 265, |
| 2730 | 0, 0, 165, 173, 174, 0, 0, 0, 0, 0, |
| 2731 | 0, 271, 0, 0, 270, 267 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2732 | }; |
| 2733 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2734 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 2735 | static const short yydefgoto[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2736 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2737 | -1, 94, 312, 329, 330, 331, 255, 272, 332, 333, |
| 2738 | 219, 220, 243, 221, 25, 15, 63, 555, 359, 454, |
| 2739 | 522, 389, 455, 95, 96, 222, 98, 99, 202, 304, |
| 2740 | 400, 348, 401, 104, 1, 2, 3, 336, 307, 305, |
| 2741 | 306, 55, 190, 42, 72, 194, 100, 476, 415, 416, |
| 2742 | 417, 64, 113, 16, 30, 36, 17, 53, 18, 28, |
| 2743 | 108, 419, 349, 101, 351, 489, 19, 32, 33, 181, |
| 2744 | 182, 579, 66, 278, 526, 527, 183, 184, 430, 185, |
| 2745 | 186 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2746 | }; |
| 2747 | |
| 2748 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 2749 | STATE-NUM. */ |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2750 | #define YYPACT_NINF -542 |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2751 | static const short yypact[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2752 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2753 | -542, 13, 162, 567, -542, -542, -542, -542, -542, -542, |
| 2754 | -542, -542, -542, -542, 83, -542, 19, -542, -542, -14, |
| 2755 | -542, -542, 50, -87, 87, 233, 27, -542, 123, 141, |
| 2756 | 175, -542, -542, 98, -542, -542, -542, -542, 33, 40, |
| 2757 | 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156, |
| 2758 | -542, -542, -542, -542, -542, -542, 221, -542, -542, -542, |
| 2759 | -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226, |
| 2760 | 227, 235, -542, -542, -542, -542, 81, -542, -542, -542, |
| 2761 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2762 | 256, 257, 4, 15, -542, -542, 108, -542, -542, 12, |
| 2763 | -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542, |
| 2764 | 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116, |
| 2765 | 479, 175, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2766 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2767 | -542, -542, -542, -542, -542, -542, -542, -542, -542, 355, |
| 2768 | 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, |
| 2769 | 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542, |
| 2770 | -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306, |
| 2771 | 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542, |
| 2772 | -542, -542, -542, -542, -13, -542, 110, 111, 75, -542, |
| 2773 | -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208, |
| 2774 | 266, 210, 267, 212, 268, 230, 277, 275, 278, 246, |
| 2775 | 280, 279, 566, -542, -542, 136, 766, -542, -542, 81, |
| 2776 | -542, 766, 766, -542, -542, -542, -542, -542, -542, -542, |
| 2777 | -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542, |
| 2778 | -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542, |
| 2779 | -542, -542, -542, -542, -542, -542, -542, -542, -542, -542, |
| 2780 | -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147, |
| 2781 | 148, 149, 151, 152, 158, 160, 766, 766, 766, 161, |
| 2782 | 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27, |
| 2783 | 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542, |
| 2784 | -542, -542, -542, -542, -542, -542, -542, -542, 355, 429, |
| 2785 | 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184, |
| 2786 | 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542, |
| 2787 | -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542, |
| 2788 | -542, -542, 193, -542, 194, 766, 766, 766, 7, -542, |
| 2789 | 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306, |
| 2790 | 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207, |
| 2791 | -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542, |
| 2792 | -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542, |
| 2793 | -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326, |
| 2794 | 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337, |
| 2795 | -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306, |
| 2796 | -542, 223, 766, 224, -542, -542, 225, 234, -542, -542, |
| 2797 | 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542, |
| 2798 | -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236, |
| 2799 | 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542, |
| 2800 | 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252, |
| 2801 | -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542, |
| 2802 | 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306, |
| 2803 | 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326, |
| 2804 | 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542, |
| 2805 | -542, -542, 368, 402, 274, 276, 259, 287, -542, -542, |
| 2806 | 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290, |
| 2807 | -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296, |
| 2808 | 297, 299, 302, 303, 430, -542, -542, 414, 41, 425, |
| 2809 | -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326, |
| 2810 | -542, -542, -542, -542, -542, -542, 766, -542, 893, 144, |
| 2811 | 448, -542, -542, -542, 314, 315, 316, -542, 331, -542, |
| 2812 | 893, 766, -542, -542, -542, 464, 334, 180, 766, 481, |
| 2813 | 482, -542, 766, 766, -542, -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2814 | }; |
| 2815 | |
| 2816 | /* YYPGOTO[NTERM-NUM]. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2817 | static const short yypgoto[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2818 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2819 | -542, -542, -542, 435, 439, 441, 191, 197, 442, 445, |
| 2820 | -119, -116, -541, -542, 478, 489, -107, -542, -267, 37, |
| 2821 | -542, -238, -542, -60, -542, -45, -542, -74, -51, -542, |
| 2822 | -101, 300, -252, 134, -542, -542, -542, -542, -542, -542, |
| 2823 | -542, 473, -542, -542, -542, -542, 8, -542, 46, -542, |
| 2824 | -542, 410, -542, -542, -542, -542, -542, -542, 518, -542, |
| 2825 | -542, -542, -528, 142, -90, -113, -542, 505, -542, -72, |
| 2826 | -542, -542, -542, -542, 97, 28, -542, -542, 70, -542, |
| 2827 | -542 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2828 | }; |
| 2829 | |
| 2830 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2831 | positive, shift that token. If negative, reduce the rule which |
| 2832 | number is the opposite. If zero, do what YYDEFACT says. |
| 2833 | If YYTABLE_NINF, syntax error. */ |
| 2834 | #define YYTABLE_NINF -180 |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 2835 | static const short yytable[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2836 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2837 | 97, 241, 227, 110, 242, 230, 223, 361, 197, 31, |
| 2838 | 111, 26, 449, 4, 244, 204, 34, 578, 97, 201, |
| 2839 | 74, 75, 426, 199, 77, 78, 79, 80, 81, 82, |
| 2840 | 83, 84, 85, 86, 87, 428, 88, 20, 590, 21, |
| 2841 | 275, 26, 31, 279, 280, 281, 282, 283, 284, 285, |
| 2842 | 588, 233, 234, 235, 236, 237, 238, 239, 240, 205, |
| 2843 | 206, 207, 596, 89, 427, 43, 289, 290, 390, 391, |
| 2844 | 226, 463, 300, 226, 403, 405, 291, 427, 452, 468, |
| 2845 | 74, 75, 301, 199, 77, 78, 79, 80, 81, 82, |
| 2846 | 83, 84, 85, 86, 87, 420, 88, 20, 412, 21, |
| 2847 | 448, 453, 38, 39, 40, 204, 273, 274, 226, 276, |
| 2848 | 277, 226, 226, 226, 226, 226, 226, 226, 225, 463, |
| 2849 | 20, 41, 21, 89, 201, 231, 300, 480, -139, 201, |
| 2850 | -112, 286, 287, 288, 226, 226, 384, 232, -139, 204, |
| 2851 | 294, 352, 353, 112, 29, 463, 295, 299, 44, 35, |
| 2852 | 467, 464, 303, 354, 233, 234, 235, 236, 237, 238, |
| 2853 | 239, 240, -179, 463, 463, 54, 198, -112, 51, 90, |
| 2854 | 52, 71, 91, 469, 513, 92, 204, 93, 200, 50, |
| 2855 | 379, 105, 106, 107, 355, 67, 362, 5, 102, 103, |
| 2856 | 188, 189, 68, 6, 292, 293, 372, 373, 374, 97, |
| 2857 | 577, 308, 309, 7, 8, 9, 10, 11, 12, 13, |
| 2858 | 356, -72, -72, -71, -71, -70, -70, 503, 69, 531, |
| 2859 | 70, 532, 381, 382, 14, 109, 385, 357, 187, 90, |
| 2860 | 191, 377, 91, -69, -69, 92, -113, 93, 298, 56, |
| 2861 | 57, 58, 59, 60, 61, 62, 97, 378, 226, 310, |
| 2862 | 311, 192, 433, 45, 435, 436, 437, 123, 124, 193, |
| 2863 | 195, 196, 443, 203, 228, 423, 424, 425, 296, 297, |
| 2864 | -76, -75, -74, 431, 7, 8, 9, 10, 46, 12, |
| 2865 | 47, -73, -79, 48, 313, -80, 314, 445, 446, 363, |
| 2866 | 358, 337, 414, 458, 459, 460, 461, 462, 360, 364, |
| 2867 | 365, 366, 367, 589, 368, 369, 470, 471, 472, 473, |
| 2868 | 474, 370, 385, 371, 375, 380, 383, 376, 386, 387, |
| 2869 | 226, 434, 226, 226, 226, 438, 439, 394, 466, 388, |
| 2870 | 226, 444, 395, 396, 397, 406, 486, 398, 488, 407, |
| 2871 | 408, 409, 492, 410, 411, 418, 421, 422, 429, 432, |
| 2872 | 496, 497, 498, 440, 441, 504, 505, 450, 456, 442, |
| 2873 | 447, 479, 511, 481, 335, 478, 457, 477, 350, 482, |
| 2874 | 483, 484, 485, 350, 350, 487, 491, 493, 494, 502, |
| 2875 | 536, 537, 538, 499, 226, 350, 501, 495, 518, 507, |
| 2876 | 508, 524, 525, 509, 528, 529, 510, 514, 515, 512, |
| 2877 | 516, 534, 500, 517, 452, 523, 544, 545, 546, 547, |
| 2878 | 540, 530, 533, 549, 550, 551, 552, 535, 350, 543, |
| 2879 | 560, 548, 475, 541, 542, 554, 556, 557, 350, 350, |
| 2880 | 350, 427, 414, 558, 575, 576, 566, 568, 226, 241, |
| 2881 | 564, 565, 242, 559, 561, 562, 563, 569, 226, 226, |
| 2882 | 226, 567, 570, 571, 226, 572, 256, 257, 573, 574, |
| 2883 | 241, 580, 582, 242, 581, 584, 583, 585, 586, 591, |
| 2884 | 592, 593, 594, 553, 245, 246, 247, 248, 249, 250, |
| 2885 | 251, 252, 253, 254, 595, 598, 587, 599, 226, 233, |
| 2886 | 234, 235, 236, 237, 238, 239, 240, 350, 350, 350, |
| 2887 | 176, 597, 602, 603, 177, 350, 178, 179, 601, 392, |
| 2888 | 180, 65, 604, 605, 49, 521, 393, 73, 224, 350, |
| 2889 | 350, 27, 334, 520, 37, 600, 490, 539, 506, 0, |
| 2890 | 0, 0, 0, 0, 74, 75, 0, 199, 208, 209, |
| 2891 | 210, 211, 212, 213, 214, 215, 216, 217, 218, 0, |
| 2892 | 88, 20, 0, 21, 258, 259, 260, 261, 262, 263, |
| 2893 | 264, 265, 266, 267, 268, 269, 270, 271, 350, 0, |
| 2894 | 350, 74, 75, 0, 350, 0, 0, 89, 0, 0, |
| 2895 | 0, 0, 350, 350, 350, 0, 0, -82, 20, 20, |
| 2896 | 21, 21, 315, 0, 0, 0, 0, 0, 6, -82, |
| 2897 | -82, 0, 0, 0, 316, 317, 0, 0, -82, -82, |
| 2898 | -82, -82, -82, -82, -82, 0, 0, -82, 22, 0, |
| 2899 | 0, 0, 0, 350, 350, 23, 350, 350, 0, 24, |
| 2900 | 0, 0, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2901 | 0, 0, 350, 0, 0, 125, 126, 127, 128, 129, |
| 2902 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2903 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
| 2904 | 319, 0, 0, 0, 0, 0, 320, 350, 321, 0, |
| 2905 | 322, 323, 324, 90, 0, 0, 91, 0, 0, 92, |
| 2906 | 0, 93, 404, 0, 0, 0, 0, 0, 0, 0, |
| 2907 | 0, 0, 0, 0, 0, 163, 164, 165, 166, 167, |
| 2908 | 168, 169, 170, 171, 172, 173, 174, 175, 350, 0, |
| 2909 | 0, 0, 0, 325, 0, 0, 326, 0, 327, 0, |
| 2910 | 0, 328, 0, 350, 0, 0, 0, 0, 0, 0, |
| 2911 | 350, 0, 0, 0, 350, 350, 74, 75, 0, 199, |
| 2912 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, |
| 2913 | 218, 0, 88, 20, 0, 21, 0, 0, 0, 338, |
| 2914 | 339, 74, 75, 340, 0, 0, 0, 0, 0, 0, |
| 2915 | 0, 0, 0, 0, 0, 0, 0, 0, 20, 89, |
| 2916 | 21, 0, 341, 342, 343, 0, 0, 0, 0, 0, |
| 2917 | 0, 0, 0, 0, 344, 345, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2918 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2919 | 0, 0, 0, 0, 0, 0, 0, 346, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2920 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2921 | 0, 0, 0, 0, 0, 125, 126, 127, 128, 129, |
| 2922 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2923 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 318, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2924 | 319, 0, 0, 0, 0, 0, 320, 0, 321, 0, |
| 2925 | 322, 323, 324, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2926 | 0, 0, 0, 0, 0, 90, 338, 339, 91, 0, |
| 2927 | 340, 92, 0, 93, 465, 163, 164, 165, 166, 167, |
| 2928 | 168, 169, 170, 171, 172, 173, 174, 175, 0, 341, |
| 2929 | 342, 343, 0, 0, 0, 0, 347, 0, 0, 0, |
| 2930 | 0, 344, 345, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2931 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2932 | 0, 0, 0, 0, 346, 0, 0, 0, 0, 0, |
| 2933 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2934 | 0, 0, 125, 126, 127, 128, 129, 130, 131, 132, |
| 2935 | 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, |
| 2936 | 143, 144, 145, 146, 147, 148, 318, 319, 0, 0, |
| 2937 | 0, 0, 0, 320, 0, 321, 0, 322, 323, 324, |
| 2938 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2939 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2940 | 0, 0, 163, 164, 165, 166, 167, 168, 169, 170, |
| 2941 | 171, 172, 173, 174, 175, 0, 0, 0, 0, 0, |
| 2942 | 0, 74, 75, 347, 199, 77, 78, 79, 80, 81, |
| 2943 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 2944 | 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2945 | 0, 0, 0, 302, 0, 0, 0, 0, 0, 0, |
| 2946 | 0, 0, 74, 75, 89, 199, 208, 209, 210, 211, |
| 2947 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 2948 | 0, 21, 74, 75, 0, 199, 77, 78, 79, 80, |
| 2949 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 2950 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 0, |
| 2951 | 0, 0, 0, 0, 413, 0, 0, 0, 0, 0, |
| 2952 | 0, 0, 0, 74, 75, 89, 199, 77, 78, 79, |
| 2953 | 80, 81, 82, 83, 84, 85, 86, 87, 0, 88, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2954 | 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2955 | 0, 0, 0, 0, 0, 451, 0, 0, 0, 0, |
| 2956 | 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, |
| 2957 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
| 2958 | 74, 75, 0, 199, 77, 78, 79, 80, 81, 82, |
| 2959 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2960 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2961 | 0, 90, 519, 0, 91, 0, 399, 92, 0, 93, |
| 2962 | 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, |
| 2963 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 93, |
| 2964 | 74, 75, 0, 76, 77, 78, 79, 80, 81, 82, |
| 2965 | 83, 84, 85, 86, 87, 0, 88, 20, 0, 21, |
| 2966 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2967 | 0, 0, 90, 0, 0, 91, 0, 0, 92, 0, |
| 2968 | 93, 74, 75, 89, 199, 77, 78, 79, 80, 81, |
| 2969 | 82, 83, 84, 85, 86, 87, 0, 88, 20, 0, |
| 2970 | 21, 74, 75, 0, 199, 208, 209, 210, 211, 212, |
| 2971 | 213, 214, 215, 216, 217, 218, 0, 88, 20, 0, |
| 2972 | 21, 0, 0, 0, 89, 0, 0, 0, 0, 90, |
| 2973 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 2974 | 0, 0, 74, 75, 89, 229, 77, 78, 79, 80, |
| 2975 | 81, 82, 83, 84, 85, 86, 87, 0, 88, 20, |
| 2976 | 0, 21, 74, 75, 0, 199, 208, 209, 210, 211, |
| 2977 | 212, 213, 214, 215, 216, 217, 218, 0, 88, 20, |
| 2978 | 0, 21, 0, 0, 0, 89, 0, 0, 0, 90, |
| 2979 | 0, 0, 91, 0, 0, 92, 0, 93, 0, 0, |
| 2980 | 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2981 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2982 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2983 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2984 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2985 | 90, 0, 0, 91, 0, 0, 92, 0, 93, 0, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2986 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2987 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 2988 | 0, 0, 0, 0, 114, 0, 0, 0, 0, 0, |
| 2989 | 0, 90, 0, 0, 91, 0, 0, 92, 115, 93, |
| 2990 | 0, 0, 0, 0, 0, 0, 0, 0, 116, 117, |
| 2991 | 0, 90, 0, 0, 91, 0, 0, 92, 0, 402, |
| 2992 | 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 2993 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 2994 | 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, |
| 2995 | 147, 148, 149, 150, 151, 152, 153, 0, 0, 154, |
| 2996 | 155, 156, 157, 158, 159, 160, 161, 162, 0, 0, |
| 2997 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2998 | 0, 0, 0, 0, 0, 0, 0, 0, 163, 164, |
| 2999 | 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 3000 | 175 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3001 | }; |
| 3002 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3003 | static const short yycheck[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3004 | { |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3005 | 45, 120, 115, 63, 120, 118, 107, 274, 4, 23, |
| 3006 | 29, 3, 161, 0, 121, 164, 30, 558, 63, 93, |
| 3007 | 5, 6, 15, 8, 9, 10, 11, 12, 13, 14, |
| 3008 | 15, 16, 17, 18, 19, 15, 21, 22, 579, 24, |
| 3009 | 153, 33, 23, 156, 157, 158, 159, 160, 161, 162, |
| 3010 | 578, 10, 11, 12, 13, 14, 15, 16, 17, 104, |
| 3011 | 105, 106, 590, 48, 57, 152, 179, 180, 306, 307, |
| 3012 | 115, 153, 153, 118, 326, 327, 183, 57, 34, 161, |
| 3013 | 5, 6, 163, 8, 9, 10, 11, 12, 13, 14, |
| 3014 | 15, 16, 17, 18, 19, 347, 21, 22, 336, 24, |
| 3015 | 159, 57, 52, 53, 54, 164, 151, 152, 153, 154, |
| 3016 | 155, 156, 157, 158, 159, 160, 161, 162, 110, 153, |
| 3017 | 22, 71, 24, 48, 198, 9, 153, 161, 153, 203, |
| 3018 | 155, 176, 177, 178, 179, 180, 163, 21, 163, 164, |
| 3019 | 153, 231, 232, 162, 61, 153, 159, 198, 61, 163, |
| 3020 | 402, 159, 203, 243, 10, 11, 12, 13, 14, 15, |
| 3021 | 16, 17, 0, 153, 153, 24, 162, 155, 45, 154, |
| 3022 | 47, 157, 157, 163, 163, 160, 164, 162, 163, 152, |
| 3023 | 293, 47, 48, 49, 244, 152, 276, 25, 32, 33, |
| 3024 | 55, 56, 152, 31, 108, 109, 286, 287, 288, 244, |
| 3025 | 159, 27, 28, 41, 42, 43, 44, 45, 46, 47, |
| 3026 | 255, 3, 4, 3, 4, 3, 4, 455, 152, 486, |
| 3027 | 152, 488, 296, 297, 62, 4, 300, 272, 24, 154, |
| 3028 | 4, 291, 157, 3, 4, 160, 155, 162, 163, 64, |
| 3029 | 65, 66, 67, 68, 69, 70, 291, 292, 293, 3, |
| 3030 | 4, 24, 365, 20, 367, 368, 369, 77, 78, 24, |
| 3031 | 4, 4, 375, 155, 59, 355, 356, 357, 158, 158, |
| 3032 | 4, 4, 4, 363, 41, 42, 43, 44, 45, 46, |
| 3033 | 47, 4, 7, 50, 4, 7, 7, 377, 378, 157, |
| 3034 | 153, 155, 337, 394, 395, 396, 397, 398, 153, 153, |
| 3035 | 153, 153, 153, 159, 153, 153, 407, 408, 409, 410, |
| 3036 | 411, 153, 386, 153, 153, 24, 161, 36, 153, 156, |
| 3037 | 365, 366, 367, 368, 369, 370, 371, 155, 402, 153, |
| 3038 | 375, 376, 155, 155, 155, 24, 426, 155, 428, 155, |
| 3039 | 155, 155, 432, 155, 155, 63, 153, 153, 153, 157, |
| 3040 | 440, 441, 442, 153, 153, 456, 457, 161, 155, 153, |
| 3041 | 153, 24, 463, 21, 222, 156, 155, 153, 226, 21, |
| 3042 | 155, 153, 153, 231, 232, 4, 153, 153, 153, 4, |
| 3043 | 493, 494, 495, 155, 429, 243, 24, 153, 36, 153, |
| 3044 | 153, 481, 482, 153, 484, 485, 153, 153, 153, 161, |
| 3045 | 153, 491, 447, 153, 34, 153, 507, 508, 509, 510, |
| 3046 | 500, 153, 153, 514, 515, 516, 517, 153, 276, 156, |
| 3047 | 533, 161, 414, 153, 153, 57, 24, 153, 286, 287, |
| 3048 | 288, 57, 477, 157, 4, 21, 153, 153, 483, 558, |
| 3049 | 541, 542, 558, 156, 159, 535, 156, 153, 493, 494, |
| 3050 | 495, 156, 156, 156, 499, 156, 27, 28, 156, 156, |
| 3051 | 579, 36, 156, 579, 159, 566, 156, 568, 569, 21, |
| 3052 | 156, 156, 156, 518, 119, 120, 121, 122, 123, 124, |
| 3053 | 125, 126, 127, 128, 153, 21, 576, 153, 533, 10, |
| 3054 | 11, 12, 13, 14, 15, 16, 17, 355, 356, 357, |
| 3055 | 65, 591, 21, 21, 65, 363, 65, 65, 598, 318, |
| 3056 | 65, 33, 602, 603, 25, 478, 319, 44, 108, 377, |
| 3057 | 378, 3, 222, 477, 19, 597, 429, 499, 458, -1, |
| 3058 | -1, -1, -1, -1, 5, 6, -1, 8, 9, 10, |
| 3059 | 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, |
| 3060 | 21, 22, -1, 24, 125, 126, 127, 128, 129, 130, |
| 3061 | 131, 132, 133, 134, 135, 136, 137, 138, 426, -1, |
| 3062 | 428, 5, 6, -1, 432, -1, -1, 48, -1, -1, |
| 3063 | -1, -1, 440, 441, 442, -1, -1, 20, 22, 22, |
| 3064 | 24, 24, 26, -1, -1, -1, -1, -1, 31, 32, |
| 3065 | 33, -1, -1, -1, 38, 39, -1, -1, 41, 42, |
| 3066 | 43, 44, 45, 46, 47, -1, -1, 50, 51, -1, |
| 3067 | -1, -1, -1, 481, 482, 58, 484, 485, -1, 62, |
| 3068 | -1, -1, -1, 491, -1, -1, -1, -1, -1, -1, |
| 3069 | -1, -1, 500, -1, -1, 79, 80, 81, 82, 83, |
| 3070 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3071 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3072 | 104, -1, -1, -1, -1, -1, 110, 535, 112, -1, |
| 3073 | 114, 115, 116, 154, -1, -1, 157, -1, -1, 160, |
| 3074 | -1, 162, 163, -1, -1, -1, -1, -1, -1, -1, |
| 3075 | -1, -1, -1, -1, -1, 139, 140, 141, 142, 143, |
| 3076 | 144, 145, 146, 147, 148, 149, 150, 151, 576, -1, |
| 3077 | -1, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3078 | -1, 165, -1, 591, -1, -1, -1, -1, -1, -1, |
| 3079 | 598, -1, -1, -1, 602, 603, 5, 6, -1, 8, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3080 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3081 | 19, -1, 21, 22, -1, 24, -1, -1, -1, 3, |
| 3082 | 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, |
| 3083 | -1, -1, -1, -1, -1, -1, -1, -1, 22, 48, |
| 3084 | 24, -1, 26, 27, 28, -1, -1, -1, -1, -1, |
| 3085 | -1, -1, -1, -1, 38, 39, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3086 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3087 | -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, |
| 3088 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3089 | -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, |
| 3090 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3091 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3092 | 104, -1, -1, -1, -1, -1, 110, -1, 112, -1, |
| 3093 | 114, 115, 116, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3094 | -1, -1, -1, -1, -1, 154, 3, 4, 157, -1, |
| 3095 | 7, 160, -1, 162, 163, 139, 140, 141, 142, 143, |
| 3096 | 144, 145, 146, 147, 148, 149, 150, 151, -1, 26, |
| 3097 | 27, 28, -1, -1, -1, -1, 160, -1, -1, -1, |
| 3098 | -1, 38, 39, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3099 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3100 | -1, -1, -1, -1, 61, -1, -1, -1, -1, -1, |
| 3101 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3102 | -1, -1, 79, 80, 81, 82, 83, 84, 85, 86, |
| 3103 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 3104 | 97, 98, 99, 100, 101, 102, 103, 104, -1, -1, |
| 3105 | -1, -1, -1, 110, -1, 112, -1, 114, 115, 116, |
| 3106 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3107 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3108 | -1, -1, 139, 140, 141, 142, 143, 144, 145, 146, |
| 3109 | 147, 148, 149, 150, 151, -1, -1, -1, -1, -1, |
| 3110 | -1, 5, 6, 160, 8, 9, 10, 11, 12, 13, |
| 3111 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3112 | 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3113 | -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, |
| 3114 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3115 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3116 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3117 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3118 | -1, 24, -1, -1, -1, 48, -1, -1, -1, -1, |
| 3119 | -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, |
| 3120 | -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3121 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 3122 | 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3123 | -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, |
| 3124 | -1, -1, -1, -1, -1, -1, 48, -1, -1, -1, |
| 3125 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 3126 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3127 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 3128 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3129 | -1, 154, 37, -1, 157, -1, 159, 160, -1, 162, |
| 3130 | -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3131 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3132 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 3133 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3134 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3135 | -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3136 | 162, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 3137 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3138 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 3139 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 3140 | 24, -1, -1, -1, 48, -1, -1, -1, -1, 154, |
| 3141 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3142 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 3143 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3144 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 3145 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 3146 | -1, 24, -1, -1, -1, 48, -1, -1, -1, 154, |
| 3147 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 3148 | -1, -1, -1, -1, -1, 48, -1, -1, -1, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3149 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3150 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3151 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3152 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3153 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3154 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3155 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3156 | -1, -1, -1, -1, 35, -1, -1, -1, -1, -1, |
| 3157 | -1, 154, -1, -1, 157, -1, -1, 160, 49, 162, |
| 3158 | -1, -1, -1, -1, -1, -1, -1, -1, 59, 60, |
| 3159 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 3160 | -1, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 3161 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 3162 | 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, |
| 3163 | 101, 102, 103, 104, 105, 106, 107, -1, -1, 110, |
| 3164 | 111, 112, 113, 114, 115, 116, 117, 118, -1, -1, |
| 3165 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 3166 | -1, -1, -1, -1, -1, -1, -1, -1, 139, 140, |
| 3167 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, |
| 3168 | 151 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3169 | }; |
| 3170 | |
| 3171 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 3172 | symbol of state STATE-NUM. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3173 | static const unsigned char yystos[] = |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3174 | { |
| 3175 | 0, 200, 201, 202, 0, 25, 31, 41, 42, 43, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3176 | 44, 45, 46, 47, 62, 181, 219, 222, 224, 232, |
| 3177 | 22, 24, 51, 58, 62, 180, 212, 224, 225, 61, |
| 3178 | 220, 23, 233, 234, 30, 163, 221, 233, 52, 53, |
| 3179 | 54, 71, 209, 152, 61, 20, 45, 47, 50, 181, |
| 3180 | 152, 45, 47, 223, 24, 207, 64, 65, 66, 67, |
| 3181 | 68, 69, 70, 182, 217, 180, 238, 152, 152, 152, |
| 3182 | 152, 157, 210, 207, 5, 6, 8, 9, 10, 11, |
| 3183 | 12, 13, 14, 15, 16, 17, 18, 19, 21, 48, |
| 3184 | 154, 157, 160, 162, 167, 189, 190, 191, 192, 193, |
| 3185 | 212, 229, 32, 33, 199, 199, 199, 199, 226, 4, |
| 3186 | 189, 29, 162, 218, 35, 49, 59, 60, 72, 73, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3187 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 3188 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 3189 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 3190 | 104, 105, 106, 107, 110, 111, 112, 113, 114, 115, |
| 3191 | 116, 117, 118, 139, 140, 141, 142, 143, 144, 145, |
| 3192 | 146, 147, 148, 149, 150, 151, 169, 170, 171, 174, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3193 | 175, 235, 236, 242, 243, 245, 246, 24, 55, 56, |
| 3194 | 208, 4, 24, 24, 211, 4, 4, 4, 162, 8, |
| 3195 | 163, 193, 194, 155, 164, 191, 191, 191, 9, 10, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3196 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 176, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3197 | 177, 179, 191, 196, 217, 212, 191, 231, 59, 8, |
| 3198 | 231, 9, 21, 10, 11, 12, 13, 14, 15, 16, |
| 3199 | 17, 176, 177, 178, 182, 119, 120, 121, 122, 123, |
| 3200 | 124, 125, 126, 127, 128, 172, 27, 28, 125, 126, |
| 3201 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 3202 | 137, 138, 173, 191, 191, 231, 191, 191, 239, 231, |
| 3203 | 231, 231, 231, 231, 231, 231, 191, 191, 191, 231, |
| 3204 | 231, 182, 108, 109, 153, 159, 158, 158, 163, 194, |
| 3205 | 153, 163, 37, 194, 195, 205, 206, 204, 27, 28, |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3206 | 3, 4, 168, 4, 7, 26, 38, 39, 103, 104, |
| 3207 | 110, 112, 114, 115, 116, 157, 160, 162, 165, 169, |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 3208 | 170, 171, 174, 175, 197, 229, 203, 155, 3, 4, |
| 3209 | 7, 26, 27, 28, 38, 39, 61, 160, 197, 228, |
| 3210 | 229, 230, 230, 230, 230, 189, 191, 191, 153, 184, |
| 3211 | 153, 184, 230, 157, 153, 153, 153, 153, 153, 153, |
| 3212 | 153, 153, 230, 230, 230, 153, 36, 189, 191, 231, |
| 3213 | 24, 193, 193, 161, 163, 193, 153, 156, 153, 187, |
| 3214 | 187, 187, 172, 173, 155, 155, 155, 155, 155, 159, |
| 3215 | 196, 198, 162, 198, 163, 198, 24, 155, 155, 155, |
| 3216 | 155, 155, 187, 37, 191, 214, 215, 216, 63, 227, |
| 3217 | 198, 153, 153, 230, 230, 230, 15, 57, 15, 153, |
| 3218 | 244, 230, 157, 231, 191, 231, 231, 231, 191, 191, |
| 3219 | 153, 153, 153, 231, 191, 230, 230, 153, 159, 161, |
| 3220 | 161, 37, 34, 57, 185, 188, 155, 155, 196, 196, |
| 3221 | 196, 196, 196, 153, 159, 163, 193, 198, 161, 163, |
| 3222 | 196, 196, 196, 196, 196, 212, 213, 153, 156, 24, |
| 3223 | 161, 21, 21, 155, 153, 153, 230, 4, 230, 231, |
| 3224 | 240, 153, 230, 153, 153, 153, 230, 230, 230, 155, |
| 3225 | 191, 24, 4, 187, 196, 196, 244, 153, 153, 153, |
| 3226 | 153, 196, 161, 163, 153, 153, 153, 153, 36, 37, |
| 3227 | 214, 185, 186, 153, 230, 230, 240, 241, 230, 230, |
| 3228 | 153, 184, 184, 153, 230, 153, 231, 231, 231, 241, |
| 3229 | 230, 153, 153, 156, 196, 196, 196, 196, 161, 196, |
| 3230 | 196, 196, 196, 191, 57, 183, 24, 153, 157, 156, |
| 3231 | 231, 159, 230, 156, 196, 196, 153, 156, 153, 153, |
| 3232 | 156, 156, 156, 156, 156, 4, 21, 159, 178, 237, |
| 3233 | 36, 159, 156, 156, 196, 196, 196, 230, 228, 159, |
| 3234 | 178, 21, 156, 156, 156, 153, 228, 230, 21, 153, |
| 3235 | 235, 230, 21, 21, 230, 230 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3236 | }; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3237 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3238 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 3239 | # define YYSIZE_T __SIZE_TYPE__ |
| 3240 | #endif |
| 3241 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 3242 | # define YYSIZE_T size_t |
| 3243 | #endif |
| 3244 | #if ! defined (YYSIZE_T) |
| 3245 | # if defined (__STDC__) || defined (__cplusplus) |
| 3246 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 3247 | # define YYSIZE_T size_t |
| 3248 | # endif |
| 3249 | #endif |
| 3250 | #if ! defined (YYSIZE_T) |
| 3251 | # define YYSIZE_T unsigned int |
| 3252 | #endif |
| 3253 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3254 | #define yyerrok (yyerrstatus = 0) |
| 3255 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3256 | #define YYEMPTY (-2) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3257 | #define YYEOF 0 |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3258 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3259 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3260 | #define YYABORT goto yyabortlab |
| 3261 | #define YYERROR goto yyerrorlab |
| 3262 | |
| 3263 | |
| 3264 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 3265 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3266 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3267 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3268 | #define YYFAIL goto yyerrlab |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3269 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3270 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3271 | |
| 3272 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3273 | do \ |
| 3274 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3275 | { \ |
| 3276 | yychar = (Token); \ |
| 3277 | yylval = (Value); \ |
| 3278 | yytoken = YYTRANSLATE (yychar); \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3279 | YYPOPSTACK; \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3280 | goto yybackup; \ |
| 3281 | } \ |
| 3282 | else \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3283 | { \ |
| 3284 | yyerror ("syntax error: cannot back up");\ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3285 | YYERROR; \ |
| 3286 | } \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3287 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3288 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3289 | #define YYTERROR 1 |
| 3290 | #define YYERRCODE 256 |
| 3291 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3292 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions |
| 3293 | are run). */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3294 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3295 | #ifndef YYLLOC_DEFAULT |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3296 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 3297 | ((Current).first_line = (Rhs)[1].first_line, \ |
| 3298 | (Current).first_column = (Rhs)[1].first_column, \ |
| 3299 | (Current).last_line = (Rhs)[N].last_line, \ |
| 3300 | (Current).last_column = (Rhs)[N].last_column) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3301 | #endif |
| 3302 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3303 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 3304 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3305 | #ifdef YYLEX_PARAM |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3306 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3307 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3308 | # define YYLEX yylex () |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3309 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3310 | |
| 3311 | /* Enable debugging if requested. */ |
| 3312 | #if YYDEBUG |
| 3313 | |
| 3314 | # ifndef YYFPRINTF |
| 3315 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 3316 | # define YYFPRINTF fprintf |
| 3317 | # endif |
| 3318 | |
| 3319 | # define YYDPRINTF(Args) \ |
| 3320 | do { \ |
| 3321 | if (yydebug) \ |
| 3322 | YYFPRINTF Args; \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3323 | } while (0) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3324 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3325 | # define YYDSYMPRINT(Args) \ |
| 3326 | do { \ |
| 3327 | if (yydebug) \ |
| 3328 | yysymprint Args; \ |
| 3329 | } while (0) |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 3330 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3331 | # define YYDSYMPRINTF(Title, Token, Value, Location) \ |
| 3332 | do { \ |
| 3333 | if (yydebug) \ |
| 3334 | { \ |
| 3335 | YYFPRINTF (stderr, "%s ", Title); \ |
| 3336 | yysymprint (stderr, \ |
| 3337 | Token, Value); \ |
| 3338 | YYFPRINTF (stderr, "\n"); \ |
| 3339 | } \ |
| 3340 | } while (0) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3341 | |
| 3342 | /*------------------------------------------------------------------. |
| 3343 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 3344 | | TOP (included). | |
| 3345 | `------------------------------------------------------------------*/ |
| 3346 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3347 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3348 | static void |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3349 | yy_stack_print (short *bottom, short *top) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3350 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3351 | static void |
| 3352 | yy_stack_print (bottom, top) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3353 | short *bottom; |
| 3354 | short *top; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3355 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3356 | { |
| 3357 | YYFPRINTF (stderr, "Stack now"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3358 | for (/* Nothing. */; bottom <= top; ++bottom) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3359 | YYFPRINTF (stderr, " %d", *bottom); |
| 3360 | YYFPRINTF (stderr, "\n"); |
| 3361 | } |
| 3362 | |
| 3363 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 3364 | do { \ |
| 3365 | if (yydebug) \ |
| 3366 | yy_stack_print ((Bottom), (Top)); \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3367 | } while (0) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3368 | |
| 3369 | |
| 3370 | /*------------------------------------------------. |
| 3371 | | Report that the YYRULE is going to be reduced. | |
| 3372 | `------------------------------------------------*/ |
| 3373 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3374 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3375 | static void |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3376 | yy_reduce_print (int yyrule) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3377 | #else |
| 3378 | static void |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3379 | yy_reduce_print (yyrule) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3380 | int yyrule; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3381 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3382 | { |
| 3383 | int yyi; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3384 | unsigned int yylno = yyrline[yyrule]; |
| 3385 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", |
| 3386 | yyrule - 1, yylno); |
| 3387 | /* Print the symbols being reduced, and their result. */ |
| 3388 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 3389 | YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); |
| 3390 | YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3391 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3392 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3393 | # define YY_REDUCE_PRINT(Rule) \ |
| 3394 | do { \ |
| 3395 | if (yydebug) \ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3396 | yy_reduce_print (Rule); \ |
| 3397 | } while (0) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3398 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3399 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 3400 | multiple parsers can coexist. */ |
| 3401 | int yydebug; |
| 3402 | #else /* !YYDEBUG */ |
| 3403 | # define YYDPRINTF(Args) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3404 | # define YYDSYMPRINT(Args) |
| 3405 | # define YYDSYMPRINTF(Title, Token, Value, Location) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3406 | # define YY_STACK_PRINT(Bottom, Top) |
| 3407 | # define YY_REDUCE_PRINT(Rule) |
| 3408 | #endif /* !YYDEBUG */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3409 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3410 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3411 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3412 | #ifndef YYINITDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3413 | # define YYINITDEPTH 200 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3414 | #endif |
| 3415 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3416 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 3417 | if the built-in stack extension method is used). |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3418 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3419 | Do not make this value too large; the results are undefined if |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3420 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3421 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3422 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3423 | #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 |
| 3424 | # undef YYMAXDEPTH |
| 3425 | #endif |
| 3426 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3427 | #ifndef YYMAXDEPTH |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3428 | # define YYMAXDEPTH 10000 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3429 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3430 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3431 | |
| 3432 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3433 | #if YYERROR_VERBOSE |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3434 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3435 | # ifndef yystrlen |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3436 | # if defined (__GLIBC__) && defined (_STRING_H) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3437 | # define yystrlen strlen |
| 3438 | # else |
| 3439 | /* Return the length of YYSTR. */ |
| 3440 | static YYSIZE_T |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3441 | # if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3442 | yystrlen (const char *yystr) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3443 | # else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3444 | yystrlen (yystr) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3445 | const char *yystr; |
| 3446 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3447 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3448 | register const char *yys = yystr; |
| 3449 | |
| 3450 | while (*yys++ != '\0') |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3451 | continue; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3452 | |
| 3453 | return yys - yystr - 1; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3454 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3455 | # endif |
| 3456 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3457 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3458 | # ifndef yystpcpy |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3459 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3460 | # define yystpcpy stpcpy |
| 3461 | # else |
| 3462 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 3463 | YYDEST. */ |
| 3464 | static char * |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3465 | # if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3466 | yystpcpy (char *yydest, const char *yysrc) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3467 | # else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3468 | yystpcpy (yydest, yysrc) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3469 | char *yydest; |
| 3470 | const char *yysrc; |
| 3471 | # endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3472 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3473 | register char *yyd = yydest; |
| 3474 | register const char *yys = yysrc; |
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 ((*yyd++ = *yys++) != '\0') |
| 3477 | continue; |
| 3478 | |
| 3479 | return yyd - 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 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3484 | #endif /* !YYERROR_VERBOSE */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3485 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3486 | |
| 3487 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3488 | #if YYDEBUG |
| 3489 | /*--------------------------------. |
| 3490 | | Print this symbol on YYOUTPUT. | |
| 3491 | `--------------------------------*/ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3492 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3493 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3494 | static void |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3495 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3496 | #else |
| 3497 | static void |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3498 | yysymprint (yyoutput, yytype, yyvaluep) |
| 3499 | FILE *yyoutput; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3500 | int yytype; |
| 3501 | YYSTYPE *yyvaluep; |
| 3502 | #endif |
| 3503 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3504 | /* Pacify ``unused variable'' warnings. */ |
| 3505 | (void) yyvaluep; |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 3506 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3507 | if (yytype < YYNTOKENS) |
| 3508 | { |
| 3509 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 3510 | # ifdef YYPRINT |
| 3511 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 3512 | # endif |
| 3513 | } |
| 3514 | else |
| 3515 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 3516 | |
| 3517 | switch (yytype) |
| 3518 | { |
| 3519 | default: |
| 3520 | break; |
| 3521 | } |
| 3522 | YYFPRINTF (yyoutput, ")"); |
| 3523 | } |
| 3524 | |
| 3525 | #endif /* ! YYDEBUG */ |
| 3526 | /*-----------------------------------------------. |
| 3527 | | Release the memory associated to this symbol. | |
| 3528 | `-----------------------------------------------*/ |
| 3529 | |
| 3530 | #if defined (__STDC__) || defined (__cplusplus) |
| 3531 | static void |
| 3532 | yydestruct (int yytype, YYSTYPE *yyvaluep) |
| 3533 | #else |
| 3534 | static void |
| 3535 | yydestruct (yytype, yyvaluep) |
| 3536 | int yytype; |
| 3537 | YYSTYPE *yyvaluep; |
| 3538 | #endif |
| 3539 | { |
| 3540 | /* Pacify ``unused variable'' warnings. */ |
| 3541 | (void) yyvaluep; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3542 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3543 | switch (yytype) |
| 3544 | { |
| 3545 | |
| 3546 | default: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3547 | break; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3548 | } |
| 3549 | } |
| 3550 | |
| 3551 | |
| 3552 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 3553 | |
| 3554 | #ifdef YYPARSE_PARAM |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3555 | # if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3556 | int yyparse (void *YYPARSE_PARAM); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3557 | # else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3558 | int yyparse (); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3559 | # endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3560 | #else /* ! YYPARSE_PARAM */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3561 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3562 | int yyparse (void); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3563 | #else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3564 | int yyparse (); |
| 3565 | #endif |
| 3566 | #endif /* ! YYPARSE_PARAM */ |
| 3567 | |
| 3568 | |
| 3569 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3570 | /* The lookahead symbol. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3571 | int yychar; |
| 3572 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3573 | /* The semantic value of the lookahead symbol. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3574 | YYSTYPE yylval; |
| 3575 | |
| 3576 | /* Number of syntax errors so far. */ |
| 3577 | int yynerrs; |
| 3578 | |
| 3579 | |
| 3580 | |
| 3581 | /*----------. |
| 3582 | | yyparse. | |
| 3583 | `----------*/ |
| 3584 | |
| 3585 | #ifdef YYPARSE_PARAM |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3586 | # if defined (__STDC__) || defined (__cplusplus) |
| 3587 | int yyparse (void *YYPARSE_PARAM) |
| 3588 | # else |
| 3589 | int yyparse (YYPARSE_PARAM) |
| 3590 | void *YYPARSE_PARAM; |
| 3591 | # endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3592 | #else /* ! YYPARSE_PARAM */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3593 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3594 | int |
| 3595 | yyparse (void) |
| 3596 | #else |
| 3597 | int |
| 3598 | yyparse () |
| 3599 | |
| 3600 | #endif |
| 3601 | #endif |
| 3602 | { |
| 3603 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3604 | register int yystate; |
| 3605 | register int yyn; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3606 | int yyresult; |
| 3607 | /* Number of tokens to shift before error messages enabled. */ |
| 3608 | int yyerrstatus; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3609 | /* Lookahead token as an internal (translated) token number. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3610 | int yytoken = 0; |
| 3611 | |
| 3612 | /* Three stacks and their tools: |
| 3613 | `yyss': related to states, |
| 3614 | `yyvs': related to semantic values, |
| 3615 | `yyls': related to locations. |
| 3616 | |
| 3617 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 3618 | to reallocate them elsewhere. */ |
| 3619 | |
| 3620 | /* The state stack. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3621 | short yyssa[YYINITDEPTH]; |
| 3622 | short *yyss = yyssa; |
| 3623 | register short *yyssp; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3624 | |
| 3625 | /* The semantic value stack. */ |
| 3626 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 3627 | YYSTYPE *yyvs = yyvsa; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3628 | register YYSTYPE *yyvsp; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3629 | |
| 3630 | |
| 3631 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3632 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3633 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3634 | YYSIZE_T yystacksize = YYINITDEPTH; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3635 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3636 | /* The variables used to return semantic value and location from the |
| 3637 | action routines. */ |
| 3638 | YYSTYPE yyval; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3639 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3640 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3641 | /* When reducing, the number of symbols on the RHS of the reduced |
| 3642 | rule. */ |
| 3643 | int yylen; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3644 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3645 | YYDPRINTF ((stderr, "Starting parse\n")); |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3646 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3647 | yystate = 0; |
| 3648 | yyerrstatus = 0; |
| 3649 | yynerrs = 0; |
| 3650 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 3651 | |
| 3652 | /* Initialize stack pointers. |
| 3653 | Waste one element of value and location stack |
| 3654 | so that they stay on the same level as the state stack. |
| 3655 | The wasted elements are never initialized. */ |
| 3656 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3657 | yyssp = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3658 | yyvsp = yyvs; |
| 3659 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3660 | goto yysetstate; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3661 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3662 | /*------------------------------------------------------------. |
| 3663 | | yynewstate -- Push a new state, which is found in yystate. | |
| 3664 | `------------------------------------------------------------*/ |
| 3665 | yynewstate: |
| 3666 | /* In all cases, when you get here, the value and location stacks |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3667 | have just been pushed. so pushing a state here evens the stacks. |
| 3668 | */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3669 | yyssp++; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3670 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3671 | yysetstate: |
| 3672 | *yyssp = yystate; |
| 3673 | |
| 3674 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3675 | { |
| 3676 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3677 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3678 | |
| 3679 | #ifdef yyoverflow |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3680 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3681 | /* Give user a chance to reallocate the stack. Use copies of |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3682 | these so that the &'s don't force the real ones into |
| 3683 | memory. */ |
| 3684 | YYSTYPE *yyvs1 = yyvs; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3685 | short *yyss1 = yyss; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3686 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3687 | |
| 3688 | /* Each stack pointer address is followed by the size of the |
| 3689 | data in use in that stack, in bytes. This used to be a |
| 3690 | conditional around just the two extra args, but that might |
| 3691 | be undefined if yyoverflow is a macro. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3692 | yyoverflow ("parser stack overflow", |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3693 | &yyss1, yysize * sizeof (*yyssp), |
| 3694 | &yyvs1, yysize * sizeof (*yyvsp), |
| 3695 | |
| 3696 | &yystacksize); |
| 3697 | |
| 3698 | yyss = yyss1; |
| 3699 | yyvs = yyvs1; |
| 3700 | } |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3701 | #else /* no yyoverflow */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3702 | # ifndef YYSTACK_RELOCATE |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3703 | goto yyoverflowlab; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3704 | # else |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3705 | /* Extend the stack our own way. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3706 | if (YYMAXDEPTH <= yystacksize) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3707 | goto yyoverflowlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3708 | yystacksize *= 2; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3709 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3710 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3711 | |
| 3712 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3713 | short *yyss1 = yyss; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3714 | union yyalloc *yyptr = |
| 3715 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 3716 | if (! yyptr) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3717 | goto yyoverflowlab; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3718 | YYSTACK_RELOCATE (yyss); |
| 3719 | YYSTACK_RELOCATE (yyvs); |
| 3720 | |
| 3721 | # undef YYSTACK_RELOCATE |
| 3722 | if (yyss1 != yyssa) |
| 3723 | YYSTACK_FREE (yyss1); |
| 3724 | } |
| 3725 | # endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3726 | #endif /* no yyoverflow */ |
| 3727 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3728 | yyssp = yyss + yysize - 1; |
| 3729 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3730 | |
| 3731 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3732 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 3733 | (unsigned long int) yystacksize)); |
| 3734 | |
| 3735 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3736 | YYABORT; |
| 3737 | } |
| 3738 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3739 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3740 | |
| 3741 | goto yybackup; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3742 | |
| 3743 | /*-----------. |
| 3744 | | yybackup. | |
| 3745 | `-----------*/ |
| 3746 | yybackup: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3747 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3748 | /* Do appropriate processing given the current state. */ |
| 3749 | /* Read a lookahead token if we need one and don't already have one. */ |
| 3750 | /* yyresume: */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3751 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3752 | /* First try to decide what to do without reference to lookahead token. */ |
| 3753 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3754 | yyn = yypact[yystate]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3755 | if (yyn == YYPACT_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3756 | goto yydefault; |
| 3757 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3758 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3759 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3760 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3761 | if (yychar == YYEMPTY) |
| 3762 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3763 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3764 | yychar = YYLEX; |
| 3765 | } |
| 3766 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3767 | if (yychar <= YYEOF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3768 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3769 | yychar = yytoken = YYEOF; |
| 3770 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3771 | } |
| 3772 | else |
| 3773 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3774 | yytoken = YYTRANSLATE (yychar); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3775 | YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3776 | } |
| 3777 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3778 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 3779 | detect an error, take that action. */ |
| 3780 | yyn += yytoken; |
| 3781 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3782 | goto yydefault; |
| 3783 | yyn = yytable[yyn]; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3784 | if (yyn <= 0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3785 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3786 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3787 | goto yyerrlab; |
| 3788 | yyn = -yyn; |
| 3789 | goto yyreduce; |
| 3790 | } |
| 3791 | |
| 3792 | if (yyn == YYFINAL) |
| 3793 | YYACCEPT; |
| 3794 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3795 | /* Shift the lookahead token. */ |
| 3796 | YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); |
| 3797 | |
| 3798 | /* Discard the token being shifted unless it is eof. */ |
| 3799 | if (yychar != YYEOF) |
| 3800 | yychar = YYEMPTY; |
| 3801 | |
| 3802 | *++yyvsp = yylval; |
| 3803 | |
| 3804 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3805 | /* Count tokens shifted since error; after three, turn off error |
| 3806 | status. */ |
| 3807 | if (yyerrstatus) |
| 3808 | yyerrstatus--; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3809 | |
| 3810 | yystate = yyn; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3811 | goto yynewstate; |
| 3812 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3813 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3814 | /*-----------------------------------------------------------. |
| 3815 | | yydefault -- do the default action for the current state. | |
| 3816 | `-----------------------------------------------------------*/ |
| 3817 | yydefault: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3818 | yyn = yydefact[yystate]; |
| 3819 | if (yyn == 0) |
| 3820 | goto yyerrlab; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3821 | goto yyreduce; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3822 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3823 | |
| 3824 | /*-----------------------------. |
| 3825 | | yyreduce -- Do a reduction. | |
| 3826 | `-----------------------------*/ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3827 | yyreduce: |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3828 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3829 | yylen = yyr2[yyn]; |
| 3830 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3831 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3832 | `$$ = $1'. |
| 3833 | |
| 3834 | Otherwise, the following line sets YYVAL to garbage. |
| 3835 | This behavior is undocumented and Bison |
| 3836 | users should not rely upon it. Assigning to YYVAL |
| 3837 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3838 | GCC warning that YYVAL may be used uninitialized. */ |
| 3839 | yyval = yyvsp[1-yylen]; |
| 3840 | |
| 3841 | |
| 3842 | YY_REDUCE_PRINT (yyn); |
| 3843 | switch (yyn) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3844 | { |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3845 | case 3: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3846 | #line 1891 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3847 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3848 | if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3849 | error("Value too large for type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3850 | yyval.SIntVal = (int32_t)yyvsp[0].UIntVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3851 | ;} |
| 3852 | break; |
| 3853 | |
| 3854 | case 5: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3855 | #line 1900 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3856 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3857 | if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3858 | error("Value too large for type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3859 | yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3860 | ;} |
| 3861 | break; |
| 3862 | |
| 3863 | case 26: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3864 | #line 1922 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3865 | { yyval.IPred = ICmpInst::ICMP_EQ; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3866 | break; |
| 3867 | |
| 3868 | case 27: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3869 | #line 1922 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3870 | { yyval.IPred = ICmpInst::ICMP_NE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3871 | break; |
| 3872 | |
| 3873 | case 28: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3874 | #line 1923 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3875 | { yyval.IPred = ICmpInst::ICMP_SLT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3876 | break; |
| 3877 | |
| 3878 | case 29: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3879 | #line 1923 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3880 | { yyval.IPred = ICmpInst::ICMP_SGT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3881 | break; |
| 3882 | |
| 3883 | case 30: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3884 | #line 1924 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3885 | { yyval.IPred = ICmpInst::ICMP_SLE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3886 | break; |
| 3887 | |
| 3888 | case 31: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3889 | #line 1924 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3890 | { yyval.IPred = ICmpInst::ICMP_SGE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3891 | break; |
| 3892 | |
| 3893 | case 32: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3894 | #line 1925 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3895 | { yyval.IPred = ICmpInst::ICMP_ULT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3896 | break; |
| 3897 | |
| 3898 | case 33: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3899 | #line 1925 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3900 | { yyval.IPred = ICmpInst::ICMP_UGT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3901 | break; |
| 3902 | |
| 3903 | case 34: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3904 | #line 1926 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3905 | { yyval.IPred = ICmpInst::ICMP_ULE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3906 | break; |
| 3907 | |
| 3908 | case 35: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3909 | #line 1926 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3910 | { yyval.IPred = ICmpInst::ICMP_UGE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3911 | break; |
| 3912 | |
| 3913 | case 36: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3914 | #line 1930 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3915 | { yyval.FPred = FCmpInst::FCMP_OEQ; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3916 | break; |
| 3917 | |
| 3918 | case 37: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3919 | #line 1930 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3920 | { yyval.FPred = FCmpInst::FCMP_ONE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3921 | break; |
| 3922 | |
| 3923 | case 38: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3924 | #line 1931 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3925 | { yyval.FPred = FCmpInst::FCMP_OLT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3926 | break; |
| 3927 | |
| 3928 | case 39: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3929 | #line 1931 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3930 | { yyval.FPred = FCmpInst::FCMP_OGT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3931 | break; |
| 3932 | |
| 3933 | case 40: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3934 | #line 1932 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3935 | { yyval.FPred = FCmpInst::FCMP_OLE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3936 | break; |
| 3937 | |
| 3938 | case 41: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3939 | #line 1932 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3940 | { yyval.FPred = FCmpInst::FCMP_OGE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3941 | break; |
| 3942 | |
| 3943 | case 42: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3944 | #line 1933 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3945 | { yyval.FPred = FCmpInst::FCMP_ORD; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3946 | break; |
| 3947 | |
| 3948 | case 43: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3949 | #line 1933 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3950 | { yyval.FPred = FCmpInst::FCMP_UNO; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3951 | break; |
| 3952 | |
| 3953 | case 44: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3954 | #line 1934 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3955 | { yyval.FPred = FCmpInst::FCMP_UEQ; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3956 | break; |
| 3957 | |
| 3958 | case 45: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3959 | #line 1934 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3960 | { yyval.FPred = FCmpInst::FCMP_UNE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3961 | break; |
| 3962 | |
| 3963 | case 46: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3964 | #line 1935 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3965 | { yyval.FPred = FCmpInst::FCMP_ULT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3966 | break; |
| 3967 | |
| 3968 | case 47: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3969 | #line 1935 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3970 | { yyval.FPred = FCmpInst::FCMP_UGT; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3971 | break; |
| 3972 | |
| 3973 | case 48: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3974 | #line 1936 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3975 | { yyval.FPred = FCmpInst::FCMP_ULE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3976 | break; |
| 3977 | |
| 3978 | case 49: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3979 | #line 1936 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3980 | { yyval.FPred = FCmpInst::FCMP_UGE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3981 | break; |
| 3982 | |
| 3983 | case 50: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3984 | #line 1937 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3985 | { yyval.FPred = FCmpInst::FCMP_TRUE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3986 | break; |
| 3987 | |
| 3988 | case 51: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3989 | #line 1938 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 3990 | { yyval.FPred = FCmpInst::FCMP_FALSE; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3991 | break; |
| 3992 | |
| 3993 | case 81: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3994 | #line 1969 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3995 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 3996 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 3997 | ;} |
| 3998 | break; |
| 3999 | |
| 4000 | case 82: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4001 | #line 1972 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4002 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4003 | yyval.StrVal = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4004 | ;} |
| 4005 | break; |
| 4006 | |
| 4007 | case 83: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4008 | #line 1977 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4009 | { yyval.Linkage = GlobalValue::InternalLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4010 | break; |
| 4011 | |
| 4012 | case 84: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4013 | #line 1978 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4014 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4015 | break; |
| 4016 | |
| 4017 | case 85: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4018 | #line 1979 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4019 | { yyval.Linkage = GlobalValue::WeakLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4020 | break; |
| 4021 | |
| 4022 | case 86: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4023 | #line 1980 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4024 | { yyval.Linkage = GlobalValue::AppendingLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4025 | break; |
| 4026 | |
| 4027 | case 87: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4028 | #line 1981 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4029 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4030 | break; |
| 4031 | |
| 4032 | case 88: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4033 | #line 1982 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4034 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4035 | break; |
| 4036 | |
| 4037 | case 89: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4038 | #line 1983 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4039 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4040 | break; |
| 4041 | |
| 4042 | case 90: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4043 | #line 1984 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4044 | { yyval.Linkage = GlobalValue::ExternalLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4045 | break; |
| 4046 | |
| 4047 | case 91: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4048 | #line 1988 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4049 | { yyval.UIntVal = lastCallingConv = OldCallingConv::C; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4050 | break; |
| 4051 | |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4052 | case 92: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4053 | #line 1989 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4054 | { yyval.UIntVal = lastCallingConv = OldCallingConv::C; ;} |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4055 | break; |
| 4056 | |
| 4057 | case 93: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4058 | #line 1990 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4059 | { yyval.UIntVal = lastCallingConv = OldCallingConv::CSRet; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4060 | break; |
| 4061 | |
| 4062 | case 94: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4063 | #line 1991 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4064 | { yyval.UIntVal = lastCallingConv = OldCallingConv::Fast; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4065 | break; |
| 4066 | |
| 4067 | case 95: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4068 | #line 1992 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4069 | { yyval.UIntVal = lastCallingConv = OldCallingConv::Cold; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4070 | break; |
| 4071 | |
| 4072 | case 96: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4073 | #line 1993 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4074 | { yyval.UIntVal = lastCallingConv = OldCallingConv::X86_StdCall; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4075 | break; |
| 4076 | |
| 4077 | case 97: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4078 | #line 1994 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4079 | { yyval.UIntVal = lastCallingConv = OldCallingConv::X86_FastCall; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4080 | break; |
| 4081 | |
| 4082 | case 98: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4083 | #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] | 4084 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4085 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4086 | error("Calling conv too large"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4087 | yyval.UIntVal = lastCallingConv = yyvsp[0].UInt64Val; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4088 | ;} |
| 4089 | break; |
| 4090 | |
| 4091 | case 99: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4092 | #line 2005 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4093 | { yyval.UIntVal = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4094 | break; |
| 4095 | |
| 4096 | case 100: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4097 | #line 2006 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4098 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4099 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 4100 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4101 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4102 | ;} |
| 4103 | break; |
| 4104 | |
| 4105 | case 101: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4106 | #line 2014 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4107 | { yyval.UIntVal = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4108 | break; |
| 4109 | |
| 4110 | case 102: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4111 | #line 2015 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4112 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4113 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 4114 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4115 | error("Alignment must be a power of two"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4116 | ;} |
| 4117 | break; |
| 4118 | |
| 4119 | case 103: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4120 | #line 2023 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4121 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4122 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 4123 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4124 | error("Invalid character in section name"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4125 | yyval.StrVal = yyvsp[0].StrVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4126 | ;} |
| 4127 | break; |
| 4128 | |
| 4129 | case 104: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4130 | #line 2032 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4131 | { yyval.StrVal = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4132 | break; |
| 4133 | |
| 4134 | case 105: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4135 | #line 2033 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4136 | { yyval.StrVal = yyvsp[0].StrVal; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4137 | break; |
| 4138 | |
| 4139 | case 106: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4140 | #line 2040 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4141 | {;} |
| 4142 | break; |
| 4143 | |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4144 | case 107: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4145 | #line 2041 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4146 | {;} |
| 4147 | break; |
| 4148 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4149 | case 108: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4150 | #line 2045 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4151 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4152 | CurGV->setSection(yyvsp[0].StrVal); |
| 4153 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4154 | ;} |
| 4155 | break; |
| 4156 | |
| 4157 | case 109: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4158 | #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] | 4159 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4160 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4161 | error("Alignment must be a power of two"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4162 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4163 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4164 | ;} |
| 4165 | break; |
| 4166 | |
| 4167 | case 111: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4168 | #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] | 4169 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4170 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 4171 | yyval.TypeVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4172 | ;} |
| 4173 | break; |
| 4174 | |
| 4175 | case 113: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4176 | #line 2074 "/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 | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4178 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 4179 | yyval.TypeVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4180 | ;} |
| 4181 | break; |
| 4182 | |
| 4183 | case 114: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4184 | #line 2081 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4185 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4186 | if (!UpRefs.empty()) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4187 | error("Invalid upreference in type: " + (*yyvsp[0].TypeVal.PAT)->getDescription()); |
| 4188 | yyval.TypeVal = yyvsp[0].TypeVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4189 | ;} |
| 4190 | break; |
| 4191 | |
| 4192 | case 127: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4193 | #line 2095 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4194 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4195 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 4196 | yyval.TypeVal.S.copy(yyvsp[0].PrimType.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4197 | ;} |
| 4198 | break; |
| 4199 | |
| 4200 | case 128: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4201 | #line 2099 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4202 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4203 | yyval.TypeVal.PAT = new PATypeHolder(OpaqueType::get()); |
| 4204 | yyval.TypeVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4205 | ;} |
| 4206 | break; |
| 4207 | |
| 4208 | case 129: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4209 | #line 2103 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4210 | { // Named types are also simple types... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4211 | yyval.TypeVal.S.copy(getTypeSign(yyvsp[0].ValIDVal)); |
| 4212 | const Type* tmp = getType(yyvsp[0].ValIDVal); |
| 4213 | yyval.TypeVal.PAT = new PATypeHolder(tmp); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4214 | ;} |
| 4215 | break; |
| 4216 | |
| 4217 | case 130: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4218 | #line 2108 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4219 | { // Type UpReference |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4220 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4221 | error("Value out of range"); |
| 4222 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4223 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 4224 | yyval.TypeVal.PAT = new PATypeHolder(OT); |
| 4225 | yyval.TypeVal.S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4226 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4227 | ;} |
| 4228 | break; |
| 4229 | |
| 4230 | case 131: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4231 | #line 2117 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4232 | { // Function derived type? |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4233 | yyval.TypeVal.S.makeComposite(yyvsp[-3].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4234 | std::vector<const Type*> Params; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4235 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(), |
| 4236 | E = yyvsp[-1].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4237 | Params.push_back(I->PAT->get()); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4238 | yyval.TypeVal.S.add(I->S); |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4239 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4240 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 4241 | if (isVarArg) Params.pop_back(); |
| 4242 | |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 4243 | ParamAttrsList *PAL = 0; |
| 4244 | if (lastCallingConv == OldCallingConv::CSRet) { |
| 4245 | ParamAttrsVector Attrs; |
| 4246 | ParamAttrsWithIndex PAWI; |
| 4247 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 4248 | Attrs.push_back(PAWI); |
| 4249 | PAL = ParamAttrsList::get(Attrs); |
| 4250 | } |
| 4251 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4252 | const FunctionType *FTy = |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4253 | FunctionType::get(yyvsp[-3].TypeVal.PAT->get(), Params, isVarArg, PAL); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4254 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4255 | yyval.TypeVal.PAT = new PATypeHolder( HandleUpRefs(FTy, yyval.TypeVal.S) ); |
| 4256 | delete yyvsp[-3].TypeVal.PAT; // Delete the return type handle |
| 4257 | delete yyvsp[-1].TypeList; // Delete the argument list |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4258 | ;} |
| 4259 | break; |
| 4260 | |
| 4261 | case 132: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4262 | #line 2144 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4263 | { // Sized array type? |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4264 | yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 4265 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(ArrayType::get(yyvsp[-1].TypeVal.PAT->get(), |
| 4266 | (unsigned)yyvsp[-3].UInt64Val), yyval.TypeVal.S)); |
| 4267 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4268 | ;} |
| 4269 | break; |
| 4270 | |
| 4271 | case 133: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4272 | #line 2150 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4273 | { // Vector type? |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4274 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal.PAT->get(); |
| 4275 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4276 | error("Unsigned result not equal to signed result"); |
| 4277 | if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint())) |
| 4278 | error("Elements of a VectorType must be integer or floating point"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4279 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4280 | error("VectorType length should be a power of 2"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4281 | yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 4282 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, |
| 4283 | (unsigned)yyvsp[-3].UInt64Val), yyval.TypeVal.S)); |
| 4284 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4285 | ;} |
| 4286 | break; |
| 4287 | |
| 4288 | case 134: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4289 | #line 2163 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4290 | { // Structure type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4291 | std::vector<const Type*> Elements; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4292 | yyval.TypeVal.S.makeComposite(); |
| 4293 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(), |
| 4294 | E = yyvsp[-1].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4295 | Elements.push_back(I->PAT->get()); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4296 | yyval.TypeVal.S.add(I->S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4297 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4298 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), yyval.TypeVal.S)); |
| 4299 | delete yyvsp[-1].TypeList; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4300 | ;} |
| 4301 | break; |
| 4302 | |
| 4303 | case 135: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4304 | #line 2174 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4305 | { // Empty structure type? |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4306 | yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
| 4307 | yyval.TypeVal.S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4308 | ;} |
| 4309 | break; |
| 4310 | |
| 4311 | case 136: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4312 | #line 2178 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4313 | { // Packed Structure type? |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4314 | yyval.TypeVal.S.makeComposite(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4315 | std::vector<const Type*> Elements; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4316 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-2].TypeList->begin(), |
| 4317 | E = yyvsp[-2].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4318 | Elements.push_back(I->PAT->get()); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4319 | yyval.TypeVal.S.add(I->S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4320 | delete I->PAT; |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 4321 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4322 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true), |
| 4323 | yyval.TypeVal.S)); |
| 4324 | delete yyvsp[-2].TypeList; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4325 | ;} |
| 4326 | break; |
| 4327 | |
| 4328 | case 137: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4329 | #line 2191 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4330 | { // Empty packed structure type? |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4331 | yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true)); |
| 4332 | yyval.TypeVal.S.makeComposite(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4333 | ;} |
| 4334 | break; |
| 4335 | |
| 4336 | case 138: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4337 | #line 2195 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4338 | { // Pointer type? |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4339 | if (yyvsp[-1].TypeVal.PAT->get() == Type::LabelTy) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4340 | error("Cannot form a pointer to a basic block"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4341 | yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 4342 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(PointerType::get(yyvsp[-1].TypeVal.PAT->get()), |
| 4343 | yyval.TypeVal.S)); |
| 4344 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4345 | ;} |
| 4346 | break; |
| 4347 | |
| 4348 | case 139: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4349 | #line 2209 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4350 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4351 | yyval.TypeList = new std::list<PATypeInfo>(); |
| 4352 | yyval.TypeList->push_back(yyvsp[0].TypeVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4353 | ;} |
| 4354 | break; |
| 4355 | |
| 4356 | case 140: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4357 | #line 2213 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4358 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4359 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4360 | ;} |
| 4361 | break; |
| 4362 | |
| 4363 | case 142: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4364 | #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] | 4365 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4366 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4367 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4368 | VoidTI.S.makeSignless(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4369 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(VoidTI); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4370 | ;} |
| 4371 | break; |
| 4372 | |
| 4373 | case 143: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4374 | #line 2227 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4375 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4376 | yyval.TypeList = new std::list<PATypeInfo>(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4377 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4378 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4379 | VoidTI.S.makeSignless(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4380 | yyval.TypeList->push_back(VoidTI); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4381 | ;} |
| 4382 | break; |
| 4383 | |
| 4384 | case 144: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4385 | #line 2234 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4386 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4387 | yyval.TypeList = new std::list<PATypeInfo>(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4388 | ;} |
| 4389 | break; |
| 4390 | |
| 4391 | case 145: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4392 | #line 2246 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4393 | { // Nonempty unsized arr |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4394 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4395 | if (ATy == 0) |
| 4396 | error("Cannot make array constant with type: '" + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4397 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4398 | const Type *ETy = ATy->getElementType(); |
| 4399 | int NumElements = ATy->getNumElements(); |
| 4400 | |
| 4401 | // Verify that we have the correct size... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4402 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4403 | error("Type mismatch: constant sized array initialized with " + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4404 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4405 | itostr(NumElements) + ""); |
| 4406 | |
| 4407 | // Verify all elements are correct type! |
| 4408 | std::vector<Constant*> Elems; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4409 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4410 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4411 | const Type* ValTy = C->getType(); |
| 4412 | if (ETy != ValTy) |
| 4413 | error("Element #" + utostr(i) + " is not of type '" + |
| 4414 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4415 | ValTy->getDescription() + "'"); |
| 4416 | Elems.push_back(C); |
| 4417 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4418 | yyval.ConstVal.C = ConstantArray::get(ATy, Elems); |
| 4419 | yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 4420 | delete yyvsp[-3].TypeVal.PAT; |
| 4421 | delete yyvsp[-1].ConstVector; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4422 | ;} |
| 4423 | break; |
| 4424 | |
| 4425 | case 146: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4426 | #line 2276 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4427 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4428 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4429 | if (ATy == 0) |
| 4430 | error("Cannot make array constant with type: '" + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4431 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4432 | int NumElements = ATy->getNumElements(); |
| 4433 | if (NumElements != -1 && NumElements != 0) |
| 4434 | error("Type mismatch: constant sized array initialized with 0" |
| 4435 | " arguments, but has size of " + itostr(NumElements) +""); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4436 | yyval.ConstVal.C = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 4437 | yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S); |
| 4438 | delete yyvsp[-2].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4439 | ;} |
| 4440 | break; |
| 4441 | |
| 4442 | case 147: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4443 | #line 2289 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4444 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4445 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4446 | if (ATy == 0) |
| 4447 | error("Cannot make array constant with type: '" + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4448 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4449 | int NumElements = ATy->getNumElements(); |
| 4450 | const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType()); |
| 4451 | if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8) |
| 4452 | error("String arrays require type i8, not '" + ETy->getDescription() + |
| 4453 | "'"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4454 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4455 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4456 | error("Can't build string constant of size " + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4457 | itostr((int)(EndStr-yyvsp[0].StrVal)) + " when array has size " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4458 | itostr(NumElements) + ""); |
| 4459 | std::vector<Constant*> Vals; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4460 | for (char *C = (char *)yyvsp[0].StrVal; C != (char *)EndStr; ++C) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4461 | Vals.push_back(ConstantInt::get(ETy, *C)); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4462 | free(yyvsp[0].StrVal); |
| 4463 | yyval.ConstVal.C = ConstantArray::get(ATy, Vals); |
| 4464 | yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S); |
| 4465 | delete yyvsp[-2].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4466 | ;} |
| 4467 | break; |
| 4468 | |
| 4469 | case 148: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4470 | #line 2312 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4471 | { // Nonempty unsized arr |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4472 | const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4473 | if (PTy == 0) |
| 4474 | error("Cannot make packed constant with type: '" + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4475 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4476 | const Type *ETy = PTy->getElementType(); |
| 4477 | int NumElements = PTy->getNumElements(); |
| 4478 | // Verify that we have the correct size... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4479 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4480 | error("Type mismatch: constant sized packed initialized with " + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4481 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4482 | itostr(NumElements) + ""); |
| 4483 | // Verify all elements are correct type! |
| 4484 | std::vector<Constant*> Elems; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4485 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4486 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4487 | const Type* ValTy = C->getType(); |
| 4488 | if (ETy != ValTy) |
| 4489 | error("Element #" + utostr(i) + " is not of type '" + |
| 4490 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 4491 | ValTy->getDescription() + "'"); |
| 4492 | Elems.push_back(C); |
| 4493 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4494 | yyval.ConstVal.C = ConstantVector::get(PTy, Elems); |
| 4495 | yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 4496 | delete yyvsp[-3].TypeVal.PAT; |
| 4497 | delete yyvsp[-1].ConstVector; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4498 | ;} |
| 4499 | break; |
| 4500 | |
| 4501 | case 149: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4502 | #line 2340 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4503 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4504 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4505 | if (STy == 0) |
| 4506 | error("Cannot make struct constant with type: '" + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4507 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
| 4508 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4509 | error("Illegal number of initializers for structure type"); |
| 4510 | |
| 4511 | // Check to ensure that constants are compatible with the type initializer! |
| 4512 | std::vector<Constant*> Fields; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4513 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) { |
| 4514 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4515 | if (C->getType() != STy->getElementType(i)) |
| 4516 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4517 | "' for element #" + utostr(i) + " of structure initializer"); |
| 4518 | Fields.push_back(C); |
| 4519 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4520 | yyval.ConstVal.C = ConstantStruct::get(STy, Fields); |
| 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 150: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4528 | #line 2362 "/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 | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4530 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].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 | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4533 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4534 | if (STy->getNumContainedTypes() != 0) |
| 4535 | error("Illegal number of initializers for structure type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4536 | yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4537 | yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S); |
| 4538 | delete yyvsp[-2].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4539 | ;} |
| 4540 | break; |
| 4541 | |
| 4542 | case 151: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4543 | #line 2373 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4544 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4545 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4546 | if (STy == 0) |
| 4547 | error("Cannot make packed struct constant with type: '" + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4548 | yyvsp[-5].TypeVal.PAT->get()->getDescription() + "'"); |
| 4549 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4550 | error("Illegal number of initializers for packed structure type"); |
| 4551 | |
| 4552 | // Check to ensure that constants are compatible with the type initializer! |
| 4553 | std::vector<Constant*> Fields; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4554 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) { |
| 4555 | Constant *C = (*yyvsp[-2].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4556 | if (C->getType() != STy->getElementType(i)) |
| 4557 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 4558 | "' for element #" + utostr(i) + " of packed struct initializer"); |
| 4559 | Fields.push_back(C); |
| 4560 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4561 | yyval.ConstVal.C = ConstantStruct::get(STy, Fields); |
| 4562 | yyval.ConstVal.S.copy(yyvsp[-5].TypeVal.S); |
| 4563 | delete yyvsp[-5].TypeVal.PAT; |
| 4564 | delete yyvsp[-2].ConstVector; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4565 | ;} |
| 4566 | break; |
| 4567 | |
| 4568 | case 152: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4569 | #line 2395 "/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 | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4571 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].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 | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4574 | yyvsp[-4].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4575 | if (STy->getNumContainedTypes() != 0) |
| 4576 | error("Illegal number of initializers for packed structure type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4577 | yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4578 | yyval.ConstVal.S.copy(yyvsp[-4].TypeVal.S); |
| 4579 | delete yyvsp[-4].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4580 | ;} |
| 4581 | break; |
| 4582 | |
| 4583 | case 153: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4584 | #line 2406 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4585 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4586 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4587 | if (PTy == 0) |
| 4588 | error("Cannot make null pointer constant with type: '" + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4589 | yyvsp[-1].TypeVal.PAT->get()->getDescription() + "'"); |
| 4590 | yyval.ConstVal.C = ConstantPointerNull::get(PTy); |
| 4591 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4592 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4593 | ;} |
| 4594 | break; |
| 4595 | |
| 4596 | case 154: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4597 | #line 2415 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4598 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4599 | yyval.ConstVal.C = UndefValue::get(yyvsp[-1].TypeVal.PAT->get()); |
| 4600 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4601 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4602 | ;} |
| 4603 | break; |
| 4604 | |
| 4605 | case 155: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4606 | #line 2420 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4607 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4608 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4609 | if (Ty == 0) |
| 4610 | error("Global const reference must be a pointer type, not" + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4611 | yyvsp[-1].TypeVal.PAT->get()->getDescription()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4612 | |
| 4613 | // ConstExprs can exist in the body of a function, thus creating |
| 4614 | // GlobalValues whenever they refer to a variable. Because we are in |
| 4615 | // the context of a function, getExistingValue will search the functions |
| 4616 | // symbol table instead of the module symbol table for the global symbol, |
| 4617 | // which throws things all off. To get around this, we just tell |
| 4618 | // getExistingValue that we are at global scope here. |
| 4619 | // |
| 4620 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 4621 | CurFun.CurrentFunction = 0; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4622 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4623 | Value *V = getExistingValue(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4624 | CurFun.CurrentFunction = SavedCurFn; |
| 4625 | |
| 4626 | // If this is an initializer for a constant pointer, which is referencing a |
| 4627 | // (currently) undefined variable, create a stub now that shall be replaced |
| 4628 | // in the future with the right type of variable. |
| 4629 | // |
| 4630 | if (V == 0) { |
| 4631 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers"); |
| 4632 | const PointerType *PT = cast<PointerType>(Ty); |
| 4633 | |
| 4634 | // First check to see if the forward references value is already created! |
| 4635 | PerModuleInfo::GlobalRefsType::iterator I = |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4636 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4637 | |
| 4638 | if (I != CurModule.GlobalRefs.end()) { |
| 4639 | V = I->second; // Placeholder already exists, use it... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4640 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4641 | } else { |
| 4642 | std::string Name; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4643 | if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4644 | |
| 4645 | // Create the forward referenced global. |
| 4646 | GlobalValue *GV; |
| 4647 | if (const FunctionType *FTy = |
| 4648 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 4649 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 4650 | CurModule.CurrentModule); |
| 4651 | } else { |
| 4652 | GV = new GlobalVariable(PT->getElementType(), false, |
| 4653 | GlobalValue::ExternalLinkage, 0, |
| 4654 | Name, CurModule.CurrentModule); |
| 4655 | } |
| 4656 | |
| 4657 | // Keep track of the fact that we have a forward ref to recycle it |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4658 | 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] | 4659 | V = GV; |
| 4660 | } |
| 4661 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4662 | yyval.ConstVal.C = cast<GlobalValue>(V); |
| 4663 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4664 | delete yyvsp[-1].TypeVal.PAT; // Free the type handle |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4665 | ;} |
| 4666 | break; |
| 4667 | |
| 4668 | case 156: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4669 | #line 2479 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4670 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4671 | if (yyvsp[-1].TypeVal.PAT->get() != yyvsp[0].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4672 | error("Mismatched types for constant expression"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4673 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 4674 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4675 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4676 | ;} |
| 4677 | break; |
| 4678 | |
| 4679 | case 157: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4680 | #line 2486 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4681 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4682 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4683 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 4684 | error("Cannot create a null initialized value of this type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4685 | yyval.ConstVal.C = Constant::getNullValue(Ty); |
| 4686 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4687 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4688 | ;} |
| 4689 | break; |
| 4690 | |
| 4691 | case 158: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4692 | #line 2494 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4693 | { // integral constants |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4694 | const Type *Ty = yyvsp[-1].PrimType.T; |
| 4695 | if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].SInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4696 | error("Constant value doesn't fit in type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4697 | yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].SInt64Val); |
| 4698 | yyval.ConstVal.S.makeSigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4699 | ;} |
| 4700 | break; |
| 4701 | |
| 4702 | case 159: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4703 | #line 2501 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4704 | { // integral constants |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4705 | const Type *Ty = yyvsp[-1].PrimType.T; |
| 4706 | if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4707 | error("Constant value doesn't fit in type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4708 | yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].UInt64Val); |
| 4709 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4710 | ;} |
| 4711 | break; |
| 4712 | |
| 4713 | case 160: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4714 | #line 2508 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4715 | { // Boolean constants |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4716 | yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, true); |
| 4717 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4718 | ;} |
| 4719 | break; |
| 4720 | |
| 4721 | case 161: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4722 | #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] | 4723 | { // Boolean constants |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4724 | yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, false); |
| 4725 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4726 | ;} |
| 4727 | break; |
| 4728 | |
| 4729 | case 162: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4730 | #line 2516 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4731 | { // Float & Double constants |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4732 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType.T, yyvsp[0].FPVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4733 | error("Floating point constant invalid for type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4734 | yyval.ConstVal.C = ConstantFP::get(yyvsp[-1].PrimType.T, yyvsp[0].FPVal); |
| 4735 | yyval.ConstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4736 | ;} |
| 4737 | break; |
| 4738 | |
| 4739 | case 163: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4740 | #line 2525 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4741 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4742 | const Type* SrcTy = yyvsp[-3].ConstVal.C->getType(); |
| 4743 | const Type* DstTy = yyvsp[-1].TypeVal.PAT->get(); |
| 4744 | Signedness SrcSign(yyvsp[-3].ConstVal.S); |
| 4745 | Signedness DstSign(yyvsp[-1].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4746 | if (!SrcTy->isFirstClassType()) |
| 4747 | error("cast constant expression from a non-primitive type: '" + |
| 4748 | SrcTy->getDescription() + "'"); |
| 4749 | if (!DstTy->isFirstClassType()) |
| 4750 | error("cast constant expression to a non-primitive type: '" + |
| 4751 | DstTy->getDescription() + "'"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4752 | yyval.ConstVal.C = cast<Constant>(getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal.C, SrcSign, DstTy, DstSign)); |
| 4753 | yyval.ConstVal.S.copy(DstSign); |
| 4754 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4755 | ;} |
| 4756 | break; |
| 4757 | |
| 4758 | case 164: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4759 | #line 2540 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4760 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4761 | const Type *Ty = yyvsp[-2].ConstVal.C->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4762 | if (!isa<PointerType>(Ty)) |
| 4763 | error("GetElementPtr requires a pointer operand"); |
| 4764 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4765 | std::vector<Constant*> CIndices; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4766 | upgradeGEPCEIndices(yyvsp[-2].ConstVal.C->getType(), yyvsp[-1].ValueList, CIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4767 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4768 | delete yyvsp[-1].ValueList; |
| 4769 | yyval.ConstVal.C = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal.C, &CIndices[0], CIndices.size()); |
| 4770 | yyval.ConstVal.S.copy(getElementSign(yyvsp[-2].ConstVal, CIndices)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4771 | ;} |
| 4772 | break; |
| 4773 | |
| 4774 | case 165: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4775 | #line 2552 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4776 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4777 | if (!yyvsp[-5].ConstVal.C->getType()->isInteger() || |
| 4778 | cast<IntegerType>(yyvsp[-5].ConstVal.C->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4779 | error("Select condition must be bool type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4780 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4781 | error("Select operand types must match"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4782 | yyval.ConstVal.C = ConstantExpr::getSelect(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4783 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4784 | ;} |
| 4785 | break; |
| 4786 | |
| 4787 | case 166: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4788 | #line 2561 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4789 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4790 | const Type *Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4791 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4792 | error("Binary operator types must match"); |
| 4793 | // First, make sure we're dealing with the right opcode by upgrading from |
| 4794 | // obsolete versions. |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4795 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4796 | |
| 4797 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 4798 | // To retain backward compatibility with these early compilers, we emit a |
| 4799 | // cast to the appropriate integer type automatically if we are in the |
| 4800 | // broken case. See PR424 for more information. |
| 4801 | if (!isa<PointerType>(Ty)) { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4802 | 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] | 4803 | } else { |
| 4804 | const Type *IntPtrTy = 0; |
| 4805 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 4806 | case Module::Pointer32: IntPtrTy = Type::Int32Ty; break; |
| 4807 | case Module::Pointer64: IntPtrTy = Type::Int64Ty; break; |
| 4808 | default: error("invalid pointer binary constant expr"); |
| 4809 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4810 | yyval.ConstVal.C = ConstantExpr::get(Opcode, |
| 4811 | ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-3].ConstVal.C, IntPtrTy), |
| 4812 | ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-1].ConstVal.C, IntPtrTy)); |
| 4813 | yyval.ConstVal.C = ConstantExpr::getCast(Instruction::IntToPtr, yyval.ConstVal.C, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4814 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4815 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4816 | ;} |
| 4817 | break; |
| 4818 | |
| 4819 | case 167: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4820 | #line 2589 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4821 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4822 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4823 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4824 | error("Logical operator types must match"); |
| 4825 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4826 | if (!isa<VectorType>(Ty) || |
| 4827 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4828 | error("Logical operator requires integer operands"); |
| 4829 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4830 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); |
| 4831 | yyval.ConstVal.C = ConstantExpr::get(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4832 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4833 | ;} |
| 4834 | break; |
| 4835 | |
| 4836 | case 168: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4837 | #line 2602 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4838 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4839 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4840 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4841 | error("setcc operand types must match"); |
| 4842 | unsigned short pred; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4843 | Instruction::OtherOps Opcode = getCompareOp(yyvsp[-5].BinaryOpVal, pred, Ty, yyvsp[-3].ConstVal.S); |
| 4844 | yyval.ConstVal.C = ConstantExpr::getCompare(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4845 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4846 | ;} |
| 4847 | break; |
| 4848 | |
| 4849 | case 169: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4850 | #line 2611 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4851 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4852 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4853 | error("icmp operand types must match"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4854 | yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].IPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4855 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4856 | ;} |
| 4857 | break; |
| 4858 | |
| 4859 | case 170: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4860 | #line 2617 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4861 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4862 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4863 | error("fcmp operand types must match"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4864 | yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].FPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4865 | yyval.ConstVal.S.makeUnsigned(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4866 | ;} |
| 4867 | break; |
| 4868 | |
| 4869 | case 171: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4870 | #line 2623 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4871 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4872 | if (!yyvsp[-1].ConstVal.C->getType()->isInteger() || |
| 4873 | cast<IntegerType>(yyvsp[-1].ConstVal.C->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4874 | error("Shift count for shift constant must be unsigned byte"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4875 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4876 | if (!yyvsp[-3].ConstVal.C->getType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4877 | error("Shift constant expression requires integer operand"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4878 | Constant *ShiftAmt = ConstantExpr::getZExt(yyvsp[-1].ConstVal.C, Ty); |
| 4879 | yyval.ConstVal.C = ConstantExpr::get(getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S), yyvsp[-3].ConstVal.C, ShiftAmt); |
| 4880 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4881 | ;} |
| 4882 | break; |
| 4883 | |
| 4884 | case 172: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4885 | #line 2634 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4886 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4887 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4888 | error("Invalid extractelement operands"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4889 | yyval.ConstVal.C = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4890 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4891 | ;} |
| 4892 | break; |
| 4893 | |
| 4894 | case 173: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4895 | #line 2640 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4896 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4897 | 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] | 4898 | error("Invalid insertelement operands"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4899 | yyval.ConstVal.C = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4900 | yyval.ConstVal.S.copy(yyvsp[-5].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4901 | ;} |
| 4902 | break; |
| 4903 | |
| 4904 | case 174: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4905 | #line 2646 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4906 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4907 | 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] | 4908 | error("Invalid shufflevector operands"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4909 | yyval.ConstVal.C = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4910 | yyval.ConstVal.S.copy(yyvsp[-5].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4911 | ;} |
| 4912 | break; |
| 4913 | |
| 4914 | case 175: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4915 | #line 2657 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4916 | { (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4917 | break; |
| 4918 | |
| 4919 | case 176: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4920 | #line 2658 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4921 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4922 | yyval.ConstVector = new std::vector<ConstInfo>(); |
| 4923 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4924 | ;} |
| 4925 | break; |
| 4926 | |
| 4927 | case 177: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4928 | #line 2667 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4929 | { yyval.BoolVal = false; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4930 | break; |
| 4931 | |
| 4932 | case 178: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4933 | #line 2668 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4934 | { yyval.BoolVal = true; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4935 | break; |
| 4936 | |
| 4937 | case 179: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4938 | #line 2680 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4939 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4940 | yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4941 | CurModule.ModuleDone(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4942 | ;} |
| 4943 | break; |
| 4944 | |
| 4945 | case 180: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4946 | #line 2689 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4947 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; CurFun.FunctionDone(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4948 | break; |
| 4949 | |
| 4950 | case 181: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4951 | #line 2690 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4952 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4953 | break; |
| 4954 | |
| 4955 | case 182: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4956 | #line 2691 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4957 | { yyval.ModuleVal = yyvsp[-3].ModuleVal; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4958 | break; |
| 4959 | |
| 4960 | case 183: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4961 | #line 2692 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 4962 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4963 | break; |
| 4964 | |
| 4965 | case 184: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4966 | #line 2693 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4967 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4968 | yyval.ModuleVal = CurModule.CurrentModule; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4969 | // Emit an error if there are any unresolved types left. |
| 4970 | if (!CurModule.LateResolveTypes.empty()) { |
| 4971 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 4972 | if (DID.Type == ValID::NameVal) { |
| 4973 | error("Reference to an undefined type: '"+DID.getName() + "'"); |
| 4974 | } else { |
| 4975 | error("Reference to an undefined type: #" + itostr(DID.Num)); |
| 4976 | } |
| 4977 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4978 | ;} |
| 4979 | break; |
| 4980 | |
| 4981 | case 185: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4982 | #line 2709 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 4983 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4984 | // Eagerly resolve types. This is not an optimization, this is a |
| 4985 | // requirement that is due to the fact that we could have this: |
| 4986 | // |
| 4987 | // %list = type { %list * } |
| 4988 | // %list = type { %list * } ; repeated type decl |
| 4989 | // |
| 4990 | // If types are not resolved eagerly, then the two types will not be |
| 4991 | // determined to be the same type! |
| 4992 | // |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4993 | 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] | 4994 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4995 | if (!setTypeName(yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4996 | // If this is a numbered type that is not a redefinition, add it to the |
| 4997 | // slot table. |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 4998 | CurModule.Types.push_back(yyvsp[0].TypeVal.PAT->get()); |
| 4999 | CurModule.TypeSigns.push_back(yyvsp[0].TypeVal.S); |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 5000 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5001 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5002 | ;} |
| 5003 | break; |
| 5004 | |
| 5005 | case 186: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5006 | #line 2729 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5007 | { // Function prototypes can be in const pool |
| 5008 | ;} |
| 5009 | break; |
| 5010 | |
| 5011 | case 187: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5012 | #line 2731 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5013 | { // Asm blocks can be in the const pool |
| 5014 | ;} |
| 5015 | break; |
| 5016 | |
| 5017 | case 188: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5018 | #line 2733 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5019 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5020 | if (yyvsp[0].ConstVal.C == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5021 | error("Global value initializer is not a constant"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5022 | 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] | 5023 | ;} |
| 5024 | break; |
| 5025 | |
| 5026 | case 189: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5027 | #line 2737 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5028 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5029 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5030 | ;} |
| 5031 | break; |
| 5032 | |
| 5033 | case 190: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5034 | #line 2740 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5035 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5036 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
| 5037 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, Ty, 0, |
| 5038 | yyvsp[0].TypeVal.S); |
| 5039 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5040 | ;} |
| 5041 | break; |
| 5042 | |
| 5043 | case 191: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5044 | #line 2745 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5045 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5046 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5047 | ;} |
| 5048 | break; |
| 5049 | |
| 5050 | case 192: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5051 | #line 2748 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5052 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5053 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
| 5054 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, Ty, 0, |
| 5055 | yyvsp[0].TypeVal.S); |
| 5056 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5057 | ;} |
| 5058 | break; |
| 5059 | |
| 5060 | case 193: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5061 | #line 2753 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5062 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5063 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5064 | ;} |
| 5065 | break; |
| 5066 | |
| 5067 | case 194: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5068 | #line 2756 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5069 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5070 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5071 | CurGV = |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5072 | ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, Ty, 0, |
| 5073 | yyvsp[0].TypeVal.S); |
| 5074 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5075 | ;} |
| 5076 | break; |
| 5077 | |
| 5078 | case 195: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5079 | #line 2762 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5080 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5081 | CurGV = 0; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5082 | ;} |
| 5083 | break; |
| 5084 | |
| 5085 | case 196: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5086 | #line 2765 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5087 | { |
| 5088 | ;} |
| 5089 | break; |
| 5090 | |
| 5091 | case 197: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5092 | #line 2767 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5093 | { |
| 5094 | ;} |
| 5095 | break; |
| 5096 | |
| 5097 | case 198: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5098 | #line 2769 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5099 | { |
| 5100 | ;} |
| 5101 | break; |
| 5102 | |
| 5103 | case 199: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5104 | #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] | 5105 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5106 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5107 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 5108 | std::string NewAsm(yyvsp[0].StrVal, EndStr); |
| 5109 | free(yyvsp[0].StrVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5110 | |
| 5111 | if (AsmSoFar.empty()) |
| 5112 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 5113 | else |
| 5114 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5115 | ;} |
| 5116 | break; |
| 5117 | |
| 5118 | case 200: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5119 | #line 2788 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5120 | { yyval.Endianness = Module::BigEndian; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5121 | break; |
| 5122 | |
| 5123 | case 201: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5124 | #line 2789 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5125 | { yyval.Endianness = Module::LittleEndian; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5126 | break; |
| 5127 | |
| 5128 | case 202: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5129 | #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] | 5130 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5131 | CurModule.setEndianness(yyvsp[0].Endianness); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5132 | ;} |
| 5133 | break; |
| 5134 | |
| 5135 | case 203: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5136 | #line 2796 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5137 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5138 | if (yyvsp[0].UInt64Val == 32) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5139 | CurModule.setPointerSize(Module::Pointer32); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5140 | else if (yyvsp[0].UInt64Val == 64) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5141 | CurModule.setPointerSize(Module::Pointer64); |
| 5142 | else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5143 | error("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5144 | ;} |
| 5145 | break; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5146 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5147 | case 204: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5148 | #line 2804 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5149 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5150 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 5151 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5152 | ;} |
| 5153 | break; |
| 5154 | |
| 5155 | case 205: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5156 | #line 2808 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5157 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5158 | CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); |
| 5159 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5160 | ;} |
| 5161 | break; |
| 5162 | |
| 5163 | case 207: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5164 | #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] | 5165 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5166 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 5167 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5168 | ;} |
| 5169 | break; |
| 5170 | |
| 5171 | case 208: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5172 | #line 2823 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5173 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5174 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 5175 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5176 | ;} |
| 5177 | break; |
| 5178 | |
| 5179 | case 209: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5180 | #line 2827 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5181 | { ;} |
| 5182 | break; |
| 5183 | |
| 5184 | case 213: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5185 | #line 2840 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5186 | { yyval.StrVal = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5187 | break; |
| 5188 | |
| 5189 | case 214: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5190 | #line 2844 "/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 | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5192 | if (yyvsp[-1].TypeVal.PAT->get() == Type::VoidTy) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5193 | error("void typed arguments are invalid"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5194 | 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] | 5195 | ;} |
| 5196 | break; |
| 5197 | |
| 5198 | case 215: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5199 | #line 2852 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5200 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5201 | yyval.ArgList = yyvsp[-2].ArgList; |
| 5202 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 5203 | delete yyvsp[0].ArgVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5204 | ;} |
| 5205 | break; |
| 5206 | |
| 5207 | case 216: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5208 | #line 2857 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5209 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5210 | yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 5211 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 5212 | delete yyvsp[0].ArgVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5213 | ;} |
| 5214 | break; |
| 5215 | |
| 5216 | case 217: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5217 | #line 2865 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5218 | { yyval.ArgList = yyvsp[0].ArgList; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5219 | break; |
| 5220 | |
| 5221 | case 218: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5222 | #line 2866 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5223 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5224 | yyval.ArgList = yyvsp[-2].ArgList; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5225 | PATypeInfo VoidTI; |
| 5226 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5227 | VoidTI.S.makeSignless(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5228 | yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5229 | ;} |
| 5230 | break; |
| 5231 | |
| 5232 | case 219: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5233 | #line 2873 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5234 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5235 | yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5236 | PATypeInfo VoidTI; |
| 5237 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5238 | VoidTI.S.makeSignless(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5239 | yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5240 | ;} |
| 5241 | break; |
| 5242 | |
| 5243 | case 220: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5244 | #line 2880 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5245 | { yyval.ArgList = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5246 | break; |
| 5247 | |
| 5248 | case 221: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5249 | #line 2884 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5250 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5251 | UnEscapeLexed(yyvsp[-5].StrVal); |
| 5252 | std::string FunctionName(yyvsp[-5].StrVal); |
| 5253 | free(yyvsp[-5].StrVal); // Free strdup'd memory! |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5254 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5255 | const Type* RetTy = yyvsp[-6].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5256 | |
| 5257 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 5258 | error("LLVM functions cannot return aggregate types"); |
| 5259 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5260 | Signedness FTySign; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5261 | FTySign.makeComposite(yyvsp[-6].TypeVal.S); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5262 | std::vector<const Type*> ParamTyList; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5263 | |
| 5264 | // In LLVM 2.0 the signatures of three varargs intrinsics changed to take |
| 5265 | // i8*. We check here for those names and override the parameter list |
| 5266 | // types to ensure the prototype is correct. |
| 5267 | if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5268 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5269 | } else if (FunctionName == "llvm.va_copy") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5270 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
| 5271 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5272 | } else if (yyvsp[-3].ArgList) { // If there are arguments... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5273 | for (std::vector<std::pair<PATypeInfo,char*> >::iterator |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5274 | 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] | 5275 | const Type *Ty = I->first.PAT->get(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5276 | ParamTyList.push_back(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5277 | FTySign.add(I->first.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5278 | } |
| 5279 | } |
| 5280 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5281 | bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy; |
| 5282 | if (isVarArg) |
| 5283 | ParamTyList.pop_back(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5284 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5285 | // Convert the CSRet calling convention into the corresponding parameter |
| 5286 | // attribute. |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5287 | ParamAttrsList *PAL = 0; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5288 | if (yyvsp[-7].UIntVal == OldCallingConv::CSRet) { |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5289 | ParamAttrsVector Attrs; |
| 5290 | ParamAttrsWithIndex PAWI; |
| 5291 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 5292 | Attrs.push_back(PAWI); |
| 5293 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5294 | } |
| 5295 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5296 | const FunctionType *FT = |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5297 | FunctionType::get(RetTy, ParamTyList, isVarArg, PAL); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5298 | const PointerType *PFT = PointerType::get(FT); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5299 | delete yyvsp[-6].TypeVal.PAT; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5300 | |
| 5301 | ValID ID; |
| 5302 | if (!FunctionName.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5303 | ID = ValID::create((char*)FunctionName.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5304 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 5305 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5306 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5307 | ID.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5308 | |
| 5309 | Function *Fn = 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5310 | Module* M = CurModule.CurrentModule; |
| 5311 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5312 | // See if this function was forward referenced. If so, recycle the object. |
| 5313 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 5314 | // Move the function to the end of the list, from whereever it was |
| 5315 | // previously inserted. |
| 5316 | Fn = cast<Function>(FWRef); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5317 | M->getFunctionList().remove(Fn); |
| 5318 | M->getFunctionList().push_back(Fn); |
| 5319 | } else if (!FunctionName.empty()) { |
| 5320 | GlobalValue *Conflict = M->getFunction(FunctionName); |
| 5321 | if (!Conflict) |
| 5322 | Conflict = M->getNamedGlobal(FunctionName); |
| 5323 | if (Conflict && PFT == Conflict->getType()) { |
| 5324 | if (!CurFun.isDeclare && !Conflict->isDeclaration()) { |
| 5325 | // We have two function definitions that conflict, same type, same |
| 5326 | // name. We should really check to make sure that this is the result |
| 5327 | // of integer type planes collapsing and generate an error if it is |
| 5328 | // not, but we'll just rename on the assumption that it is. However, |
| 5329 | // let's do it intelligently and rename the internal linkage one |
| 5330 | // if there is one. |
| 5331 | std::string NewName(makeNameUnique(FunctionName)); |
| 5332 | if (Conflict->hasInternalLinkage()) { |
| 5333 | Conflict->setName(NewName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5334 | RenameMapKey Key = |
| 5335 | makeRenameMapKey(FunctionName, Conflict->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5336 | CurModule.RenameMap[Key] = NewName; |
| 5337 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5338 | InsertValue(Fn, CurModule.Values); |
| 5339 | } else { |
| 5340 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5341 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5342 | RenameMapKey Key = |
| 5343 | makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5344 | CurModule.RenameMap[Key] = NewName; |
| 5345 | } |
| 5346 | } else { |
| 5347 | // If they are not both definitions, then just use the function we |
| 5348 | // found since the types are the same. |
| 5349 | Fn = cast<Function>(Conflict); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5350 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5351 | // Make sure to strip off any argument names so we can't get |
| 5352 | // conflicts. |
| 5353 | if (Fn->isDeclaration()) |
| 5354 | for (Function::arg_iterator AI = Fn->arg_begin(), |
| 5355 | AE = Fn->arg_end(); AI != AE; ++AI) |
| 5356 | AI->setName(""); |
| 5357 | } |
| 5358 | } else if (Conflict) { |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 5359 | // We have two globals with the same name and different types. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5360 | // Previously, this was permitted because the symbol table had |
| 5361 | // "type planes" and names only needed to be distinct within a |
| 5362 | // type plane. After PR411 was fixed, this is no loner the case. |
| 5363 | // To resolve this we must rename one of the two. |
| 5364 | if (Conflict->hasInternalLinkage()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5365 | // We can safely rename the Conflict. |
| 5366 | RenameMapKey Key = |
| 5367 | makeRenameMapKey(Conflict->getName(), Conflict->getType(), |
| 5368 | CurModule.NamedValueSigns[Conflict->getName()]); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5369 | Conflict->setName(makeNameUnique(Conflict->getName())); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5370 | CurModule.RenameMap[Key] = Conflict->getName(); |
| 5371 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5372 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5373 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5374 | // We can't quietly rename either of these things, but we must |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5375 | // rename one of them. Only if the function's linkage is internal can |
| 5376 | // we forgo a warning message about the renamed function. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5377 | std::string NewName = makeNameUnique(FunctionName); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5378 | if (CurFun.Linkage != GlobalValue::InternalLinkage) { |
| 5379 | warning("Renaming function '" + FunctionName + "' as '" + NewName + |
| 5380 | "' may cause linkage errors"); |
| 5381 | } |
| 5382 | // Elect to rename the thing we're now defining. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5383 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 5384 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5385 | RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5386 | CurModule.RenameMap[Key] = NewName; |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5387 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5388 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5389 | // There's no conflict, just define the function |
| 5390 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5391 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5392 | } |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 5393 | } else { |
| 5394 | // There's no conflict, just define the function |
| 5395 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 5396 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5397 | } |
| 5398 | |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 5399 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5400 | CurFun.FunctionStart(Fn); |
| 5401 | |
| 5402 | if (CurFun.isDeclare) { |
| 5403 | // If we have declaration, always overwrite linkage. This will allow us |
| 5404 | // to correctly handle cases, when pointer to function is passed as |
| 5405 | // argument to another function. |
| 5406 | Fn->setLinkage(CurFun.Linkage); |
| 5407 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5408 | Fn->setCallingConv(upgradeCallingConv(yyvsp[-7].UIntVal)); |
| 5409 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 5410 | if (yyvsp[-1].StrVal) { |
| 5411 | Fn->setSection(yyvsp[-1].StrVal); |
| 5412 | free(yyvsp[-1].StrVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5413 | } |
| 5414 | |
| 5415 | // Add all of the arguments we parsed to the function... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5416 | if (yyvsp[-3].ArgList) { // Is null if empty... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5417 | if (isVarArg) { // Nuke the last entry |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5418 | assert(yyvsp[-3].ArgList->back().first.PAT->get() == Type::VoidTy && |
| 5419 | yyvsp[-3].ArgList->back().second == 0 && "Not a varargs marker"); |
| 5420 | delete yyvsp[-3].ArgList->back().first.PAT; |
| 5421 | yyvsp[-3].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5422 | } |
| 5423 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5424 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5425 | std::vector<std::pair<PATypeInfo,char*> >::iterator I = yyvsp[-3].ArgList->begin(); |
| 5426 | std::vector<std::pair<PATypeInfo,char*> >::iterator E = yyvsp[-3].ArgList->end(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5427 | for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5428 | delete I->first.PAT; // Delete the typeholder... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5429 | ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S); |
| 5430 | setValueName(VI, I->second); // Insert arg into symtab... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5431 | InsertValue(ArgIt); |
| 5432 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5433 | delete yyvsp[-3].ArgList; // We're now done with the argument list |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5434 | } |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5435 | lastCallingConv = OldCallingConv::C; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5436 | ;} |
| 5437 | break; |
| 5438 | |
| 5439 | case 224: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5440 | #line 3078 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5441 | { CurFun.Linkage = yyvsp[0].Linkage; ;} |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5442 | break; |
| 5443 | |
| 5444 | case 225: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5445 | #line 3078 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5446 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5447 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5448 | |
| 5449 | // Make sure that we keep track of the linkage type even if there was a |
| 5450 | // previous "declare". |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5451 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5452 | ;} |
| 5453 | break; |
| 5454 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5455 | case 228: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5456 | #line 3092 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5457 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5458 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5459 | ;} |
| 5460 | break; |
| 5461 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5462 | case 229: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5463 | #line 3097 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5464 | { yyval.Linkage = GlobalValue::ExternalLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5465 | break; |
| 5466 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5467 | case 230: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5468 | #line 3098 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5469 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5470 | break; |
| 5471 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5472 | case 231: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5473 | #line 3099 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5474 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5475 | break; |
| 5476 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5477 | case 232: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5478 | #line 3103 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5479 | { CurFun.isDeclare = true; ;} |
| 5480 | break; |
| 5481 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5482 | case 233: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5483 | #line 3104 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5484 | { CurFun.Linkage = yyvsp[0].Linkage; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5485 | break; |
| 5486 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5487 | case 234: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5488 | #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] | 5489 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5490 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5491 | CurFun.FunctionDone(); |
| 5492 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5493 | ;} |
| 5494 | break; |
| 5495 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5496 | case 235: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5497 | #line 3116 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5498 | { yyval.BoolVal = false; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5499 | break; |
| 5500 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5501 | case 236: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5502 | #line 3117 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5503 | { yyval.BoolVal = true; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5504 | break; |
| 5505 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5506 | case 237: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5507 | #line 3122 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5508 | { yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5509 | break; |
| 5510 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5511 | case 238: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5512 | #line 3123 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5513 | { yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5514 | break; |
| 5515 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5516 | case 239: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5517 | #line 3124 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5518 | { yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5519 | break; |
| 5520 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5521 | case 240: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5522 | #line 3125 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5523 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5524 | yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, true)); |
| 5525 | yyval.ValIDVal.S.makeUnsigned(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5526 | ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5527 | break; |
| 5528 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5529 | case 241: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5530 | #line 3129 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5531 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5532 | yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, false)); |
| 5533 | yyval.ValIDVal.S.makeUnsigned(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5534 | ;} |
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 242: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5538 | #line 3133 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5539 | { yyval.ValIDVal = ValID::createNull(); ;} |
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 243: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5543 | #line 3134 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5544 | { yyval.ValIDVal = ValID::createUndef(); ;} |
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 244: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5548 | #line 3135 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5549 | { yyval.ValIDVal = ValID::createZeroInit(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5550 | break; |
| 5551 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5552 | case 245: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5553 | #line 3136 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5554 | { // Nonempty unsized packed vector |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5555 | const Type *ETy = (*yyvsp[-1].ConstVector)[0].C->getType(); |
| 5556 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5557 | VectorType* pt = VectorType::get(ETy, NumElements); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5558 | yyval.ValIDVal.S.makeComposite((*yyvsp[-1].ConstVector)[0].S); |
| 5559 | PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, yyval.ValIDVal.S)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5560 | |
| 5561 | // Verify all elements are correct type! |
| 5562 | std::vector<Constant*> Elems; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5563 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 5564 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5565 | const Type *CTy = C->getType(); |
| 5566 | if (ETy != CTy) |
| 5567 | error("Element #" + utostr(i) + " is not of type '" + |
| 5568 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 5569 | CTy->getDescription() + "'"); |
| 5570 | Elems.push_back(C); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 5571 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5572 | yyval.ValIDVal = ValID::create(ConstantVector::get(pt, Elems)); |
| 5573 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5574 | ;} |
| 5575 | break; |
| 5576 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5577 | case 246: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5578 | #line 3157 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5579 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5580 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal.C); |
| 5581 | yyval.ValIDVal.S.copy(yyvsp[0].ConstVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5582 | ;} |
| 5583 | break; |
| 5584 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5585 | case 247: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5586 | #line 3161 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5587 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5588 | char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); |
| 5589 | std::string AsmStr = std::string(yyvsp[-2].StrVal, End); |
| 5590 | End = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 5591 | std::string Constraints = std::string(yyvsp[0].StrVal, End); |
| 5592 | yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); |
| 5593 | free(yyvsp[-2].StrVal); |
| 5594 | free(yyvsp[0].StrVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5595 | ;} |
| 5596 | break; |
| 5597 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5598 | case 248: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5599 | #line 3175 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5600 | { yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); yyval.ValIDVal.S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5601 | break; |
| 5602 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5603 | case 249: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5604 | #line 3176 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5605 | { yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); yyval.ValIDVal.S.makeSignless(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5606 | break; |
| 5607 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5608 | case 252: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5609 | #line 3189 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5610 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5611 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 5612 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
| 5613 | yyval.ValueVal.V = getVal(Ty, yyvsp[0].ValIDVal); |
| 5614 | yyval.ValueVal.S.copy(yyvsp[-1].TypeVal.S); |
| 5615 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5616 | ;} |
| 5617 | break; |
| 5618 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5619 | case 253: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5620 | #line 3199 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5621 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5622 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5623 | ;} |
| 5624 | break; |
| 5625 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5626 | case 254: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5627 | #line 3202 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5628 | { // Do not allow functions with 0 basic blocks |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5629 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5630 | ;} |
| 5631 | break; |
| 5632 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5633 | case 255: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5634 | #line 3211 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5635 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5636 | ValueInfo VI; VI.V = yyvsp[0].TermInstVal.TI; VI.S.copy(yyvsp[0].TermInstVal.S); |
| 5637 | setValueName(VI, yyvsp[-1].StrVal); |
| 5638 | InsertValue(yyvsp[0].TermInstVal.TI); |
| 5639 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal.TI); |
| 5640 | InsertValue(yyvsp[-2].BasicBlockVal); |
| 5641 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
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 256: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5646 | #line 3222 "/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 | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5648 | if (yyvsp[0].InstVal.I) |
| 5649 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal.I); |
| 5650 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5651 | ;} |
| 5652 | break; |
| 5653 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5654 | case 257: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5655 | #line 3227 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5656 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5657 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5658 | // Make sure to move the basic block to the correct location in the |
| 5659 | // function, instead of leaving it inserted wherever it was first |
| 5660 | // referenced. |
| 5661 | Function::BasicBlockListType &BBL = |
| 5662 | CurFun.CurrentFunction->getBasicBlockList(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5663 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5664 | ;} |
| 5665 | break; |
| 5666 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5667 | case 258: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5668 | #line 3236 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5669 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5670 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5671 | // Make sure to move the basic block to the correct location in the |
| 5672 | // function, instead of leaving it inserted wherever it was first |
| 5673 | // referenced. |
| 5674 | Function::BasicBlockListType &BBL = |
| 5675 | CurFun.CurrentFunction->getBasicBlockList(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5676 | BBL.splice(BBL.end(), BBL, yyval.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 261: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5681 | #line 3250 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5682 | { // Return with a result... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5683 | yyval.TermInstVal.TI = new ReturnInst(yyvsp[0].ValueVal.V); |
| 5684 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5685 | ;} |
| 5686 | break; |
| 5687 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5688 | case 262: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5689 | #line 3254 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5690 | { // Return with no result... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5691 | yyval.TermInstVal.TI = new ReturnInst(); |
| 5692 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5693 | ;} |
| 5694 | break; |
| 5695 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5696 | case 263: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5697 | #line 3258 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5698 | { // Unconditional Branch... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5699 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 5700 | yyval.TermInstVal.TI = new BranchInst(tmpBB); |
| 5701 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5702 | ;} |
| 5703 | break; |
| 5704 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5705 | case 264: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5706 | #line 3263 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5707 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5708 | yyvsp[-3].ValIDVal.S.makeSignless(); |
| 5709 | yyvsp[0].ValIDVal.S.makeSignless(); |
| 5710 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 5711 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 5712 | yyvsp[-6].ValIDVal.S.makeUnsigned(); |
| 5713 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 5714 | yyval.TermInstVal.TI = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 5715 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5716 | ;} |
| 5717 | break; |
| 5718 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5719 | case 265: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5720 | #line 3273 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5721 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5722 | yyvsp[-6].ValIDVal.S.copy(yyvsp[-7].PrimType.S); |
| 5723 | Value* tmpVal = getVal(yyvsp[-7].PrimType.T, yyvsp[-6].ValIDVal); |
| 5724 | yyvsp[-3].ValIDVal.S.makeSignless(); |
| 5725 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 5726 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 5727 | yyval.TermInstVal.TI = S; |
| 5728 | yyval.TermInstVal.S.makeSignless(); |
| 5729 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 5730 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5731 | for (; I != E; ++I) { |
| 5732 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 5733 | S->addCase(CI, I->second); |
| 5734 | else |
| 5735 | error("Switch case is constant, but not a simple integer"); |
| 5736 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5737 | delete yyvsp[-1].JumpTable; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5738 | ;} |
| 5739 | break; |
| 5740 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5741 | case 266: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5742 | #line 3291 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5743 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5744 | yyvsp[-5].ValIDVal.S.copy(yyvsp[-6].PrimType.S); |
| 5745 | Value* tmpVal = getVal(yyvsp[-6].PrimType.T, yyvsp[-5].ValIDVal); |
| 5746 | yyvsp[-2].ValIDVal.S.makeSignless(); |
| 5747 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5748 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5749 | yyval.TermInstVal.TI = S; |
| 5750 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5751 | ;} |
| 5752 | break; |
| 5753 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5754 | case 267: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5755 | #line 3301 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5756 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5757 | const PointerType *PFTy; |
| 5758 | const FunctionType *Ty; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5759 | Signedness FTySign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5760 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5761 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal.PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5762 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5763 | // Pull out the types of all of the arguments... |
| 5764 | std::vector<const Type*> ParamTypes; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5765 | FTySign.makeComposite(yyvsp[-10].TypeVal.S); |
| 5766 | if (yyvsp[-7].ValueList) { |
| 5767 | 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] | 5768 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5769 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5770 | FTySign.add(I->S); |
| 5771 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5772 | } |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5773 | ParamAttrsList *PAL = 0; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5774 | if (yyvsp[-11].UIntVal == OldCallingConv::CSRet) { |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5775 | ParamAttrsVector Attrs; |
| 5776 | ParamAttrsWithIndex PAWI; |
| 5777 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 5778 | Attrs.push_back(PAWI); |
| 5779 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5780 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5781 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5782 | if (isVarArg) ParamTypes.pop_back(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5783 | Ty = FunctionType::get(yyvsp[-10].TypeVal.PAT->get(), ParamTypes, isVarArg, PAL); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5784 | PFTy = PointerType::get(Ty); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5785 | yyval.TermInstVal.S.copy(yyvsp[-10].TypeVal.S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5786 | } else { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5787 | FTySign = yyvsp[-10].TypeVal.S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 5788 | // Get the signedness of the result type. $3 is the pointer to the |
| 5789 | // function type so we get the 0th element to extract the function type, |
| 5790 | // and then the 0th element again to get the result type. |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5791 | yyval.TermInstVal.S.copy(yyvsp[-10].TypeVal.S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5792 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5793 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5794 | yyvsp[-9].ValIDVal.S.makeComposite(FTySign); |
| 5795 | Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling... |
| 5796 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
| 5797 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5798 | |
| 5799 | // Create the call node... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5800 | if (!yyvsp[-7].ValueList) { // Has no arguments? |
| 5801 | std::vector<Value*> Args; |
| 5802 | yyval.TermInstVal.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5803 | } else { // Has arguments? |
| 5804 | // Loop through FunctionType's arguments and ensure they are specified |
| 5805 | // correctly! |
| 5806 | // |
| 5807 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5808 | FunctionType::param_iterator E = Ty->param_end(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5809 | 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] | 5810 | |
| 5811 | std::vector<Value*> Args; |
| 5812 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5813 | if ((*ArgI).V->getType() != *I) |
| 5814 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 5815 | (*I)->getDescription() + "'"); |
| 5816 | Args.push_back((*ArgI).V); |
| 5817 | } |
| 5818 | |
| 5819 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 5820 | error("Invalid number of parameters detected"); |
| 5821 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5822 | yyval.TermInstVal.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5823 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5824 | cast<InvokeInst>(yyval.TermInstVal.TI)->setCallingConv(upgradeCallingConv(yyvsp[-11].UIntVal)); |
| 5825 | delete yyvsp[-10].TypeVal.PAT; |
| 5826 | delete yyvsp[-7].ValueList; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5827 | lastCallingConv = OldCallingConv::C; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5828 | ;} |
| 5829 | break; |
| 5830 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5831 | case 268: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5832 | #line 3374 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5833 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5834 | yyval.TermInstVal.TI = new UnwindInst(); |
| 5835 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5836 | ;} |
| 5837 | break; |
| 5838 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5839 | case 269: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5840 | #line 3378 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5841 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5842 | yyval.TermInstVal.TI = new UnreachableInst(); |
| 5843 | yyval.TermInstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5844 | ;} |
| 5845 | break; |
| 5846 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5847 | case 270: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5848 | #line 3385 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5849 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5850 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 5851 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-4].PrimType.S); |
| 5852 | Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5853 | |
| 5854 | if (V == 0) |
| 5855 | error("May only switch on a constant pool value"); |
| 5856 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5857 | yyvsp[0].ValIDVal.S.makeSignless(); |
| 5858 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 5859 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5860 | ;} |
| 5861 | break; |
| 5862 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5863 | case 271: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5864 | #line 3397 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5865 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5866 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 5867 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-4].PrimType.S); |
| 5868 | Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5869 | |
| 5870 | if (V == 0) |
| 5871 | error("May only switch on a constant pool value"); |
| 5872 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5873 | yyvsp[0].ValIDVal.S.makeSignless(); |
| 5874 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 5875 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5876 | ;} |
| 5877 | break; |
| 5878 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5879 | case 272: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5880 | #line 3412 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5881 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5882 | bool omit = false; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5883 | if (yyvsp[-1].StrVal) |
| 5884 | if (BitCastInst *BCI = dyn_cast<BitCastInst>(yyvsp[0].InstVal.I)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5885 | if (BCI->getSrcTy() == BCI->getDestTy() && |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5886 | BCI->getOperand(0)->getName() == yyvsp[-1].StrVal) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5887 | // This is a useless bit cast causing a name redefinition. It is |
| 5888 | // a bit cast from a type to the same type of an operand with the |
| 5889 | // same name as the name we would give this instruction. Since this |
| 5890 | // instruction results in no code generation, it is safe to omit |
| 5891 | // the instruction. This situation can occur because of collapsed |
| 5892 | // type planes. For example: |
| 5893 | // %X = add int %Y, %Z |
| 5894 | // %X = cast int %Y to uint |
| 5895 | // After upgrade, this looks like: |
| 5896 | // %X = add i32 %Y, %Z |
| 5897 | // %X = bitcast i32 to i32 |
| 5898 | // The bitcast is clearly useless so we omit it. |
| 5899 | omit = true; |
| 5900 | if (omit) { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5901 | yyval.InstVal.I = 0; |
| 5902 | yyval.InstVal.S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5903 | } else { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5904 | ValueInfo VI; VI.V = yyvsp[0].InstVal.I; VI.S.copy(yyvsp[0].InstVal.S); |
| 5905 | setValueName(VI, yyvsp[-1].StrVal); |
| 5906 | InsertValue(yyvsp[0].InstVal.I); |
| 5907 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5908 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5909 | ;} |
| 5910 | break; |
| 5911 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5912 | case 273: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5913 | #line 3442 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5914 | { // Used for PHI nodes |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5915 | yyval.PHIList.P = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 5916 | yyval.PHIList.S.copy(yyvsp[-5].TypeVal.S); |
| 5917 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-5].TypeVal.S); |
| 5918 | Value* tmpVal = getVal(yyvsp[-5].TypeVal.PAT->get(), yyvsp[-3].ValIDVal); |
| 5919 | yyvsp[-1].ValIDVal.S.makeSignless(); |
| 5920 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
| 5921 | yyval.PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5922 | delete yyvsp[-5].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5923 | ;} |
| 5924 | break; |
| 5925 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5926 | case 274: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5927 | #line 3452 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5928 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5929 | yyval.PHIList = yyvsp[-6].PHIList; |
| 5930 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-6].PHIList.S); |
| 5931 | Value* tmpVal = getVal(yyvsp[-6].PHIList.P->front().first->getType(), yyvsp[-3].ValIDVal); |
| 5932 | yyvsp[-1].ValIDVal.S.makeSignless(); |
| 5933 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
| 5934 | yyvsp[-6].PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5935 | ;} |
| 5936 | break; |
| 5937 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5938 | case 275: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5939 | #line 3462 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5940 | { // Used for call statements, and memory insts... |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5941 | yyval.ValueList = new std::vector<ValueInfo>(); |
| 5942 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5943 | ;} |
| 5944 | break; |
| 5945 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5946 | case 276: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5947 | #line 3466 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5948 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5949 | yyval.ValueList = yyvsp[-2].ValueList; |
| 5950 | yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5951 | ;} |
| 5952 | break; |
| 5953 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5954 | case 278: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5955 | #line 3474 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 5956 | { yyval.ValueList = 0; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5957 | break; |
| 5958 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5959 | case 279: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5960 | #line 3478 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5961 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5962 | yyval.BoolVal = true; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5963 | ;} |
| 5964 | break; |
| 5965 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5966 | case 280: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5967 | #line 3481 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5968 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5969 | yyval.BoolVal = false; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5970 | ;} |
| 5971 | break; |
| 5972 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5973 | case 281: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5974 | #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] | 5975 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5976 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5977 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5978 | const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5979 | if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5980 | error("Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5981 | if (isa<VectorType>(Ty) && |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5982 | (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] | 5983 | error("Remainder not supported on vector types"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5984 | // Upgrade the opcode from obsolete versions before we do anything with it. |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5985 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); |
| 5986 | Value* val1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 5987 | Value* val2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 5988 | yyval.InstVal.I = BinaryOperator::create(Opcode, val1, val2); |
| 5989 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5990 | error("binary operator returned null"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5991 | yyval.InstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5992 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5993 | ;} |
| 5994 | break; |
| 5995 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 5996 | case 282: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5997 | #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] | 5998 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 5999 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6000 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6001 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6002 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6003 | if (!isa<VectorType>(Ty) || |
| 6004 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6005 | error("Logical operator requires integral operands"); |
| 6006 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6007 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); |
| 6008 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 6009 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 6010 | yyval.InstVal.I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); |
| 6011 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6012 | error("binary operator returned null"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6013 | yyval.InstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6014 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6015 | ;} |
| 6016 | break; |
| 6017 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6018 | case 283: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6019 | #line 3524 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6020 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6021 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6022 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6023 | const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6024 | if(isa<VectorType>(Ty)) |
| 6025 | error("VectorTypes currently not supported in setcc instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6026 | unsigned short pred; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6027 | Instruction::OtherOps Opcode = getCompareOp(yyvsp[-4].BinaryOpVal, pred, Ty, yyvsp[-3].TypeVal.S); |
| 6028 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 6029 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 6030 | yyval.InstVal.I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); |
| 6031 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6032 | error("binary operator returned null"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6033 | yyval.InstVal.S.makeUnsigned(); |
| 6034 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6035 | ;} |
| 6036 | break; |
| 6037 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6038 | case 284: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6039 | #line 3540 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6040 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6041 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6042 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6043 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6044 | if (isa<VectorType>(Ty)) |
| 6045 | error("VectorTypes currently not supported in icmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6046 | else if (!Ty->isInteger() && !isa<PointerType>(Ty)) |
| 6047 | error("icmp requires integer or pointer typed operands"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6048 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 6049 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 6050 | yyval.InstVal.I = new ICmpInst(yyvsp[-4].IPred, tmpVal1, tmpVal2); |
| 6051 | yyval.InstVal.S.makeUnsigned(); |
| 6052 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6053 | ;} |
| 6054 | break; |
| 6055 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6056 | case 285: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6057 | #line 3554 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6058 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6059 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6060 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 6061 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 6062 | if (isa<VectorType>(Ty)) |
| 6063 | error("VectorTypes currently not supported in fcmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6064 | else if (!Ty->isFloatingPoint()) |
| 6065 | error("fcmp instruction requires floating point operands"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6066 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 6067 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 6068 | yyval.InstVal.I = new FCmpInst(yyvsp[-4].FPred, tmpVal1, tmpVal2); |
| 6069 | yyval.InstVal.S.makeUnsigned(); |
| 6070 | delete yyvsp[-3].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6071 | ;} |
| 6072 | break; |
| 6073 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6074 | case 286: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6075 | #line 3568 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6076 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6077 | warning("Use of obsolete 'not' instruction: Replacing with 'xor"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6078 | const Type *Ty = yyvsp[0].ValueVal.V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6079 | Value *Ones = ConstantInt::getAllOnesValue(Ty); |
| 6080 | if (Ones == 0) |
| 6081 | error("Expected integral type for not instruction"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6082 | yyval.InstVal.I = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal.V, Ones); |
| 6083 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6084 | error("Could not create a xor instruction"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6085 | yyval.InstVal.S.copy(yyvsp[0].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6086 | ;} |
| 6087 | break; |
| 6088 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6089 | case 287: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6090 | #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] | 6091 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6092 | if (!yyvsp[0].ValueVal.V->getType()->isInteger() || |
| 6093 | cast<IntegerType>(yyvsp[0].ValueVal.V->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6094 | error("Shift amount must be int8"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6095 | const Type* Ty = yyvsp[-2].ValueVal.V->getType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6096 | if (!Ty->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6097 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6098 | Value* ShiftAmt = 0; |
| 6099 | if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth()) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6100 | if (Constant *C = dyn_cast<Constant>(yyvsp[0].ValueVal.V)) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6101 | ShiftAmt = ConstantExpr::getZExt(C, Ty); |
| 6102 | else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6103 | ShiftAmt = new ZExtInst(yyvsp[0].ValueVal.V, Ty, makeNameUnique("shift"), CurBB); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 6104 | else |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6105 | ShiftAmt = yyvsp[0].ValueVal.V; |
| 6106 | yyval.InstVal.I = BinaryOperator::create(getBinaryOp(yyvsp[-3].BinaryOpVal, Ty, yyvsp[-2].ValueVal.S), yyvsp[-2].ValueVal.V, ShiftAmt); |
| 6107 | yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6108 | ;} |
| 6109 | break; |
| 6110 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6111 | case 288: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6112 | #line 3597 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6113 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6114 | const Type *DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6115 | if (!DstTy->isFirstClassType()) |
| 6116 | error("cast instruction to a non-primitive type: '" + |
| 6117 | DstTy->getDescription() + "'"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6118 | yyval.InstVal.I = cast<Instruction>(getCast(yyvsp[-3].CastOpVal, yyvsp[-2].ValueVal.V, yyvsp[-2].ValueVal.S, DstTy, yyvsp[0].TypeVal.S, true)); |
| 6119 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 6120 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6121 | ;} |
| 6122 | break; |
| 6123 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6124 | case 289: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6125 | #line 3606 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6126 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6127 | if (!yyvsp[-4].ValueVal.V->getType()->isInteger() || |
| 6128 | cast<IntegerType>(yyvsp[-4].ValueVal.V->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6129 | error("select condition must be bool"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6130 | if (yyvsp[-2].ValueVal.V->getType() != yyvsp[0].ValueVal.V->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6131 | error("select value types should match"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6132 | yyval.InstVal.I = new SelectInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 6133 | yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6134 | ;} |
| 6135 | break; |
| 6136 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6137 | case 290: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6138 | #line 3615 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6139 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6140 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6141 | NewVarArgs = true; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6142 | yyval.InstVal.I = new VAArgInst(yyvsp[-2].ValueVal.V, Ty); |
| 6143 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 6144 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6145 | ;} |
| 6146 | break; |
| 6147 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6148 | case 291: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6149 | #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] | 6150 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6151 | const Type* ArgTy = yyvsp[-2].ValueVal.V->getType(); |
| 6152 | const Type* DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6153 | ObsoleteVarArgs = true; |
| 6154 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 6155 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 6156 | |
| 6157 | //b = vaarg a, t -> |
| 6158 | //foo = alloca 1 of t |
| 6159 | //bar = vacopy a |
| 6160 | //store bar -> foo |
| 6161 | //b = vaarg foo, t |
| 6162 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 6163 | CurBB->getInstList().push_back(foo); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6164 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6165 | CurBB->getInstList().push_back(bar); |
| 6166 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6167 | yyval.InstVal.I = new VAArgInst(foo, DstTy); |
| 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 292: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6174 | #line 3643 "/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 | 5fd22a8 | 2007-09-04 18:46:50 +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 = vanext a, t -> |
| 6183 | //foo = alloca 1 of t |
| 6184 | //bar = vacopy a |
| 6185 | //store bar -> foo |
| 6186 | //tmp = vaarg foo, t |
| 6187 | //b = load foo |
| 6188 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 6189 | CurBB->getInstList().push_back(foo); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6190 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6191 | CurBB->getInstList().push_back(bar); |
| 6192 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 6193 | Instruction* tmp = new VAArgInst(foo, DstTy); |
| 6194 | CurBB->getInstList().push_back(tmp); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6195 | yyval.InstVal.I = new LoadInst(foo); |
| 6196 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 6197 | delete yyvsp[0].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6198 | ;} |
| 6199 | break; |
| 6200 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6201 | case 293: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6202 | #line 3667 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6203 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6204 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6205 | error("Invalid extractelement operands"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6206 | yyval.InstVal.I = new ExtractElementInst(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 6207 | yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S.get(0)); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6208 | ;} |
| 6209 | break; |
| 6210 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6211 | case 294: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6212 | #line 3673 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6213 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6214 | 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] | 6215 | error("Invalid insertelement operands"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6216 | yyval.InstVal.I = new InsertElementInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 6217 | yyval.InstVal.S.copy(yyvsp[-4].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6218 | ;} |
| 6219 | break; |
| 6220 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6221 | case 295: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6222 | #line 3679 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6223 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6224 | 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] | 6225 | error("Invalid shufflevector operands"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6226 | yyval.InstVal.I = new ShuffleVectorInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 6227 | yyval.InstVal.S.copy(yyvsp[-4].ValueVal.S); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6228 | ;} |
| 6229 | break; |
| 6230 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6231 | case 296: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6232 | #line 3685 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6233 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6234 | const Type *Ty = yyvsp[0].PHIList.P->front().first->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6235 | if (!Ty->isFirstClassType()) |
| 6236 | error("PHI node operands must be of first class type"); |
| 6237 | PHINode *PHI = new PHINode(Ty); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6238 | PHI->reserveOperandSpace(yyvsp[0].PHIList.P->size()); |
| 6239 | while (yyvsp[0].PHIList.P->begin() != yyvsp[0].PHIList.P->end()) { |
| 6240 | if (yyvsp[0].PHIList.P->front().first->getType() != Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6241 | error("All elements of a PHI node must be of the same type"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6242 | PHI->addIncoming(yyvsp[0].PHIList.P->front().first, yyvsp[0].PHIList.P->front().second); |
| 6243 | yyvsp[0].PHIList.P->pop_front(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6244 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6245 | yyval.InstVal.I = PHI; |
| 6246 | yyval.InstVal.S.copy(yyvsp[0].PHIList.S); |
| 6247 | delete yyvsp[0].PHIList.P; // Free the list... |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6248 | ;} |
| 6249 | break; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6250 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6251 | case 297: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6252 | #line 3701 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6253 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6254 | // Handle the short call syntax |
| 6255 | const PointerType *PFTy; |
| 6256 | const FunctionType *FTy; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6257 | Signedness FTySign; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6258 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal.PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6259 | !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 6260 | // Pull out the types of all of the arguments... |
| 6261 | std::vector<const Type*> ParamTypes; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6262 | FTySign.makeComposite(yyvsp[-4].TypeVal.S); |
| 6263 | if (yyvsp[-1].ValueList) { |
| 6264 | 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] | 6265 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6266 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6267 | FTySign.add(I->S); |
| 6268 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6269 | } |
| 6270 | |
| 6271 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 6272 | if (isVarArg) ParamTypes.pop_back(); |
| 6273 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6274 | const Type *RetTy = yyvsp[-4].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6275 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 6276 | error("Functions cannot return aggregate types"); |
| 6277 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 6278 | // Deal with CSRetCC |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6279 | ParamAttrsList *PAL = 0; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6280 | if (yyvsp[-5].UIntVal == OldCallingConv::CSRet) { |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6281 | ParamAttrsVector Attrs; |
| 6282 | ParamAttrsWithIndex PAWI; |
| 6283 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 6284 | Attrs.push_back(PAWI); |
| 6285 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 6286 | } |
| 6287 | |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6288 | FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, PAL); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6289 | PFTy = PointerType::get(FTy); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6290 | yyval.InstVal.S.copy(yyvsp[-4].TypeVal.S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 6291 | } else { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6292 | FTySign = yyvsp[-4].TypeVal.S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 6293 | // Get the signedness of the result type. $3 is the pointer to the |
| 6294 | // function type so we get the 0th element to extract the function type, |
| 6295 | // and then the 0th element again to get the result type. |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6296 | yyval.InstVal.S.copy(yyvsp[-4].TypeVal.S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6297 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6298 | yyvsp[-3].ValIDVal.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6299 | |
| 6300 | // First upgrade any intrinsic calls. |
| 6301 | std::vector<Value*> Args; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6302 | if (yyvsp[-1].ValueList) |
| 6303 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i < e; ++i) |
| 6304 | Args.push_back((*yyvsp[-1].ValueList)[i].V); |
| 6305 | Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), yyvsp[-3].ValIDVal, Args); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6306 | |
| 6307 | // If we got an upgraded intrinsic |
| 6308 | if (Inst) { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6309 | yyval.InstVal.I = Inst; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6310 | } else { |
| 6311 | // Get the function we're calling |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6312 | Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6313 | |
| 6314 | // Check the argument values match |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6315 | if (!yyvsp[-1].ValueList) { // Has no arguments? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6316 | // Make sure no arguments is a good thing! |
| 6317 | if (FTy->getNumParams() != 0) |
| 6318 | error("No arguments passed to a function that expects arguments"); |
| 6319 | } else { // Has arguments? |
| 6320 | // Loop through FunctionType's arguments and ensure they are specified |
| 6321 | // correctly! |
| 6322 | // |
| 6323 | FunctionType::param_iterator I = FTy->param_begin(); |
| 6324 | FunctionType::param_iterator E = FTy->param_end(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6325 | 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] | 6326 | |
| 6327 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 6328 | if ((*ArgI).V->getType() != *I) |
| 6329 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 6330 | (*I)->getDescription() + "'"); |
| 6331 | |
| 6332 | if (I != E || (ArgI != ArgE && !FTy->isVarArg())) |
| 6333 | error("Invalid number of parameters detected"); |
| 6334 | } |
| 6335 | |
| 6336 | // Create the call instruction |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 6337 | CallInst *CI = new CallInst(V, Args.begin(), Args.end()); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6338 | CI->setTailCall(yyvsp[-6].BoolVal); |
| 6339 | CI->setCallingConv(upgradeCallingConv(yyvsp[-5].UIntVal)); |
| 6340 | yyval.InstVal.I = CI; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6341 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6342 | delete yyvsp[-4].TypeVal.PAT; |
| 6343 | delete yyvsp[-1].ValueList; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 6344 | lastCallingConv = OldCallingConv::C; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6345 | ;} |
| 6346 | break; |
| 6347 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6348 | case 298: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6349 | #line 3794 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6350 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6351 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6352 | ;} |
| 6353 | break; |
| 6354 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6355 | case 299: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6356 | #line 3802 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 6357 | { yyval.ValueList = yyvsp[0].ValueList; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6358 | break; |
| 6359 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6360 | case 300: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6361 | #line 3803 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 6362 | { yyval.ValueList = new std::vector<ValueInfo>(); ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6363 | break; |
| 6364 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6365 | case 301: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6366 | #line 3807 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 6367 | { yyval.BoolVal = true; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6368 | break; |
| 6369 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6370 | case 302: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6371 | #line 3808 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
| 6372 | { yyval.BoolVal = false; ;} |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6373 | break; |
| 6374 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6375 | case 303: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6376 | #line 3812 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6377 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6378 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 6379 | yyval.InstVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 6380 | yyval.InstVal.I = new MallocInst(Ty, 0, yyvsp[0].UIntVal); |
| 6381 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6382 | ;} |
| 6383 | break; |
| 6384 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6385 | case 304: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6386 | #line 3818 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6387 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6388 | const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); |
| 6389 | yyvsp[-1].ValIDVal.S.makeUnsigned(); |
| 6390 | yyval.InstVal.S.makeComposite(yyvsp[-4].TypeVal.S); |
| 6391 | yyval.InstVal.I = new MallocInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 6392 | delete yyvsp[-4].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6393 | ;} |
| 6394 | break; |
| 6395 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6396 | case 305: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6397 | #line 3825 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6398 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6399 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 6400 | yyval.InstVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 6401 | yyval.InstVal.I = new AllocaInst(Ty, 0, yyvsp[0].UIntVal); |
| 6402 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6403 | ;} |
| 6404 | break; |
| 6405 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6406 | case 306: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6407 | #line 3831 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6408 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6409 | const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); |
| 6410 | yyvsp[-1].ValIDVal.S.makeUnsigned(); |
| 6411 | yyval.InstVal.S.makeComposite(yyvsp[-2].PrimType.S); |
| 6412 | yyval.InstVal.I = new AllocaInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 6413 | delete yyvsp[-4].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6414 | ;} |
| 6415 | break; |
| 6416 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6417 | case 307: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6418 | #line 3838 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6419 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6420 | const Type *PTy = yyvsp[0].ValueVal.V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6421 | if (!isa<PointerType>(PTy)) |
| 6422 | error("Trying to free nonpointer type '" + PTy->getDescription() + "'"); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6423 | yyval.InstVal.I = new FreeInst(yyvsp[0].ValueVal.V); |
| 6424 | yyval.InstVal.S.makeSignless(); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6425 | ;} |
| 6426 | break; |
| 6427 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6428 | case 308: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6429 | #line 3845 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6430 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6431 | const Type* Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 6432 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6433 | if (!isa<PointerType>(Ty)) |
| 6434 | error("Can't load from nonpointer type: " + Ty->getDescription()); |
| 6435 | if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType()) |
| 6436 | error("Can't load from pointer of non-first-class type: " + |
| 6437 | Ty->getDescription()); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6438 | Value* tmpVal = getVal(Ty, yyvsp[0].ValIDVal); |
| 6439 | yyval.InstVal.I = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal); |
| 6440 | yyval.InstVal.S.copy(yyvsp[-1].TypeVal.S.get(0)); |
| 6441 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6442 | ;} |
| 6443 | break; |
| 6444 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6445 | case 309: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6446 | #line 3858 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6447 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6448 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
| 6449 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6450 | if (!PTy) |
| 6451 | error("Can't store to a nonpointer type: " + |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6452 | yyvsp[-1].TypeVal.PAT->get()->getDescription()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6453 | const Type *ElTy = PTy->getElementType(); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6454 | Value *StoreVal = yyvsp[-3].ValueVal.V; |
| 6455 | Value* tmpVal = getVal(PTy, yyvsp[0].ValIDVal); |
| 6456 | if (ElTy != yyvsp[-3].ValueVal.V->getType()) { |
| 6457 | StoreVal = handleSRetFuncTypeMerge(yyvsp[-3].ValueVal.V, ElTy); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6458 | if (!StoreVal) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6459 | error("Can't store '" + yyvsp[-3].ValueVal.V->getType()->getDescription() + |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6460 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 6461 | else { |
| 6462 | PTy = PointerType::get(StoreVal->getType()); |
| 6463 | if (Constant *C = dyn_cast<Constant>(tmpVal)) |
| 6464 | tmpVal = ConstantExpr::getBitCast(C, PTy); |
| 6465 | else |
| 6466 | tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB); |
| 6467 | } |
| 6468 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6469 | yyval.InstVal.I = new StoreInst(StoreVal, tmpVal, yyvsp[-5].BoolVal); |
| 6470 | yyval.InstVal.S.makeSignless(); |
| 6471 | delete yyvsp[-1].TypeVal.PAT; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6472 | ;} |
| 6473 | break; |
| 6474 | |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 6475 | case 310: |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6476 | #line 3884 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6477 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6478 | yyvsp[-1].ValIDVal.S.copy(yyvsp[-2].TypeVal.S); |
| 6479 | const Type* Ty = yyvsp[-2].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6480 | if (!isa<PointerType>(Ty)) |
| 6481 | error("getelementptr insn requires pointer operand"); |
| 6482 | |
| 6483 | std::vector<Value*> VIndices; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6484 | upgradeGEPInstIndices(Ty, yyvsp[0].ValueList, VIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6485 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6486 | Value* tmpVal = getVal(Ty, yyvsp[-1].ValIDVal); |
| 6487 | yyval.InstVal.I = new GetElementPtrInst(tmpVal, VIndices.begin(), VIndices.end()); |
| 6488 | ValueInfo VI; VI.V = tmpVal; VI.S.copy(yyvsp[-2].TypeVal.S); |
| 6489 | yyval.InstVal.S.copy(getElementSign(VI, VIndices)); |
| 6490 | delete yyvsp[-2].TypeVal.PAT; |
| 6491 | delete yyvsp[0].ValueList; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6492 | ;} |
| 6493 | break; |
| 6494 | |
| 6495 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6496 | } |
| 6497 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6498 | /* Line 993 of yacc.c. */ |
| 6499 | #line 6500 "UpgradeParser.tab.c" |
| 6500 | |
| 6501 | yyvsp -= yylen; |
| 6502 | yyssp -= yylen; |
| 6503 | |
| 6504 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6505 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6506 | |
| 6507 | *++yyvsp = yyval; |
| 6508 | |
| 6509 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6510 | /* Now `shift' the result of the reduction. Determine what state |
| 6511 | that goes to, based on the state we popped back to and the rule |
| 6512 | number reduced by. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6513 | |
| 6514 | yyn = yyr1[yyn]; |
| 6515 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6516 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 6517 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6518 | yystate = yytable[yystate]; |
| 6519 | else |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6520 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6521 | |
| 6522 | goto yynewstate; |
| 6523 | |
| 6524 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6525 | /*------------------------------------. |
| 6526 | | yyerrlab -- here on detecting error | |
| 6527 | `------------------------------------*/ |
| 6528 | yyerrlab: |
| 6529 | /* If not already recovering from an error, report this error. */ |
| 6530 | if (!yyerrstatus) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6531 | { |
| 6532 | ++yynerrs; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6533 | #if YYERROR_VERBOSE |
| 6534 | yyn = yypact[yystate]; |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 6535 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6536 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
| 6537 | { |
| 6538 | YYSIZE_T yysize = 0; |
| 6539 | int yytype = YYTRANSLATE (yychar); |
| 6540 | const char* yyprefix; |
| 6541 | char *yymsg; |
| 6542 | int yyx; |
| 6543 | |
| 6544 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 6545 | YYCHECK. */ |
| 6546 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 6547 | |
| 6548 | /* Stay within bounds of both yycheck and yytname. */ |
| 6549 | int yychecklim = YYLAST - yyn; |
| 6550 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 6551 | int yycount = 0; |
| 6552 | |
| 6553 | yyprefix = ", expecting "; |
| 6554 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 6555 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 6556 | { |
| 6557 | yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); |
| 6558 | yycount += 1; |
| 6559 | if (yycount == 5) |
| 6560 | { |
| 6561 | yysize = 0; |
| 6562 | break; |
| 6563 | } |
| 6564 | } |
| 6565 | yysize += (sizeof ("syntax error, unexpected ") |
| 6566 | + yystrlen (yytname[yytype])); |
| 6567 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 6568 | if (yymsg != 0) |
| 6569 | { |
| 6570 | char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); |
| 6571 | yyp = yystpcpy (yyp, yytname[yytype]); |
| 6572 | |
| 6573 | if (yycount < 5) |
| 6574 | { |
| 6575 | yyprefix = ", expecting "; |
| 6576 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 6577 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 6578 | { |
| 6579 | yyp = yystpcpy (yyp, yyprefix); |
| 6580 | yyp = yystpcpy (yyp, yytname[yyx]); |
| 6581 | yyprefix = " or "; |
| 6582 | } |
| 6583 | } |
| 6584 | yyerror (yymsg); |
| 6585 | YYSTACK_FREE (yymsg); |
| 6586 | } |
| 6587 | else |
| 6588 | yyerror ("syntax error; also virtual memory exhausted"); |
| 6589 | } |
| 6590 | else |
| 6591 | #endif /* YYERROR_VERBOSE */ |
| 6592 | yyerror ("syntax error"); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6593 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6594 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6595 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6596 | |
| 6597 | if (yyerrstatus == 3) |
| 6598 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6599 | /* If just tried and failed to reuse lookahead token after an |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6600 | error, discard it. */ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6601 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6602 | if (yychar <= YYEOF) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6603 | { |
| 6604 | /* If at end of input, pop the error token, |
| 6605 | then the rest of the stack, then return failure. */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6606 | if (yychar == YYEOF) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6607 | for (;;) |
| 6608 | { |
| 6609 | YYPOPSTACK; |
| 6610 | if (yyssp == yyss) |
| 6611 | YYABORT; |
| 6612 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); |
| 6613 | yydestruct (yystos[*yyssp], yyvsp); |
| 6614 | } |
| 6615 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6616 | else |
| 6617 | { |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6618 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); |
| 6619 | yydestruct (yytoken, &yylval); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6620 | yychar = YYEMPTY; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6621 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6622 | } |
| 6623 | } |
| 6624 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6625 | /* Else will try to reuse lookahead token after shifting the error |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6626 | token. */ |
| 6627 | goto yyerrlab1; |
| 6628 | |
| 6629 | |
| 6630 | /*---------------------------------------------------. |
| 6631 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 6632 | `---------------------------------------------------*/ |
| 6633 | yyerrorlab: |
| 6634 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6635 | #ifdef __GNUC__ |
| 6636 | /* Pacify GCC when the user code never invokes YYERROR and the label |
| 6637 | yyerrorlab therefore never appears in user code. */ |
| 6638 | if (0) |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6639 | goto yyerrorlab; |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6640 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6641 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6642 | yyvsp -= yylen; |
| 6643 | yyssp -= yylen; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6644 | yystate = *yyssp; |
| 6645 | goto yyerrlab1; |
| 6646 | |
| 6647 | |
| 6648 | /*-------------------------------------------------------------. |
| 6649 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 6650 | `-------------------------------------------------------------*/ |
| 6651 | yyerrlab1: |
| 6652 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 6653 | |
| 6654 | for (;;) |
| 6655 | { |
| 6656 | yyn = yypact[yystate]; |
| 6657 | if (yyn != YYPACT_NINF) |
| 6658 | { |
| 6659 | yyn += YYTERROR; |
| 6660 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 6661 | { |
| 6662 | yyn = yytable[yyn]; |
| 6663 | if (0 < yyn) |
| 6664 | break; |
| 6665 | } |
| 6666 | } |
| 6667 | |
| 6668 | /* Pop the current state because it cannot handle the error token. */ |
| 6669 | if (yyssp == yyss) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6670 | YYABORT; |
| 6671 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6672 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); |
| 6673 | yydestruct (yystos[yystate], yyvsp); |
| 6674 | YYPOPSTACK; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6675 | yystate = *yyssp; |
| 6676 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6677 | } |
| 6678 | |
| 6679 | if (yyn == YYFINAL) |
| 6680 | YYACCEPT; |
| 6681 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6682 | YYDPRINTF ((stderr, "Shifting error token, ")); |
| 6683 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6684 | *++yyvsp = yylval; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6685 | |
| 6686 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6687 | yystate = yyn; |
| 6688 | goto yynewstate; |
| 6689 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6690 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6691 | /*-------------------------------------. |
| 6692 | | yyacceptlab -- YYACCEPT comes here. | |
| 6693 | `-------------------------------------*/ |
| 6694 | yyacceptlab: |
| 6695 | yyresult = 0; |
| 6696 | goto yyreturn; |
| 6697 | |
| 6698 | /*-----------------------------------. |
| 6699 | | yyabortlab -- YYABORT comes here. | |
| 6700 | `-----------------------------------*/ |
| 6701 | yyabortlab: |
| 6702 | yyresult = 1; |
| 6703 | goto yyreturn; |
| 6704 | |
| 6705 | #ifndef yyoverflow |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6706 | /*----------------------------------------------. |
| 6707 | | yyoverflowlab -- parser overflow comes here. | |
| 6708 | `----------------------------------------------*/ |
| 6709 | yyoverflowlab: |
| 6710 | yyerror ("parser stack overflow"); |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6711 | yyresult = 2; |
| 6712 | /* Fall through. */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 6713 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6714 | |
| 6715 | yyreturn: |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6716 | #ifndef yyoverflow |
| 6717 | if (yyss != yyssa) |
| 6718 | YYSTACK_FREE (yyss); |
| 6719 | #endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6720 | return yyresult; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6721 | } |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6722 | |
| 6723 | |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame^] | 6724 | #line 3902 "/users/dag/projects/cascade/llvm.modified/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6725 | |
| 6726 | |
| 6727 | int yyerror(const char *ErrorMsg) { |
| 6728 | std::string where |
| 6729 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6730 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6731 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 6732 | if (yychar != YYEMPTY && yychar != 0) |
| 6733 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6734 | "'."; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 6735 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6736 | std::cout << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6737 | exit(1); |
| 6738 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6739 | |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 6740 | void warning(const std::string& ErrorMsg) { |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6741 | std::string where |
| 6742 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 6743 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6744 | std::string errMsg = where + "warning: " + std::string(ErrorMsg); |
| 6745 | if (yychar != YYEMPTY && yychar != 0) |
| 6746 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 6747 | "'."; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 6748 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
| 6749 | } |
| 6750 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 6751 | void error(const std::string& ErrorMsg, int LineNo) { |
| 6752 | if (LineNo == -1) LineNo = Upgradelineno; |
| 6753 | Upgradelineno = LineNo; |
| 6754 | yyerror(ErrorMsg.c_str()); |
| 6755 | } |
| 6756 | |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 6757 | |