mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 00:33:09 +00:00
Regenerate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32908 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bcdd54cf6f
commit
319a730353
File diff suppressed because it is too large
Load Diff
@ -940,7 +940,7 @@ char *yytext;
|
|||||||
#define YY_NEVER_INTERACTIVE 1
|
#define YY_NEVER_INTERACTIVE 1
|
||||||
#line 28 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
#line 28 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||||
|
|
||||||
#include "ParserInternals.h"
|
#include "UpgradeInternals.h"
|
||||||
#include "UpgradeParser.h"
|
#include "UpgradeParser.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -962,7 +962,7 @@ char *yytext;
|
|||||||
return sym
|
return sym
|
||||||
|
|
||||||
#define RET_TY(sym,OldTY,NewTY,sign) \
|
#define RET_TY(sym,OldTY,NewTY,sign) \
|
||||||
Upgradelval.Type = new TypeInfo(NewTY, OldTY); \
|
Upgradelval.Type = TypeInfo::get(NewTY, OldTY); \
|
||||||
return sym
|
return sym
|
||||||
|
|
||||||
#define YY_NEVER_INTERACTIVE 1
|
#define YY_NEVER_INTERACTIVE 1
|
||||||
@ -1196,7 +1196,7 @@ yy_match:
|
|||||||
yy_find_action:
|
yy_find_action:
|
||||||
yy_current_state = *--yy_state_ptr;
|
yy_current_state = *--yy_state_ptr;
|
||||||
yy_lp = yy_accept[yy_current_state];
|
yy_lp = yy_accept[yy_current_state];
|
||||||
find_rule: /* we branch to this label when backing up */
|
|
||||||
for ( ; ; ) /* until we find what rule we matched */
|
for ( ; ; ) /* until we find what rule we matched */
|
||||||
{
|
{
|
||||||
if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )
|
if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
||||||
#include "ParserInternals.h"
|
#include "UpgradeInternals.h"
|
||||||
#include "UpgradeParser.h"
|
#include "UpgradeParser.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -48,7 +48,7 @@
|
|||||||
return sym
|
return sym
|
||||||
|
|
||||||
#define RET_TY(sym,OldTY,NewTY,sign) \
|
#define RET_TY(sym,OldTY,NewTY,sign) \
|
||||||
Upgradelval.Type = new TypeInfo(NewTY, OldTY); \
|
Upgradelval.Type = TypeInfo::get(NewTY, OldTY); \
|
||||||
return sym
|
return sym
|
||||||
|
|
||||||
#define YY_NEVER_INTERACTIVE 1
|
#define YY_NEVER_INTERACTIVE 1
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,159 +1,355 @@
|
|||||||
typedef union {
|
/* A Bison parser, made by GNU Bison 2.1. */
|
||||||
|
|
||||||
|
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||||
|
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
/* As a special exception, when this file is copied by Bison into a
|
||||||
|
Bison output file, you may use that output file without restriction.
|
||||||
|
This special exception was added by the Free Software Foundation
|
||||||
|
in version 1.24 of Bison. */
|
||||||
|
|
||||||
|
/* Tokens. */
|
||||||
|
#ifndef YYTOKENTYPE
|
||||||
|
# define YYTOKENTYPE
|
||||||
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
|
know about them. */
|
||||||
|
enum yytokentype {
|
||||||
|
VOID = 258,
|
||||||
|
BOOL = 259,
|
||||||
|
SBYTE = 260,
|
||||||
|
UBYTE = 261,
|
||||||
|
SHORT = 262,
|
||||||
|
USHORT = 263,
|
||||||
|
INT = 264,
|
||||||
|
UINT = 265,
|
||||||
|
LONG = 266,
|
||||||
|
ULONG = 267,
|
||||||
|
FLOAT = 268,
|
||||||
|
DOUBLE = 269,
|
||||||
|
LABEL = 270,
|
||||||
|
OPAQUE = 271,
|
||||||
|
ESINT64VAL = 272,
|
||||||
|
EUINT64VAL = 273,
|
||||||
|
SINTVAL = 274,
|
||||||
|
UINTVAL = 275,
|
||||||
|
FPVAL = 276,
|
||||||
|
NULL_TOK = 277,
|
||||||
|
UNDEF = 278,
|
||||||
|
ZEROINITIALIZER = 279,
|
||||||
|
TRUETOK = 280,
|
||||||
|
FALSETOK = 281,
|
||||||
|
TYPE = 282,
|
||||||
|
VAR_ID = 283,
|
||||||
|
LABELSTR = 284,
|
||||||
|
STRINGCONSTANT = 285,
|
||||||
|
IMPLEMENTATION = 286,
|
||||||
|
BEGINTOK = 287,
|
||||||
|
ENDTOK = 288,
|
||||||
|
DECLARE = 289,
|
||||||
|
GLOBAL = 290,
|
||||||
|
CONSTANT = 291,
|
||||||
|
SECTION = 292,
|
||||||
|
VOLATILE = 293,
|
||||||
|
TO = 294,
|
||||||
|
DOTDOTDOT = 295,
|
||||||
|
CONST = 296,
|
||||||
|
INTERNAL = 297,
|
||||||
|
LINKONCE = 298,
|
||||||
|
WEAK = 299,
|
||||||
|
DLLIMPORT = 300,
|
||||||
|
DLLEXPORT = 301,
|
||||||
|
EXTERN_WEAK = 302,
|
||||||
|
APPENDING = 303,
|
||||||
|
NOT = 304,
|
||||||
|
EXTERNAL = 305,
|
||||||
|
TARGET = 306,
|
||||||
|
TRIPLE = 307,
|
||||||
|
ENDIAN = 308,
|
||||||
|
POINTERSIZE = 309,
|
||||||
|
LITTLE = 310,
|
||||||
|
BIG = 311,
|
||||||
|
ALIGN = 312,
|
||||||
|
UNINITIALIZED = 313,
|
||||||
|
DEPLIBS = 314,
|
||||||
|
CALL = 315,
|
||||||
|
TAIL = 316,
|
||||||
|
ASM_TOK = 317,
|
||||||
|
MODULE = 318,
|
||||||
|
SIDEEFFECT = 319,
|
||||||
|
CC_TOK = 320,
|
||||||
|
CCC_TOK = 321,
|
||||||
|
CSRETCC_TOK = 322,
|
||||||
|
FASTCC_TOK = 323,
|
||||||
|
COLDCC_TOK = 324,
|
||||||
|
X86_STDCALLCC_TOK = 325,
|
||||||
|
X86_FASTCALLCC_TOK = 326,
|
||||||
|
DATALAYOUT = 327,
|
||||||
|
RET = 328,
|
||||||
|
BR = 329,
|
||||||
|
SWITCH = 330,
|
||||||
|
INVOKE = 331,
|
||||||
|
EXCEPT = 332,
|
||||||
|
UNWIND = 333,
|
||||||
|
UNREACHABLE = 334,
|
||||||
|
ADD = 335,
|
||||||
|
SUB = 336,
|
||||||
|
MUL = 337,
|
||||||
|
DIV = 338,
|
||||||
|
UDIV = 339,
|
||||||
|
SDIV = 340,
|
||||||
|
FDIV = 341,
|
||||||
|
REM = 342,
|
||||||
|
UREM = 343,
|
||||||
|
SREM = 344,
|
||||||
|
FREM = 345,
|
||||||
|
AND = 346,
|
||||||
|
OR = 347,
|
||||||
|
XOR = 348,
|
||||||
|
SETLE = 349,
|
||||||
|
SETGE = 350,
|
||||||
|
SETLT = 351,
|
||||||
|
SETGT = 352,
|
||||||
|
SETEQ = 353,
|
||||||
|
SETNE = 354,
|
||||||
|
ICMP = 355,
|
||||||
|
FCMP = 356,
|
||||||
|
EQ = 357,
|
||||||
|
NE = 358,
|
||||||
|
SLT = 359,
|
||||||
|
SGT = 360,
|
||||||
|
SLE = 361,
|
||||||
|
SGE = 362,
|
||||||
|
OEQ = 363,
|
||||||
|
ONE = 364,
|
||||||
|
OLT = 365,
|
||||||
|
OGT = 366,
|
||||||
|
OLE = 367,
|
||||||
|
OGE = 368,
|
||||||
|
ORD = 369,
|
||||||
|
UNO = 370,
|
||||||
|
UEQ = 371,
|
||||||
|
UNE = 372,
|
||||||
|
ULT = 373,
|
||||||
|
UGT = 374,
|
||||||
|
ULE = 375,
|
||||||
|
UGE = 376,
|
||||||
|
MALLOC = 377,
|
||||||
|
ALLOCA = 378,
|
||||||
|
FREE = 379,
|
||||||
|
LOAD = 380,
|
||||||
|
STORE = 381,
|
||||||
|
GETELEMENTPTR = 382,
|
||||||
|
PHI_TOK = 383,
|
||||||
|
SELECT = 384,
|
||||||
|
SHL = 385,
|
||||||
|
SHR = 386,
|
||||||
|
ASHR = 387,
|
||||||
|
LSHR = 388,
|
||||||
|
VAARG = 389,
|
||||||
|
EXTRACTELEMENT = 390,
|
||||||
|
INSERTELEMENT = 391,
|
||||||
|
SHUFFLEVECTOR = 392,
|
||||||
|
CAST = 393,
|
||||||
|
TRUNC = 394,
|
||||||
|
ZEXT = 395,
|
||||||
|
SEXT = 396,
|
||||||
|
FPTRUNC = 397,
|
||||||
|
FPEXT = 398,
|
||||||
|
FPTOUI = 399,
|
||||||
|
FPTOSI = 400,
|
||||||
|
UITOFP = 401,
|
||||||
|
SITOFP = 402,
|
||||||
|
PTRTOINT = 403,
|
||||||
|
INTTOPTR = 404,
|
||||||
|
BITCAST = 405
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
/* Tokens. */
|
||||||
|
#define VOID 258
|
||||||
|
#define BOOL 259
|
||||||
|
#define SBYTE 260
|
||||||
|
#define UBYTE 261
|
||||||
|
#define SHORT 262
|
||||||
|
#define USHORT 263
|
||||||
|
#define INT 264
|
||||||
|
#define UINT 265
|
||||||
|
#define LONG 266
|
||||||
|
#define ULONG 267
|
||||||
|
#define FLOAT 268
|
||||||
|
#define DOUBLE 269
|
||||||
|
#define LABEL 270
|
||||||
|
#define OPAQUE 271
|
||||||
|
#define ESINT64VAL 272
|
||||||
|
#define EUINT64VAL 273
|
||||||
|
#define SINTVAL 274
|
||||||
|
#define UINTVAL 275
|
||||||
|
#define FPVAL 276
|
||||||
|
#define NULL_TOK 277
|
||||||
|
#define UNDEF 278
|
||||||
|
#define ZEROINITIALIZER 279
|
||||||
|
#define TRUETOK 280
|
||||||
|
#define FALSETOK 281
|
||||||
|
#define TYPE 282
|
||||||
|
#define VAR_ID 283
|
||||||
|
#define LABELSTR 284
|
||||||
|
#define STRINGCONSTANT 285
|
||||||
|
#define IMPLEMENTATION 286
|
||||||
|
#define BEGINTOK 287
|
||||||
|
#define ENDTOK 288
|
||||||
|
#define DECLARE 289
|
||||||
|
#define GLOBAL 290
|
||||||
|
#define CONSTANT 291
|
||||||
|
#define SECTION 292
|
||||||
|
#define VOLATILE 293
|
||||||
|
#define TO 294
|
||||||
|
#define DOTDOTDOT 295
|
||||||
|
#define CONST 296
|
||||||
|
#define INTERNAL 297
|
||||||
|
#define LINKONCE 298
|
||||||
|
#define WEAK 299
|
||||||
|
#define DLLIMPORT 300
|
||||||
|
#define DLLEXPORT 301
|
||||||
|
#define EXTERN_WEAK 302
|
||||||
|
#define APPENDING 303
|
||||||
|
#define NOT 304
|
||||||
|
#define EXTERNAL 305
|
||||||
|
#define TARGET 306
|
||||||
|
#define TRIPLE 307
|
||||||
|
#define ENDIAN 308
|
||||||
|
#define POINTERSIZE 309
|
||||||
|
#define LITTLE 310
|
||||||
|
#define BIG 311
|
||||||
|
#define ALIGN 312
|
||||||
|
#define UNINITIALIZED 313
|
||||||
|
#define DEPLIBS 314
|
||||||
|
#define CALL 315
|
||||||
|
#define TAIL 316
|
||||||
|
#define ASM_TOK 317
|
||||||
|
#define MODULE 318
|
||||||
|
#define SIDEEFFECT 319
|
||||||
|
#define CC_TOK 320
|
||||||
|
#define CCC_TOK 321
|
||||||
|
#define CSRETCC_TOK 322
|
||||||
|
#define FASTCC_TOK 323
|
||||||
|
#define COLDCC_TOK 324
|
||||||
|
#define X86_STDCALLCC_TOK 325
|
||||||
|
#define X86_FASTCALLCC_TOK 326
|
||||||
|
#define DATALAYOUT 327
|
||||||
|
#define RET 328
|
||||||
|
#define BR 329
|
||||||
|
#define SWITCH 330
|
||||||
|
#define INVOKE 331
|
||||||
|
#define EXCEPT 332
|
||||||
|
#define UNWIND 333
|
||||||
|
#define UNREACHABLE 334
|
||||||
|
#define ADD 335
|
||||||
|
#define SUB 336
|
||||||
|
#define MUL 337
|
||||||
|
#define DIV 338
|
||||||
|
#define UDIV 339
|
||||||
|
#define SDIV 340
|
||||||
|
#define FDIV 341
|
||||||
|
#define REM 342
|
||||||
|
#define UREM 343
|
||||||
|
#define SREM 344
|
||||||
|
#define FREM 345
|
||||||
|
#define AND 346
|
||||||
|
#define OR 347
|
||||||
|
#define XOR 348
|
||||||
|
#define SETLE 349
|
||||||
|
#define SETGE 350
|
||||||
|
#define SETLT 351
|
||||||
|
#define SETGT 352
|
||||||
|
#define SETEQ 353
|
||||||
|
#define SETNE 354
|
||||||
|
#define ICMP 355
|
||||||
|
#define FCMP 356
|
||||||
|
#define EQ 357
|
||||||
|
#define NE 358
|
||||||
|
#define SLT 359
|
||||||
|
#define SGT 360
|
||||||
|
#define SLE 361
|
||||||
|
#define SGE 362
|
||||||
|
#define OEQ 363
|
||||||
|
#define ONE 364
|
||||||
|
#define OLT 365
|
||||||
|
#define OGT 366
|
||||||
|
#define OLE 367
|
||||||
|
#define OGE 368
|
||||||
|
#define ORD 369
|
||||||
|
#define UNO 370
|
||||||
|
#define UEQ 371
|
||||||
|
#define UNE 372
|
||||||
|
#define ULT 373
|
||||||
|
#define UGT 374
|
||||||
|
#define ULE 375
|
||||||
|
#define UGE 376
|
||||||
|
#define MALLOC 377
|
||||||
|
#define ALLOCA 378
|
||||||
|
#define FREE 379
|
||||||
|
#define LOAD 380
|
||||||
|
#define STORE 381
|
||||||
|
#define GETELEMENTPTR 382
|
||||||
|
#define PHI_TOK 383
|
||||||
|
#define SELECT 384
|
||||||
|
#define SHL 385
|
||||||
|
#define SHR 386
|
||||||
|
#define ASHR 387
|
||||||
|
#define LSHR 388
|
||||||
|
#define VAARG 389
|
||||||
|
#define EXTRACTELEMENT 390
|
||||||
|
#define INSERTELEMENT 391
|
||||||
|
#define SHUFFLEVECTOR 392
|
||||||
|
#define CAST 393
|
||||||
|
#define TRUNC 394
|
||||||
|
#define ZEXT 395
|
||||||
|
#define SEXT 396
|
||||||
|
#define FPTRUNC 397
|
||||||
|
#define FPEXT 398
|
||||||
|
#define FPTOUI 399
|
||||||
|
#define FPTOSI 400
|
||||||
|
#define UITOFP 401
|
||||||
|
#define SITOFP 402
|
||||||
|
#define PTRTOINT 403
|
||||||
|
#define INTTOPTR 404
|
||||||
|
#define BITCAST 405
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||||
|
#line 742 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
|
||||||
|
typedef union YYSTYPE {
|
||||||
std::string* String;
|
std::string* String;
|
||||||
TypeInfo* Type;
|
const TypeInfo* Type;
|
||||||
ValueInfo Value;
|
ValueInfo Value;
|
||||||
ConstInfo Const;
|
ConstInfo Const;
|
||||||
ValueList* ValList;
|
ValueList* ValList;
|
||||||
TypeList* TypeVec;
|
TypeList* TypeVec;
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
#define VOID 257
|
/* Line 1447 of yacc.c. */
|
||||||
#define BOOL 258
|
#line 347 "UpgradeParser.tab.h"
|
||||||
#define SBYTE 259
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
#define UBYTE 260
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
#define SHORT 261
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
#define USHORT 262
|
#endif
|
||||||
#define INT 263
|
|
||||||
#define UINT 264
|
|
||||||
#define LONG 265
|
|
||||||
#define ULONG 266
|
|
||||||
#define FLOAT 267
|
|
||||||
#define DOUBLE 268
|
|
||||||
#define LABEL 269
|
|
||||||
#define OPAQUE 270
|
|
||||||
#define ESINT64VAL 271
|
|
||||||
#define EUINT64VAL 272
|
|
||||||
#define SINTVAL 273
|
|
||||||
#define UINTVAL 274
|
|
||||||
#define FPVAL 275
|
|
||||||
#define NULL_TOK 276
|
|
||||||
#define UNDEF 277
|
|
||||||
#define ZEROINITIALIZER 278
|
|
||||||
#define TRUETOK 279
|
|
||||||
#define FALSETOK 280
|
|
||||||
#define TYPE 281
|
|
||||||
#define VAR_ID 282
|
|
||||||
#define LABELSTR 283
|
|
||||||
#define STRINGCONSTANT 284
|
|
||||||
#define IMPLEMENTATION 285
|
|
||||||
#define BEGINTOK 286
|
|
||||||
#define ENDTOK 287
|
|
||||||
#define DECLARE 288
|
|
||||||
#define GLOBAL 289
|
|
||||||
#define CONSTANT 290
|
|
||||||
#define SECTION 291
|
|
||||||
#define VOLATILE 292
|
|
||||||
#define TO 293
|
|
||||||
#define DOTDOTDOT 294
|
|
||||||
#define CONST 295
|
|
||||||
#define INTERNAL 296
|
|
||||||
#define LINKONCE 297
|
|
||||||
#define WEAK 298
|
|
||||||
#define DLLIMPORT 299
|
|
||||||
#define DLLEXPORT 300
|
|
||||||
#define EXTERN_WEAK 301
|
|
||||||
#define APPENDING 302
|
|
||||||
#define NOT 303
|
|
||||||
#define EXTERNAL 304
|
|
||||||
#define TARGET 305
|
|
||||||
#define TRIPLE 306
|
|
||||||
#define ENDIAN 307
|
|
||||||
#define POINTERSIZE 308
|
|
||||||
#define LITTLE 309
|
|
||||||
#define BIG 310
|
|
||||||
#define ALIGN 311
|
|
||||||
#define UNINITIALIZED 312
|
|
||||||
#define DEPLIBS 313
|
|
||||||
#define CALL 314
|
|
||||||
#define TAIL 315
|
|
||||||
#define ASM_TOK 316
|
|
||||||
#define MODULE 317
|
|
||||||
#define SIDEEFFECT 318
|
|
||||||
#define CC_TOK 319
|
|
||||||
#define CCC_TOK 320
|
|
||||||
#define CSRETCC_TOK 321
|
|
||||||
#define FASTCC_TOK 322
|
|
||||||
#define COLDCC_TOK 323
|
|
||||||
#define X86_STDCALLCC_TOK 324
|
|
||||||
#define X86_FASTCALLCC_TOK 325
|
|
||||||
#define DATALAYOUT 326
|
|
||||||
#define RET 327
|
|
||||||
#define BR 328
|
|
||||||
#define SWITCH 329
|
|
||||||
#define INVOKE 330
|
|
||||||
#define EXCEPT 331
|
|
||||||
#define UNWIND 332
|
|
||||||
#define UNREACHABLE 333
|
|
||||||
#define ADD 334
|
|
||||||
#define SUB 335
|
|
||||||
#define MUL 336
|
|
||||||
#define DIV 337
|
|
||||||
#define UDIV 338
|
|
||||||
#define SDIV 339
|
|
||||||
#define FDIV 340
|
|
||||||
#define REM 341
|
|
||||||
#define UREM 342
|
|
||||||
#define SREM 343
|
|
||||||
#define FREM 344
|
|
||||||
#define AND 345
|
|
||||||
#define OR 346
|
|
||||||
#define XOR 347
|
|
||||||
#define SETLE 348
|
|
||||||
#define SETGE 349
|
|
||||||
#define SETLT 350
|
|
||||||
#define SETGT 351
|
|
||||||
#define SETEQ 352
|
|
||||||
#define SETNE 353
|
|
||||||
#define ICMP 354
|
|
||||||
#define FCMP 355
|
|
||||||
#define EQ 356
|
|
||||||
#define NE 357
|
|
||||||
#define SLT 358
|
|
||||||
#define SGT 359
|
|
||||||
#define SLE 360
|
|
||||||
#define SGE 361
|
|
||||||
#define OEQ 362
|
|
||||||
#define ONE 363
|
|
||||||
#define OLT 364
|
|
||||||
#define OGT 365
|
|
||||||
#define OLE 366
|
|
||||||
#define OGE 367
|
|
||||||
#define ORD 368
|
|
||||||
#define UNO 369
|
|
||||||
#define UEQ 370
|
|
||||||
#define UNE 371
|
|
||||||
#define ULT 372
|
|
||||||
#define UGT 373
|
|
||||||
#define ULE 374
|
|
||||||
#define UGE 375
|
|
||||||
#define MALLOC 376
|
|
||||||
#define ALLOCA 377
|
|
||||||
#define FREE 378
|
|
||||||
#define LOAD 379
|
|
||||||
#define STORE 380
|
|
||||||
#define GETELEMENTPTR 381
|
|
||||||
#define PHI_TOK 382
|
|
||||||
#define SELECT 383
|
|
||||||
#define SHL 384
|
|
||||||
#define SHR 385
|
|
||||||
#define ASHR 386
|
|
||||||
#define LSHR 387
|
|
||||||
#define VAARG 388
|
|
||||||
#define EXTRACTELEMENT 389
|
|
||||||
#define INSERTELEMENT 390
|
|
||||||
#define SHUFFLEVECTOR 391
|
|
||||||
#define CAST 392
|
|
||||||
#define TRUNC 393
|
|
||||||
#define ZEXT 394
|
|
||||||
#define SEXT 395
|
|
||||||
#define FPTRUNC 396
|
|
||||||
#define FPEXT 397
|
|
||||||
#define FPTOUI 398
|
|
||||||
#define FPTOSI 399
|
|
||||||
#define UITOFP 400
|
|
||||||
#define SITOFP 401
|
|
||||||
#define PTRTOINT 402
|
|
||||||
#define INTTOPTR 403
|
|
||||||
#define BITCAST 404
|
|
||||||
|
|
||||||
|
|
||||||
extern YYSTYPE Upgradelval;
|
extern YYSTYPE Upgradelval;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,159 +1,355 @@
|
|||||||
typedef union {
|
/* A Bison parser, made by GNU Bison 2.1. */
|
||||||
|
|
||||||
|
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||||
|
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
/* As a special exception, when this file is copied by Bison into a
|
||||||
|
Bison output file, you may use that output file without restriction.
|
||||||
|
This special exception was added by the Free Software Foundation
|
||||||
|
in version 1.24 of Bison. */
|
||||||
|
|
||||||
|
/* Tokens. */
|
||||||
|
#ifndef YYTOKENTYPE
|
||||||
|
# define YYTOKENTYPE
|
||||||
|
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||||
|
know about them. */
|
||||||
|
enum yytokentype {
|
||||||
|
VOID = 258,
|
||||||
|
BOOL = 259,
|
||||||
|
SBYTE = 260,
|
||||||
|
UBYTE = 261,
|
||||||
|
SHORT = 262,
|
||||||
|
USHORT = 263,
|
||||||
|
INT = 264,
|
||||||
|
UINT = 265,
|
||||||
|
LONG = 266,
|
||||||
|
ULONG = 267,
|
||||||
|
FLOAT = 268,
|
||||||
|
DOUBLE = 269,
|
||||||
|
LABEL = 270,
|
||||||
|
OPAQUE = 271,
|
||||||
|
ESINT64VAL = 272,
|
||||||
|
EUINT64VAL = 273,
|
||||||
|
SINTVAL = 274,
|
||||||
|
UINTVAL = 275,
|
||||||
|
FPVAL = 276,
|
||||||
|
NULL_TOK = 277,
|
||||||
|
UNDEF = 278,
|
||||||
|
ZEROINITIALIZER = 279,
|
||||||
|
TRUETOK = 280,
|
||||||
|
FALSETOK = 281,
|
||||||
|
TYPE = 282,
|
||||||
|
VAR_ID = 283,
|
||||||
|
LABELSTR = 284,
|
||||||
|
STRINGCONSTANT = 285,
|
||||||
|
IMPLEMENTATION = 286,
|
||||||
|
BEGINTOK = 287,
|
||||||
|
ENDTOK = 288,
|
||||||
|
DECLARE = 289,
|
||||||
|
GLOBAL = 290,
|
||||||
|
CONSTANT = 291,
|
||||||
|
SECTION = 292,
|
||||||
|
VOLATILE = 293,
|
||||||
|
TO = 294,
|
||||||
|
DOTDOTDOT = 295,
|
||||||
|
CONST = 296,
|
||||||
|
INTERNAL = 297,
|
||||||
|
LINKONCE = 298,
|
||||||
|
WEAK = 299,
|
||||||
|
DLLIMPORT = 300,
|
||||||
|
DLLEXPORT = 301,
|
||||||
|
EXTERN_WEAK = 302,
|
||||||
|
APPENDING = 303,
|
||||||
|
NOT = 304,
|
||||||
|
EXTERNAL = 305,
|
||||||
|
TARGET = 306,
|
||||||
|
TRIPLE = 307,
|
||||||
|
ENDIAN = 308,
|
||||||
|
POINTERSIZE = 309,
|
||||||
|
LITTLE = 310,
|
||||||
|
BIG = 311,
|
||||||
|
ALIGN = 312,
|
||||||
|
UNINITIALIZED = 313,
|
||||||
|
DEPLIBS = 314,
|
||||||
|
CALL = 315,
|
||||||
|
TAIL = 316,
|
||||||
|
ASM_TOK = 317,
|
||||||
|
MODULE = 318,
|
||||||
|
SIDEEFFECT = 319,
|
||||||
|
CC_TOK = 320,
|
||||||
|
CCC_TOK = 321,
|
||||||
|
CSRETCC_TOK = 322,
|
||||||
|
FASTCC_TOK = 323,
|
||||||
|
COLDCC_TOK = 324,
|
||||||
|
X86_STDCALLCC_TOK = 325,
|
||||||
|
X86_FASTCALLCC_TOK = 326,
|
||||||
|
DATALAYOUT = 327,
|
||||||
|
RET = 328,
|
||||||
|
BR = 329,
|
||||||
|
SWITCH = 330,
|
||||||
|
INVOKE = 331,
|
||||||
|
EXCEPT = 332,
|
||||||
|
UNWIND = 333,
|
||||||
|
UNREACHABLE = 334,
|
||||||
|
ADD = 335,
|
||||||
|
SUB = 336,
|
||||||
|
MUL = 337,
|
||||||
|
DIV = 338,
|
||||||
|
UDIV = 339,
|
||||||
|
SDIV = 340,
|
||||||
|
FDIV = 341,
|
||||||
|
REM = 342,
|
||||||
|
UREM = 343,
|
||||||
|
SREM = 344,
|
||||||
|
FREM = 345,
|
||||||
|
AND = 346,
|
||||||
|
OR = 347,
|
||||||
|
XOR = 348,
|
||||||
|
SETLE = 349,
|
||||||
|
SETGE = 350,
|
||||||
|
SETLT = 351,
|
||||||
|
SETGT = 352,
|
||||||
|
SETEQ = 353,
|
||||||
|
SETNE = 354,
|
||||||
|
ICMP = 355,
|
||||||
|
FCMP = 356,
|
||||||
|
EQ = 357,
|
||||||
|
NE = 358,
|
||||||
|
SLT = 359,
|
||||||
|
SGT = 360,
|
||||||
|
SLE = 361,
|
||||||
|
SGE = 362,
|
||||||
|
OEQ = 363,
|
||||||
|
ONE = 364,
|
||||||
|
OLT = 365,
|
||||||
|
OGT = 366,
|
||||||
|
OLE = 367,
|
||||||
|
OGE = 368,
|
||||||
|
ORD = 369,
|
||||||
|
UNO = 370,
|
||||||
|
UEQ = 371,
|
||||||
|
UNE = 372,
|
||||||
|
ULT = 373,
|
||||||
|
UGT = 374,
|
||||||
|
ULE = 375,
|
||||||
|
UGE = 376,
|
||||||
|
MALLOC = 377,
|
||||||
|
ALLOCA = 378,
|
||||||
|
FREE = 379,
|
||||||
|
LOAD = 380,
|
||||||
|
STORE = 381,
|
||||||
|
GETELEMENTPTR = 382,
|
||||||
|
PHI_TOK = 383,
|
||||||
|
SELECT = 384,
|
||||||
|
SHL = 385,
|
||||||
|
SHR = 386,
|
||||||
|
ASHR = 387,
|
||||||
|
LSHR = 388,
|
||||||
|
VAARG = 389,
|
||||||
|
EXTRACTELEMENT = 390,
|
||||||
|
INSERTELEMENT = 391,
|
||||||
|
SHUFFLEVECTOR = 392,
|
||||||
|
CAST = 393,
|
||||||
|
TRUNC = 394,
|
||||||
|
ZEXT = 395,
|
||||||
|
SEXT = 396,
|
||||||
|
FPTRUNC = 397,
|
||||||
|
FPEXT = 398,
|
||||||
|
FPTOUI = 399,
|
||||||
|
FPTOSI = 400,
|
||||||
|
UITOFP = 401,
|
||||||
|
SITOFP = 402,
|
||||||
|
PTRTOINT = 403,
|
||||||
|
INTTOPTR = 404,
|
||||||
|
BITCAST = 405
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
/* Tokens. */
|
||||||
|
#define VOID 258
|
||||||
|
#define BOOL 259
|
||||||
|
#define SBYTE 260
|
||||||
|
#define UBYTE 261
|
||||||
|
#define SHORT 262
|
||||||
|
#define USHORT 263
|
||||||
|
#define INT 264
|
||||||
|
#define UINT 265
|
||||||
|
#define LONG 266
|
||||||
|
#define ULONG 267
|
||||||
|
#define FLOAT 268
|
||||||
|
#define DOUBLE 269
|
||||||
|
#define LABEL 270
|
||||||
|
#define OPAQUE 271
|
||||||
|
#define ESINT64VAL 272
|
||||||
|
#define EUINT64VAL 273
|
||||||
|
#define SINTVAL 274
|
||||||
|
#define UINTVAL 275
|
||||||
|
#define FPVAL 276
|
||||||
|
#define NULL_TOK 277
|
||||||
|
#define UNDEF 278
|
||||||
|
#define ZEROINITIALIZER 279
|
||||||
|
#define TRUETOK 280
|
||||||
|
#define FALSETOK 281
|
||||||
|
#define TYPE 282
|
||||||
|
#define VAR_ID 283
|
||||||
|
#define LABELSTR 284
|
||||||
|
#define STRINGCONSTANT 285
|
||||||
|
#define IMPLEMENTATION 286
|
||||||
|
#define BEGINTOK 287
|
||||||
|
#define ENDTOK 288
|
||||||
|
#define DECLARE 289
|
||||||
|
#define GLOBAL 290
|
||||||
|
#define CONSTANT 291
|
||||||
|
#define SECTION 292
|
||||||
|
#define VOLATILE 293
|
||||||
|
#define TO 294
|
||||||
|
#define DOTDOTDOT 295
|
||||||
|
#define CONST 296
|
||||||
|
#define INTERNAL 297
|
||||||
|
#define LINKONCE 298
|
||||||
|
#define WEAK 299
|
||||||
|
#define DLLIMPORT 300
|
||||||
|
#define DLLEXPORT 301
|
||||||
|
#define EXTERN_WEAK 302
|
||||||
|
#define APPENDING 303
|
||||||
|
#define NOT 304
|
||||||
|
#define EXTERNAL 305
|
||||||
|
#define TARGET 306
|
||||||
|
#define TRIPLE 307
|
||||||
|
#define ENDIAN 308
|
||||||
|
#define POINTERSIZE 309
|
||||||
|
#define LITTLE 310
|
||||||
|
#define BIG 311
|
||||||
|
#define ALIGN 312
|
||||||
|
#define UNINITIALIZED 313
|
||||||
|
#define DEPLIBS 314
|
||||||
|
#define CALL 315
|
||||||
|
#define TAIL 316
|
||||||
|
#define ASM_TOK 317
|
||||||
|
#define MODULE 318
|
||||||
|
#define SIDEEFFECT 319
|
||||||
|
#define CC_TOK 320
|
||||||
|
#define CCC_TOK 321
|
||||||
|
#define CSRETCC_TOK 322
|
||||||
|
#define FASTCC_TOK 323
|
||||||
|
#define COLDCC_TOK 324
|
||||||
|
#define X86_STDCALLCC_TOK 325
|
||||||
|
#define X86_FASTCALLCC_TOK 326
|
||||||
|
#define DATALAYOUT 327
|
||||||
|
#define RET 328
|
||||||
|
#define BR 329
|
||||||
|
#define SWITCH 330
|
||||||
|
#define INVOKE 331
|
||||||
|
#define EXCEPT 332
|
||||||
|
#define UNWIND 333
|
||||||
|
#define UNREACHABLE 334
|
||||||
|
#define ADD 335
|
||||||
|
#define SUB 336
|
||||||
|
#define MUL 337
|
||||||
|
#define DIV 338
|
||||||
|
#define UDIV 339
|
||||||
|
#define SDIV 340
|
||||||
|
#define FDIV 341
|
||||||
|
#define REM 342
|
||||||
|
#define UREM 343
|
||||||
|
#define SREM 344
|
||||||
|
#define FREM 345
|
||||||
|
#define AND 346
|
||||||
|
#define OR 347
|
||||||
|
#define XOR 348
|
||||||
|
#define SETLE 349
|
||||||
|
#define SETGE 350
|
||||||
|
#define SETLT 351
|
||||||
|
#define SETGT 352
|
||||||
|
#define SETEQ 353
|
||||||
|
#define SETNE 354
|
||||||
|
#define ICMP 355
|
||||||
|
#define FCMP 356
|
||||||
|
#define EQ 357
|
||||||
|
#define NE 358
|
||||||
|
#define SLT 359
|
||||||
|
#define SGT 360
|
||||||
|
#define SLE 361
|
||||||
|
#define SGE 362
|
||||||
|
#define OEQ 363
|
||||||
|
#define ONE 364
|
||||||
|
#define OLT 365
|
||||||
|
#define OGT 366
|
||||||
|
#define OLE 367
|
||||||
|
#define OGE 368
|
||||||
|
#define ORD 369
|
||||||
|
#define UNO 370
|
||||||
|
#define UEQ 371
|
||||||
|
#define UNE 372
|
||||||
|
#define ULT 373
|
||||||
|
#define UGT 374
|
||||||
|
#define ULE 375
|
||||||
|
#define UGE 376
|
||||||
|
#define MALLOC 377
|
||||||
|
#define ALLOCA 378
|
||||||
|
#define FREE 379
|
||||||
|
#define LOAD 380
|
||||||
|
#define STORE 381
|
||||||
|
#define GETELEMENTPTR 382
|
||||||
|
#define PHI_TOK 383
|
||||||
|
#define SELECT 384
|
||||||
|
#define SHL 385
|
||||||
|
#define SHR 386
|
||||||
|
#define ASHR 387
|
||||||
|
#define LSHR 388
|
||||||
|
#define VAARG 389
|
||||||
|
#define EXTRACTELEMENT 390
|
||||||
|
#define INSERTELEMENT 391
|
||||||
|
#define SHUFFLEVECTOR 392
|
||||||
|
#define CAST 393
|
||||||
|
#define TRUNC 394
|
||||||
|
#define ZEXT 395
|
||||||
|
#define SEXT 396
|
||||||
|
#define FPTRUNC 397
|
||||||
|
#define FPEXT 398
|
||||||
|
#define FPTOUI 399
|
||||||
|
#define FPTOSI 400
|
||||||
|
#define UITOFP 401
|
||||||
|
#define SITOFP 402
|
||||||
|
#define PTRTOINT 403
|
||||||
|
#define INTTOPTR 404
|
||||||
|
#define BITCAST 405
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||||
|
#line 742 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
|
||||||
|
typedef union YYSTYPE {
|
||||||
std::string* String;
|
std::string* String;
|
||||||
TypeInfo* Type;
|
const TypeInfo* Type;
|
||||||
ValueInfo Value;
|
ValueInfo Value;
|
||||||
ConstInfo Const;
|
ConstInfo Const;
|
||||||
ValueList* ValList;
|
ValueList* ValList;
|
||||||
TypeList* TypeVec;
|
TypeList* TypeVec;
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
#define VOID 257
|
/* Line 1447 of yacc.c. */
|
||||||
#define BOOL 258
|
#line 347 "UpgradeParser.tab.h"
|
||||||
#define SBYTE 259
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
#define UBYTE 260
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
#define SHORT 261
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
#define USHORT 262
|
#endif
|
||||||
#define INT 263
|
|
||||||
#define UINT 264
|
|
||||||
#define LONG 265
|
|
||||||
#define ULONG 266
|
|
||||||
#define FLOAT 267
|
|
||||||
#define DOUBLE 268
|
|
||||||
#define LABEL 269
|
|
||||||
#define OPAQUE 270
|
|
||||||
#define ESINT64VAL 271
|
|
||||||
#define EUINT64VAL 272
|
|
||||||
#define SINTVAL 273
|
|
||||||
#define UINTVAL 274
|
|
||||||
#define FPVAL 275
|
|
||||||
#define NULL_TOK 276
|
|
||||||
#define UNDEF 277
|
|
||||||
#define ZEROINITIALIZER 278
|
|
||||||
#define TRUETOK 279
|
|
||||||
#define FALSETOK 280
|
|
||||||
#define TYPE 281
|
|
||||||
#define VAR_ID 282
|
|
||||||
#define LABELSTR 283
|
|
||||||
#define STRINGCONSTANT 284
|
|
||||||
#define IMPLEMENTATION 285
|
|
||||||
#define BEGINTOK 286
|
|
||||||
#define ENDTOK 287
|
|
||||||
#define DECLARE 288
|
|
||||||
#define GLOBAL 289
|
|
||||||
#define CONSTANT 290
|
|
||||||
#define SECTION 291
|
|
||||||
#define VOLATILE 292
|
|
||||||
#define TO 293
|
|
||||||
#define DOTDOTDOT 294
|
|
||||||
#define CONST 295
|
|
||||||
#define INTERNAL 296
|
|
||||||
#define LINKONCE 297
|
|
||||||
#define WEAK 298
|
|
||||||
#define DLLIMPORT 299
|
|
||||||
#define DLLEXPORT 300
|
|
||||||
#define EXTERN_WEAK 301
|
|
||||||
#define APPENDING 302
|
|
||||||
#define NOT 303
|
|
||||||
#define EXTERNAL 304
|
|
||||||
#define TARGET 305
|
|
||||||
#define TRIPLE 306
|
|
||||||
#define ENDIAN 307
|
|
||||||
#define POINTERSIZE 308
|
|
||||||
#define LITTLE 309
|
|
||||||
#define BIG 310
|
|
||||||
#define ALIGN 311
|
|
||||||
#define UNINITIALIZED 312
|
|
||||||
#define DEPLIBS 313
|
|
||||||
#define CALL 314
|
|
||||||
#define TAIL 315
|
|
||||||
#define ASM_TOK 316
|
|
||||||
#define MODULE 317
|
|
||||||
#define SIDEEFFECT 318
|
|
||||||
#define CC_TOK 319
|
|
||||||
#define CCC_TOK 320
|
|
||||||
#define CSRETCC_TOK 321
|
|
||||||
#define FASTCC_TOK 322
|
|
||||||
#define COLDCC_TOK 323
|
|
||||||
#define X86_STDCALLCC_TOK 324
|
|
||||||
#define X86_FASTCALLCC_TOK 325
|
|
||||||
#define DATALAYOUT 326
|
|
||||||
#define RET 327
|
|
||||||
#define BR 328
|
|
||||||
#define SWITCH 329
|
|
||||||
#define INVOKE 330
|
|
||||||
#define EXCEPT 331
|
|
||||||
#define UNWIND 332
|
|
||||||
#define UNREACHABLE 333
|
|
||||||
#define ADD 334
|
|
||||||
#define SUB 335
|
|
||||||
#define MUL 336
|
|
||||||
#define DIV 337
|
|
||||||
#define UDIV 338
|
|
||||||
#define SDIV 339
|
|
||||||
#define FDIV 340
|
|
||||||
#define REM 341
|
|
||||||
#define UREM 342
|
|
||||||
#define SREM 343
|
|
||||||
#define FREM 344
|
|
||||||
#define AND 345
|
|
||||||
#define OR 346
|
|
||||||
#define XOR 347
|
|
||||||
#define SETLE 348
|
|
||||||
#define SETGE 349
|
|
||||||
#define SETLT 350
|
|
||||||
#define SETGT 351
|
|
||||||
#define SETEQ 352
|
|
||||||
#define SETNE 353
|
|
||||||
#define ICMP 354
|
|
||||||
#define FCMP 355
|
|
||||||
#define EQ 356
|
|
||||||
#define NE 357
|
|
||||||
#define SLT 358
|
|
||||||
#define SGT 359
|
|
||||||
#define SLE 360
|
|
||||||
#define SGE 361
|
|
||||||
#define OEQ 362
|
|
||||||
#define ONE 363
|
|
||||||
#define OLT 364
|
|
||||||
#define OGT 365
|
|
||||||
#define OLE 366
|
|
||||||
#define OGE 367
|
|
||||||
#define ORD 368
|
|
||||||
#define UNO 369
|
|
||||||
#define UEQ 370
|
|
||||||
#define UNE 371
|
|
||||||
#define ULT 372
|
|
||||||
#define UGT 373
|
|
||||||
#define ULE 374
|
|
||||||
#define UGE 375
|
|
||||||
#define MALLOC 376
|
|
||||||
#define ALLOCA 377
|
|
||||||
#define FREE 378
|
|
||||||
#define LOAD 379
|
|
||||||
#define STORE 380
|
|
||||||
#define GETELEMENTPTR 381
|
|
||||||
#define PHI_TOK 382
|
|
||||||
#define SELECT 383
|
|
||||||
#define SHL 384
|
|
||||||
#define SHR 385
|
|
||||||
#define ASHR 386
|
|
||||||
#define LSHR 387
|
|
||||||
#define VAARG 388
|
|
||||||
#define EXTRACTELEMENT 389
|
|
||||||
#define INSERTELEMENT 390
|
|
||||||
#define SHUFFLEVECTOR 391
|
|
||||||
#define CAST 392
|
|
||||||
#define TRUNC 393
|
|
||||||
#define ZEXT 394
|
|
||||||
#define SEXT 395
|
|
||||||
#define FPTRUNC 396
|
|
||||||
#define FPEXT 397
|
|
||||||
#define FPTOUI 398
|
|
||||||
#define FPTOSI 399
|
|
||||||
#define UITOFP 400
|
|
||||||
#define SITOFP 401
|
|
||||||
#define PTRTOINT 402
|
|
||||||
#define INTTOPTR 403
|
|
||||||
#define BITCAST 404
|
|
||||||
|
|
||||||
|
|
||||||
extern YYSTYPE Upgradelval;
|
extern YYSTYPE Upgradelval;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "ParserInternals.h"
|
#include "UpgradeInternals.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -45,11 +45,15 @@ static bool AddAttributes = false;
|
|||||||
static bool deleteUselessCastFlag = false;
|
static bool deleteUselessCastFlag = false;
|
||||||
static std::string* deleteUselessCastName = 0;
|
static std::string* deleteUselessCastName = 0;
|
||||||
|
|
||||||
typedef std::vector<TypeInfo> TypeVector;
|
typedef std::vector<const TypeInfo*> TypeVector;
|
||||||
static TypeVector EnumeratedTypes;
|
static TypeVector EnumeratedTypes;
|
||||||
typedef std::map<std::string,TypeInfo> TypeMap;
|
typedef std::map<std::string,const TypeInfo*> TypeMap;
|
||||||
static TypeMap NamedTypes;
|
static TypeMap NamedTypes;
|
||||||
static TypeMap Globals;
|
typedef std::map<const TypeInfo*,std::string> TypePlaneMap;
|
||||||
|
typedef std::map<std::string,TypePlaneMap> GlobalsTypeMap;
|
||||||
|
static GlobalsTypeMap Globals;
|
||||||
|
|
||||||
|
static void warning(const std::string& msg);
|
||||||
|
|
||||||
void destroy(ValueList* VL) {
|
void destroy(ValueList* VL) {
|
||||||
while (!VL->empty()) {
|
while (!VL->empty()) {
|
||||||
@ -77,32 +81,261 @@ void UpgradeAssembly(const std::string &infile, std::istream& in,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfo* ResolveType(TypeInfo*& Ty) {
|
TypeInfo::TypeRegMap TypeInfo::registry;
|
||||||
if (Ty->isUnresolved()) {
|
|
||||||
if (Ty->getNewTy()[0] == '%' && isdigit(Ty->getNewTy()[1])) {
|
const TypeInfo* TypeInfo::get(const std::string &newType, Types oldType) {
|
||||||
unsigned ref = atoi(&((Ty->getNewTy().c_str())[1])); // skip the %
|
TypeInfo* Ty = new TypeInfo();
|
||||||
|
Ty->newTy = newType;
|
||||||
|
Ty->oldTy = oldType;
|
||||||
|
return add_new_type(Ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TypeInfo* TypeInfo::get(const std::string& newType, Types oldType,
|
||||||
|
const TypeInfo* eTy, const TypeInfo* rTy) {
|
||||||
|
TypeInfo* Ty= new TypeInfo();
|
||||||
|
Ty->newTy = newType;
|
||||||
|
Ty->oldTy = oldType;
|
||||||
|
Ty->elemTy = const_cast<TypeInfo*>(eTy);
|
||||||
|
Ty->resultTy = const_cast<TypeInfo*>(rTy);
|
||||||
|
return add_new_type(Ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TypeInfo* TypeInfo::get(const std::string& newType, Types oldType,
|
||||||
|
const TypeInfo *eTy, uint64_t elems) {
|
||||||
|
TypeInfo* Ty = new TypeInfo();
|
||||||
|
Ty->newTy = newType;
|
||||||
|
Ty->oldTy = oldType;
|
||||||
|
Ty->elemTy = const_cast<TypeInfo*>(eTy);
|
||||||
|
Ty->nelems = elems;
|
||||||
|
return add_new_type(Ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TypeInfo* TypeInfo::get(const std::string& newType, Types oldType,
|
||||||
|
TypeList* TL) {
|
||||||
|
TypeInfo* Ty = new TypeInfo();
|
||||||
|
Ty->newTy = newType;
|
||||||
|
Ty->oldTy = oldType;
|
||||||
|
Ty->elements = TL;
|
||||||
|
return add_new_type(Ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TypeInfo* TypeInfo::get(const std::string& newType, const TypeInfo* resTy,
|
||||||
|
TypeList* TL) {
|
||||||
|
TypeInfo* Ty = new TypeInfo();
|
||||||
|
Ty->newTy = newType;
|
||||||
|
Ty->oldTy = FunctionTy;
|
||||||
|
Ty->resultTy = const_cast<TypeInfo*>(resTy);
|
||||||
|
Ty->elements = TL;
|
||||||
|
return add_new_type(Ty);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TypeInfo* TypeInfo::resolve() const {
|
||||||
|
if (isUnresolved()) {
|
||||||
|
if (getNewTy()[0] == '%' && isdigit(getNewTy()[1])) {
|
||||||
|
unsigned ref = atoi(&((getNewTy().c_str())[1])); // skip the %
|
||||||
if (ref < EnumeratedTypes.size()) {
|
if (ref < EnumeratedTypes.size()) {
|
||||||
Ty = &EnumeratedTypes[ref];
|
return EnumeratedTypes[ref];
|
||||||
return Ty;
|
|
||||||
} else {
|
} else {
|
||||||
std::string msg("Can't resolve numbered type: ");
|
std::string msg("Can't resolve numbered type: ");
|
||||||
msg += Ty->getNewTy();
|
msg += getNewTy();
|
||||||
yyerror(msg.c_str());
|
yyerror(msg.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TypeMap::iterator I = NamedTypes.find(Ty->getNewTy());
|
TypeMap::iterator I = NamedTypes.find(getNewTy());
|
||||||
if (I != NamedTypes.end()) {
|
if (I != NamedTypes.end()) {
|
||||||
Ty = &I->second;
|
return I->second;
|
||||||
return Ty;
|
|
||||||
} else {
|
} else {
|
||||||
std::string msg("Cannot resolve type: ");
|
std::string msg("Cannot resolve type: ");
|
||||||
msg += Ty->getNewTy();
|
msg += getNewTy();
|
||||||
yyerror(msg.c_str());
|
yyerror(msg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// otherwise its already resolved.
|
// otherwise its already resolved.
|
||||||
return Ty;
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TypeInfo::operator<(const TypeInfo& that) const {
|
||||||
|
if (this == &that)
|
||||||
|
return false;
|
||||||
|
if (oldTy != that.oldTy)
|
||||||
|
return oldTy < that.oldTy;
|
||||||
|
switch (oldTy) {
|
||||||
|
case UpRefTy: {
|
||||||
|
unsigned thisUp = this->getUpRefNum();
|
||||||
|
unsigned thatUp = that.getUpRefNum();
|
||||||
|
return thisUp < thatUp;
|
||||||
|
}
|
||||||
|
case PackedTy:
|
||||||
|
case ArrayTy:
|
||||||
|
if (this->nelems != that.nelems)
|
||||||
|
return nelems < that.nelems;
|
||||||
|
case PointerTy: {
|
||||||
|
const TypeInfo* thisTy = this->elemTy;
|
||||||
|
const TypeInfo* thatTy = that.elemTy;
|
||||||
|
return *thisTy < *thatTy;
|
||||||
|
}
|
||||||
|
case FunctionTy: {
|
||||||
|
const TypeInfo* thisTy = this->resultTy;
|
||||||
|
const TypeInfo* thatTy = that.resultTy;
|
||||||
|
if (!thisTy->sameOldTyAs(thatTy))
|
||||||
|
return *thisTy < *thatTy;
|
||||||
|
/* FALL THROUGH */
|
||||||
|
}
|
||||||
|
case StructTy:
|
||||||
|
case PackedStructTy: {
|
||||||
|
if (elements->size() != that.elements->size())
|
||||||
|
return elements->size() < that.elements->size();
|
||||||
|
for (unsigned i = 0; i < elements->size(); i++) {
|
||||||
|
const TypeInfo* thisTy = (*this->elements)[i];
|
||||||
|
const TypeInfo* thatTy = (*that.elements)[i];
|
||||||
|
if (!thisTy->sameOldTyAs(thatTy))
|
||||||
|
return *thisTy < *thatTy;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case UnresolvedTy:
|
||||||
|
return this->newTy < that.newTy;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TypeInfo::sameOldTyAs(const TypeInfo* that) const {
|
||||||
|
if (that == 0)
|
||||||
|
return false;
|
||||||
|
if ( this == that )
|
||||||
|
return true;
|
||||||
|
if (oldTy != that->oldTy)
|
||||||
|
return false;
|
||||||
|
switch (oldTy) {
|
||||||
|
case PackedTy:
|
||||||
|
case ArrayTy:
|
||||||
|
if (nelems != that->nelems)
|
||||||
|
return false;
|
||||||
|
/* FALL THROUGH */
|
||||||
|
case PointerTy: {
|
||||||
|
const TypeInfo* thisTy = this->elemTy;
|
||||||
|
const TypeInfo* thatTy = that->elemTy;
|
||||||
|
return thisTy->sameOldTyAs(thatTy);
|
||||||
|
}
|
||||||
|
case FunctionTy: {
|
||||||
|
const TypeInfo* thisTy = this->resultTy;
|
||||||
|
const TypeInfo* thatTy = that->resultTy;
|
||||||
|
if (!thisTy->sameOldTyAs(thatTy))
|
||||||
|
return false;
|
||||||
|
/* FALL THROUGH */
|
||||||
|
}
|
||||||
|
case StructTy:
|
||||||
|
case PackedStructTy: {
|
||||||
|
if (elements->size() != that->elements->size())
|
||||||
|
return false;
|
||||||
|
for (unsigned i = 0; i < elements->size(); i++) {
|
||||||
|
const TypeInfo* thisTy = (*this->elements)[i];
|
||||||
|
const TypeInfo* thatTy = (*that->elements)[i];
|
||||||
|
if (!thisTy->sameOldTyAs(thatTy))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case UnresolvedTy:
|
||||||
|
return this->newTy == that->newTy;
|
||||||
|
default:
|
||||||
|
return true; // for all others oldTy == that->oldTy is sufficient
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TypeInfo::isUnresolvedDeep() const {
|
||||||
|
switch (oldTy) {
|
||||||
|
case UnresolvedTy:
|
||||||
|
return true;
|
||||||
|
case PackedTy:
|
||||||
|
case ArrayTy:
|
||||||
|
case PointerTy:
|
||||||
|
return elemTy->isUnresolvedDeep();
|
||||||
|
case PackedStructTy:
|
||||||
|
case StructTy:
|
||||||
|
for (unsigned i = 0; i < elements->size(); i++)
|
||||||
|
if ((*elements)[i]->isUnresolvedDeep())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned TypeInfo::getBitWidth() const {
|
||||||
|
switch (oldTy) {
|
||||||
|
default:
|
||||||
|
case LabelTy:
|
||||||
|
case VoidTy : return 0;
|
||||||
|
case BoolTy : return 1;
|
||||||
|
case SByteTy: case UByteTy : return 8;
|
||||||
|
case ShortTy: case UShortTy : return 16;
|
||||||
|
case IntTy: case UIntTy: case FloatTy: return 32;
|
||||||
|
case LongTy: case ULongTy: case DoubleTy : return 64;
|
||||||
|
case PointerTy: return SizeOfPointer; // global var
|
||||||
|
case PackedTy:
|
||||||
|
case ArrayTy:
|
||||||
|
return nelems * elemTy->getBitWidth();
|
||||||
|
case StructTy:
|
||||||
|
case PackedStructTy: {
|
||||||
|
uint64_t size = 0;
|
||||||
|
for (unsigned i = 0; i < elements->size(); i++) {
|
||||||
|
size += (*elements)[i]->getBitWidth();
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const TypeInfo* TypeInfo::getIndexedType(const ValueInfo& VI) const {
|
||||||
|
if (isStruct()) {
|
||||||
|
if (VI.isConstant() && VI.type->isInteger()) {
|
||||||
|
size_t pos = VI.val->find(' ') + 1;
|
||||||
|
if (pos < VI.val->size()) {
|
||||||
|
uint64_t idx = atoi(VI.val->substr(pos).c_str());
|
||||||
|
return (*elements)[idx];
|
||||||
|
} else {
|
||||||
|
yyerror("Invalid value for constant integer");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
yyerror("Structure requires constant index");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isArray() || isPacked() || isPointer())
|
||||||
|
return elemTy;
|
||||||
|
yyerror("Invalid type for getIndexedType");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeInfo& TypeInfo::operator=(const TypeInfo& that) {
|
||||||
|
oldTy = that.oldTy;
|
||||||
|
nelems = that.nelems;
|
||||||
|
newTy = that.newTy;
|
||||||
|
elemTy = that.elemTy;
|
||||||
|
resultTy = that.resultTy;
|
||||||
|
if (that.elements) {
|
||||||
|
elements = new TypeList(that.elements->size());
|
||||||
|
*elements = *that.elements;
|
||||||
|
} else {
|
||||||
|
elements = 0;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TypeInfo* TypeInfo::add_new_type(TypeInfo* newTy) {
|
||||||
|
TypeRegMap::iterator I = registry.find(newTy);
|
||||||
|
if (I != registry.end()) {
|
||||||
|
delete newTy;
|
||||||
|
return *I;
|
||||||
|
}
|
||||||
|
registry.insert(newTy);
|
||||||
|
return newTy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* getCastOpcode(
|
static const char* getCastOpcode(
|
||||||
@ -183,8 +416,8 @@ static const char* getCastOpcode(
|
|||||||
return opcode;
|
return opcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string getCastUpgrade(const std::string& Src, TypeInfo* SrcTy,
|
static std::string getCastUpgrade(const std::string& Src, const TypeInfo* SrcTy,
|
||||||
TypeInfo* DstTy, bool isConst)
|
const TypeInfo* DstTy, bool isConst)
|
||||||
{
|
{
|
||||||
std::string Result;
|
std::string Result;
|
||||||
std::string Source = Src;
|
std::string Source = Src;
|
||||||
@ -199,8 +432,7 @@ static std::string getCastUpgrade(const std::string& Src, TypeInfo* SrcTy,
|
|||||||
Source = "i64 %cast_upgrade" + llvm::utostr(unique);
|
Source = "i64 %cast_upgrade" + llvm::utostr(unique);
|
||||||
}
|
}
|
||||||
// Update the SrcTy for the getCastOpcode call below
|
// Update the SrcTy for the getCastOpcode call below
|
||||||
delete SrcTy;
|
SrcTy = TypeInfo::get("i64", ULongTy);
|
||||||
SrcTy = new TypeInfo("i64", ULongTy);
|
|
||||||
} else if (DstTy->isBool()) {
|
} else if (DstTy->isBool()) {
|
||||||
// cast type %x to bool was previously defined as setne type %x, null
|
// cast type %x to bool was previously defined as setne type %x, null
|
||||||
// The cast semantic is now to truncate, not compare so we must retain
|
// The cast semantic is now to truncate, not compare so we must retain
|
||||||
@ -216,8 +448,8 @@ static std::string getCastUpgrade(const std::string& Src, TypeInfo* SrcTy,
|
|||||||
Result = compareOp + Source + comparator;
|
Result = compareOp + Source + comparator;
|
||||||
return Result; // skip cast processing below
|
return Result; // skip cast processing below
|
||||||
}
|
}
|
||||||
ResolveType(SrcTy);
|
SrcTy = SrcTy->resolve();
|
||||||
ResolveType(DstTy);
|
DstTy = DstTy->resolve();
|
||||||
std::string Opcode(getCastOpcode(Source, SrcTy, DstTy));
|
std::string Opcode(getCastOpcode(Source, SrcTy, DstTy));
|
||||||
if (isConst)
|
if (isConst)
|
||||||
Result += Opcode + "( " + Source + " to " + DstTy->getNewTy() + ")";
|
Result += Opcode + "( " + Source + " to " + DstTy->getNewTy() + ")";
|
||||||
@ -226,9 +458,9 @@ static std::string getCastUpgrade(const std::string& Src, TypeInfo* SrcTy,
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* getDivRemOpcode(const std::string& opcode, TypeInfo* TI) {
|
const char* getDivRemOpcode(const std::string& opcode, const TypeInfo* TI) {
|
||||||
const char* op = opcode.c_str();
|
const char* op = opcode.c_str();
|
||||||
const TypeInfo* Ty = ResolveType(TI);
|
const TypeInfo* Ty = TI->resolve();
|
||||||
if (Ty->isPacked())
|
if (Ty->isPacked())
|
||||||
Ty = Ty->getElementType();
|
Ty = Ty->getElementType();
|
||||||
if (opcode == "div")
|
if (opcode == "div")
|
||||||
@ -283,35 +515,36 @@ getCompareOp(const std::string& setcc, const TypeInfo* TI) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TypeInfo* getFunctionReturnType(TypeInfo* PFTy) {
|
static const TypeInfo* getFunctionReturnType(const TypeInfo* PFTy) {
|
||||||
ResolveType(PFTy);
|
PFTy = PFTy->resolve();
|
||||||
if (PFTy->isPointer()) {
|
if (PFTy->isPointer()) {
|
||||||
TypeInfo* ElemTy = PFTy->getElementType();
|
const TypeInfo* ElemTy = PFTy->getElementType();
|
||||||
ResolveType(ElemTy);
|
ElemTy = ElemTy->resolve();
|
||||||
if (ElemTy->isFunction())
|
if (ElemTy->isFunction())
|
||||||
return ElemTy->getResultType()->clone();
|
return ElemTy->getResultType();
|
||||||
} else if (PFTy->isFunction()) {
|
} else if (PFTy->isFunction()) {
|
||||||
return PFTy->getResultType()->clone();
|
return PFTy->getResultType();
|
||||||
}
|
}
|
||||||
return PFTy->clone();
|
return PFTy;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::vector<TypeInfo*> UpRefStack;
|
typedef std::vector<const TypeInfo*> UpRefStack;
|
||||||
static TypeInfo* ResolveUpReference(TypeInfo* Ty, UpRefStack* stack) {
|
static const TypeInfo* ResolveUpReference(const TypeInfo* Ty,
|
||||||
|
UpRefStack* stack) {
|
||||||
assert(Ty->isUpReference() && "Can't resolve a non-upreference");
|
assert(Ty->isUpReference() && "Can't resolve a non-upreference");
|
||||||
unsigned upref = atoi(&((Ty->getNewTy().c_str())[1])); // skip the slash
|
unsigned upref = Ty->getUpRefNum();
|
||||||
assert(upref < stack->size() && "Invalid up reference");
|
assert(upref < stack->size() && "Invalid up reference");
|
||||||
return (*stack)[upref - stack->size() - 1];
|
return (*stack)[upref - stack->size() - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
static TypeInfo* getGEPIndexedType(TypeInfo* PTy, ValueList* idxs) {
|
static const TypeInfo* getGEPIndexedType(const TypeInfo* PTy, ValueList* idxs) {
|
||||||
TypeInfo* Result = ResolveType(PTy);
|
const TypeInfo* Result = PTy = PTy->resolve();
|
||||||
assert(PTy->isPointer() && "GEP Operand is not a pointer?");
|
assert(PTy->isPointer() && "GEP Operand is not a pointer?");
|
||||||
UpRefStack stack;
|
UpRefStack stack;
|
||||||
for (unsigned i = 0; i < idxs->size(); ++i) {
|
for (unsigned i = 0; i < idxs->size(); ++i) {
|
||||||
if (Result->isComposite()) {
|
if (Result->isComposite()) {
|
||||||
Result = Result->getIndexedType((*idxs)[i]);
|
Result = Result->getIndexedType((*idxs)[i]);
|
||||||
ResolveType(Result);
|
Result = Result->resolve();
|
||||||
stack.push_back(Result);
|
stack.push_back(Result);
|
||||||
} else
|
} else
|
||||||
yyerror("Invalid type for index");
|
yyerror("Invalid type for index");
|
||||||
@ -344,25 +577,47 @@ static std::string makeUniqueName(const std::string *Name, bool isSigned) {
|
|||||||
// were previously unsigned or signed, respectively. This avoids name
|
// were previously unsigned or signed, respectively. This avoids name
|
||||||
// collisions since the unsigned and signed type planes have collapsed
|
// collisions since the unsigned and signed type planes have collapsed
|
||||||
// into a single signless type plane.
|
// into a single signless type plane.
|
||||||
static std::string getUniqueName(const std::string *Name, TypeInfo* Ty) {
|
static std::string getUniqueName(const std::string *Name, const TypeInfo* Ty,
|
||||||
|
bool isGlobal = false) {
|
||||||
|
|
||||||
// If its not a symbolic name, don't modify it, probably a constant val.
|
// If its not a symbolic name, don't modify it, probably a constant val.
|
||||||
if ((*Name)[0] != '%' && (*Name)[0] != '"')
|
if ((*Name)[0] != '%' && (*Name)[0] != '"')
|
||||||
return *Name;
|
return *Name;
|
||||||
|
|
||||||
// If its a numeric reference, just leave it alone.
|
// If its a numeric reference, just leave it alone.
|
||||||
if (isdigit((*Name)[1]))
|
if (isdigit((*Name)[1]))
|
||||||
return *Name;
|
return *Name;
|
||||||
|
|
||||||
// Resolve the type
|
// Resolve the type
|
||||||
ResolveType(Ty);
|
Ty = Ty->resolve();
|
||||||
|
|
||||||
|
// If its a global name, get its uniquified name, if any
|
||||||
|
GlobalsTypeMap::iterator GI = Globals.find(*Name);
|
||||||
|
if (GI != Globals.end()) {
|
||||||
|
TypePlaneMap::iterator TPI = GI->second.begin();
|
||||||
|
TypePlaneMap::iterator TPE = GI->second.end();
|
||||||
|
for ( ; TPI != TPE ; ++TPI) {
|
||||||
|
if (TPI->first->sameNewTyAs(Ty))
|
||||||
|
return TPI->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isGlobal) {
|
||||||
|
// We didn't find a global name, but if its supposed to be global then all
|
||||||
|
// we can do is return the name. This is probably a forward reference of a
|
||||||
|
// global value that hasn't been defined yet. Since we have no definition
|
||||||
|
// we don't know its linkage class. Just assume its an external and the name
|
||||||
|
// shouldn't change.
|
||||||
|
return *Name;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove as many levels of pointer nesting that we have.
|
// Remove as many levels of pointer nesting that we have.
|
||||||
if (Ty->isPointer()) {
|
if (Ty->isPointer()) {
|
||||||
// Avoid infinite loops in recursive types
|
// Avoid infinite loops in recursive types
|
||||||
TypeInfo* Last = 0;
|
const TypeInfo* Last = 0;
|
||||||
while (Ty->isPointer() && Last != Ty) {
|
while (Ty->isPointer() && !Ty->sameOldTyAs(Last)) {
|
||||||
Last = Ty;
|
Last = Ty;
|
||||||
Ty = Ty->getElementType();
|
Ty = Ty->getElementType()->resolve();
|
||||||
ResolveType(Ty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +636,7 @@ static std::string getUniqueName(const std::string *Name, TypeInfo* Ty) {
|
|||||||
// Scan the fields and count the signed and unsigned fields
|
// Scan the fields and count the signed and unsigned fields
|
||||||
int isSigned = 0;
|
int isSigned = 0;
|
||||||
for (unsigned i = 0; i < Ty->getNumStructElements(); ++i) {
|
for (unsigned i = 0; i < Ty->getNumStructElements(); ++i) {
|
||||||
TypeInfo* Tmp = Ty->getElement(i);
|
const TypeInfo* Tmp = Ty->getElement(i);
|
||||||
if (Tmp->isInteger())
|
if (Tmp->isInteger())
|
||||||
if (Tmp->isSigned())
|
if (Tmp->isSigned())
|
||||||
isSigned++;
|
isSigned++;
|
||||||
@ -394,13 +649,99 @@ static std::string getUniqueName(const std::string *Name, TypeInfo* Ty) {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned UniqueNameCounter = 0;
|
||||||
|
|
||||||
|
std::string getGlobalName(const std::string* Name, const std::string Linkage,
|
||||||
|
const TypeInfo* Ty, bool isConstant) {
|
||||||
|
// Default to given name
|
||||||
|
std::string Result = *Name;
|
||||||
|
// Look up the name in the Globals Map
|
||||||
|
GlobalsTypeMap::iterator GI = Globals.find(*Name);
|
||||||
|
// Did we see this global name before?
|
||||||
|
if (GI != Globals.end()) {
|
||||||
|
if (Ty->isUnresolvedDeep()) {
|
||||||
|
// The Gval's type is unresolved. Consequently, we can't disambiguate it
|
||||||
|
// by type. We'll just change its name and emit a warning.
|
||||||
|
warning("Cannot disambiguate global value '" + *Name +
|
||||||
|
"' because type '" + Ty->getNewTy() + "'is unresolved.\n");
|
||||||
|
Result = *Name + ".unique";
|
||||||
|
UniqueNameCounter++;
|
||||||
|
Result += llvm::utostr(UniqueNameCounter);
|
||||||
|
return Result;
|
||||||
|
} else {
|
||||||
|
TypePlaneMap::iterator TPI = GI->second.find(Ty);
|
||||||
|
if (TPI != GI->second.end()) {
|
||||||
|
// We found an existing name of the same old type. This isn't allowed
|
||||||
|
// in LLVM 2.0. Consequently, we must alter the name of the global so it
|
||||||
|
// can at least compile. References to the global will yield the first
|
||||||
|
// definition, which is okay. We also must warn about this.
|
||||||
|
Result = *Name + ".unique";
|
||||||
|
UniqueNameCounter++;
|
||||||
|
Result += llvm::utostr(UniqueNameCounter);
|
||||||
|
warning(std::string("Global variable '") + *Name + "' was renamed to '"+
|
||||||
|
Result + "'");
|
||||||
|
} else {
|
||||||
|
// There isn't an existing definition for this name according to the
|
||||||
|
// old types. Now search the TypePlanMap for types with the same new
|
||||||
|
// name.
|
||||||
|
TypePlaneMap::iterator TPI = GI->second.begin();
|
||||||
|
TypePlaneMap::iterator TPE = GI->second.end();
|
||||||
|
for ( ; TPI != TPE; ++TPI) {
|
||||||
|
if (TPI->first->sameNewTyAs(Ty)) {
|
||||||
|
// The new types are the same but the old types are different so
|
||||||
|
// this is a global name collision resulting from type planes
|
||||||
|
// collapsing.
|
||||||
|
if (Linkage == "external" || Linkage == "dllimport" ||
|
||||||
|
Linkage == "extern_weak" || Linkage == "") {
|
||||||
|
// The linkage of this gval is external so we can't reliably
|
||||||
|
// rename it because it could potentially create a linking
|
||||||
|
// problem. However, we can't leave the name conflict in the
|
||||||
|
// output either or it won't assemble with LLVM 2.0. So, all we
|
||||||
|
// can do is rename this one to something unique and emit a
|
||||||
|
// warning about the problem.
|
||||||
|
Result = *Name + ".unique";
|
||||||
|
UniqueNameCounter++;
|
||||||
|
Result += llvm::utostr(UniqueNameCounter);
|
||||||
|
warning("Renaming global value '" + *Name + "' to '" + Result +
|
||||||
|
"' may cause linkage errors.");
|
||||||
|
return Result;
|
||||||
|
} else {
|
||||||
|
// Its linkage is internal and its type is known so we can
|
||||||
|
// disambiguate the name collision successfully based on the type.
|
||||||
|
Result = getUniqueName(Name, Ty);
|
||||||
|
TPI->second = Result;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// We didn't find an entry in the type plane with the same new type and
|
||||||
|
// the old types differ so this is a new type plane for this global
|
||||||
|
// variable. We just fall through to the logic below which inserts
|
||||||
|
// the global.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Its a new global name, if it is external we can't change it
|
||||||
|
if (isConstant || Linkage == "external" || Linkage == "dllimport" ||
|
||||||
|
Linkage == "extern_weak" || Linkage == "") {
|
||||||
|
Globals[Result][Ty] = Result;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Its a new global name, and it is internal, change the name to make it
|
||||||
|
// unique for its type.
|
||||||
|
// Result = getUniqueName(Name, Ty);
|
||||||
|
Globals[*Name][Ty] = Result;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
// %file-prefix="UpgradeParser"
|
// %file-prefix="UpgradeParser"
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
std::string* String;
|
std::string* String;
|
||||||
TypeInfo* Type;
|
const TypeInfo* Type;
|
||||||
ValueInfo Value;
|
ValueInfo Value;
|
||||||
ConstInfo Const;
|
ConstInfo Const;
|
||||||
ValueList* ValList;
|
ValueList* ValList;
|
||||||
@ -570,17 +911,17 @@ PrimType : BOOL | SBYTE | UBYTE | SHORT | USHORT | INT | UINT ;
|
|||||||
PrimType : LONG | ULONG | FLOAT | DOUBLE | LABEL;
|
PrimType : LONG | ULONG | FLOAT | DOUBLE | LABEL;
|
||||||
UpRTypes
|
UpRTypes
|
||||||
: OPAQUE {
|
: OPAQUE {
|
||||||
$$ = new TypeInfo($1, OpaqueTy);
|
$$ = TypeInfo::get(*$1, OpaqueTy);
|
||||||
}
|
}
|
||||||
| SymbolicValueRef {
|
| SymbolicValueRef {
|
||||||
$$ = new TypeInfo($1, UnresolvedTy);
|
$$ = TypeInfo::get(*$1, UnresolvedTy);
|
||||||
}
|
}
|
||||||
| PrimType {
|
| PrimType {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| '\\' EUINT64VAL { // Type UpReference
|
| '\\' EUINT64VAL { // Type UpReference
|
||||||
$2->insert(0, "\\");
|
$2->insert(0, "\\");
|
||||||
$$ = new TypeInfo($2, UpRefTy);
|
$$ = TypeInfo::get(*$2, UpRefTy);
|
||||||
}
|
}
|
||||||
| UpRTypesV '(' ArgTypeListI ')' { // Function derived type?
|
| UpRTypesV '(' ArgTypeListI ')' { // Function derived type?
|
||||||
std::string newTy( $1->getNewTy() + "(");
|
std::string newTy( $1->getNewTy() + "(");
|
||||||
@ -593,19 +934,19 @@ UpRTypes
|
|||||||
newTy += (*$3)[i]->getNewTy();
|
newTy += (*$3)[i]->getNewTy();
|
||||||
}
|
}
|
||||||
newTy += ")";
|
newTy += ")";
|
||||||
$$ = new TypeInfo(new std::string(newTy), $1, $3);
|
$$ = TypeInfo::get(newTy, $1, $3);
|
||||||
}
|
}
|
||||||
| '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type?
|
| '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type?
|
||||||
|
uint64_t elems = atoi($2->c_str());
|
||||||
$2->insert(0,"[ ");
|
$2->insert(0,"[ ");
|
||||||
*$2 += " x " + $4->getNewTy() + " ]";
|
*$2 += " x " + $4->getNewTy() + " ]";
|
||||||
uint64_t elems = atoi($2->c_str());
|
$$ = TypeInfo::get(*$2, ArrayTy, $4, elems);
|
||||||
$$ = new TypeInfo($2, ArrayTy, $4, elems);
|
|
||||||
}
|
}
|
||||||
| '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type?
|
| '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type?
|
||||||
|
uint64_t elems = atoi($2->c_str());
|
||||||
$2->insert(0,"< ");
|
$2->insert(0,"< ");
|
||||||
*$2 += " x " + $4->getNewTy() + " >";
|
*$2 += " x " + $4->getNewTy() + " >";
|
||||||
uint64_t elems = atoi($2->c_str());
|
$$ = TypeInfo::get(*$2, PackedTy, $4, elems);
|
||||||
$$ = new TypeInfo($2, PackedTy, $4, elems);
|
|
||||||
}
|
}
|
||||||
| '{' TypeListI '}' { // Structure type?
|
| '{' TypeListI '}' { // Structure type?
|
||||||
std::string newTy("{");
|
std::string newTy("{");
|
||||||
@ -615,10 +956,10 @@ UpRTypes
|
|||||||
newTy += (*$2)[i]->getNewTy();
|
newTy += (*$2)[i]->getNewTy();
|
||||||
}
|
}
|
||||||
newTy += "}";
|
newTy += "}";
|
||||||
$$ = new TypeInfo(new std::string(newTy), StructTy, $2);
|
$$ = TypeInfo::get(newTy, StructTy, $2);
|
||||||
}
|
}
|
||||||
| '{' '}' { // Empty structure type?
|
| '{' '}' { // Empty structure type?
|
||||||
$$ = new TypeInfo(new std::string("{}"), StructTy, new TypeList());
|
$$ = TypeInfo::get("{}", StructTy, new TypeList());
|
||||||
}
|
}
|
||||||
| '<' '{' TypeListI '}' '>' { // Packed Structure type?
|
| '<' '{' TypeListI '}' '>' { // Packed Structure type?
|
||||||
std::string newTy("<{");
|
std::string newTy("<{");
|
||||||
@ -628,10 +969,10 @@ UpRTypes
|
|||||||
newTy += (*$3)[i]->getNewTy();
|
newTy += (*$3)[i]->getNewTy();
|
||||||
}
|
}
|
||||||
newTy += "}>";
|
newTy += "}>";
|
||||||
$$ = new TypeInfo(new std::string(newTy), PackedStructTy, $3);
|
$$ = TypeInfo::get(newTy, PackedStructTy, $3);
|
||||||
}
|
}
|
||||||
| '<' '{' '}' '>' { // Empty packed structure type?
|
| '<' '{' '}' '>' { // Empty packed structure type?
|
||||||
$$ = new TypeInfo(new std::string("<{}>"), PackedStructTy, new TypeList());
|
$$ = TypeInfo::get("<{}>", PackedStructTy, new TypeList());
|
||||||
}
|
}
|
||||||
| UpRTypes '*' { // Pointer type?
|
| UpRTypes '*' { // Pointer type?
|
||||||
$$ = $1->getPointerType();
|
$$ = $1->getPointerType();
|
||||||
@ -655,12 +996,12 @@ ArgTypeListI
|
|||||||
: TypeListI
|
: TypeListI
|
||||||
| TypeListI ',' DOTDOTDOT {
|
| TypeListI ',' DOTDOTDOT {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
$$->push_back(new TypeInfo("void",VoidTy));
|
$$->push_back(TypeInfo::get("void",VoidTy));
|
||||||
delete $3;
|
delete $3;
|
||||||
}
|
}
|
||||||
| DOTDOTDOT {
|
| DOTDOTDOT {
|
||||||
$$ = new TypeList();
|
$$ = new TypeList();
|
||||||
$$->push_back(new TypeInfo("void",VoidTy));
|
$$->push_back(TypeInfo::get("void",VoidTy));
|
||||||
delete $1;
|
delete $1;
|
||||||
}
|
}
|
||||||
| /*empty*/ {
|
| /*empty*/ {
|
||||||
@ -720,7 +1061,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
|
|||||||
delete $2;
|
delete $2;
|
||||||
}
|
}
|
||||||
| Types SymbolicValueRef {
|
| Types SymbolicValueRef {
|
||||||
std::string Name = getUniqueName($2,$1);
|
std::string Name = getUniqueName($2, $1->resolve(), true);
|
||||||
$$.type = $1;
|
$$.type = $1;
|
||||||
$$.cnst = new std::string($1->getNewTy());
|
$$.cnst = new std::string($1->getNewTy());
|
||||||
*$$.cnst += " " + Name;
|
*$$.cnst += " " + Name;
|
||||||
@ -772,10 +1113,11 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
|
|||||||
|
|
||||||
ConstExpr: CastOps '(' ConstVal TO Types ')' {
|
ConstExpr: CastOps '(' ConstVal TO Types ')' {
|
||||||
std::string source = *$3.cnst;
|
std::string source = *$3.cnst;
|
||||||
TypeInfo* DstTy = ResolveType($5);
|
const TypeInfo* SrcTy = $3.type->resolve();
|
||||||
|
const TypeInfo* DstTy = $5->resolve();
|
||||||
if (*$1 == "cast") {
|
if (*$1 == "cast") {
|
||||||
// Call getCastUpgrade to upgrade the old cast
|
// Call getCastUpgrade to upgrade the old cast
|
||||||
$$ = new std::string(getCastUpgrade(source, $3.type, DstTy, true));
|
$$ = new std::string(getCastUpgrade(source, SrcTy, DstTy, true));
|
||||||
} else {
|
} else {
|
||||||
// Nothing to upgrade, just create the cast constant expr
|
// Nothing to upgrade, just create the cast constant expr
|
||||||
$$ = new std::string(*$1);
|
$$ = new std::string(*$1);
|
||||||
@ -902,9 +1244,9 @@ External : EXTERNAL | UNINITIALIZED { $$ = $1; *$$ = "external"; }
|
|||||||
|
|
||||||
// ConstPool - Constants with optional names assigned to them.
|
// ConstPool - Constants with optional names assigned to them.
|
||||||
ConstPool : ConstPool OptAssign TYPE TypesV {
|
ConstPool : ConstPool OptAssign TYPE TypesV {
|
||||||
EnumeratedTypes.push_back(*$4);
|
EnumeratedTypes.push_back($4);
|
||||||
if (!$2->empty()) {
|
if (!$2->empty()) {
|
||||||
NamedTypes[*$2] = *$4;
|
NamedTypes[*$2] = $4;
|
||||||
*O << *$2 << " = ";
|
*O << *$2 << " = ";
|
||||||
}
|
}
|
||||||
*O << "type " << $4->getNewTy() << '\n';
|
*O << "type " << $4->getNewTy() << '\n';
|
||||||
@ -923,9 +1265,9 @@ ConstPool : ConstPool OptAssign TYPE TypesV {
|
|||||||
}
|
}
|
||||||
| ConstPool OptAssign OptLinkage GlobalType ConstVal GlobalVarAttributes {
|
| ConstPool OptAssign OptLinkage GlobalType ConstVal GlobalVarAttributes {
|
||||||
if (!$2->empty()) {
|
if (!$2->empty()) {
|
||||||
std::string Name = getUniqueName($2,$5.type);
|
std::string Name = getGlobalName($2,*$3, $5.type->getPointerType(),
|
||||||
|
*$4 == "constant");
|
||||||
*O << Name << " = ";
|
*O << Name << " = ";
|
||||||
Globals[Name] = *$5.type;
|
|
||||||
}
|
}
|
||||||
*O << *$3 << ' ' << *$4 << ' ' << *$5.cnst << ' ' << *$6 << '\n';
|
*O << *$3 << ' ' << *$4 << ' ' << *$5.cnst << ' ' << *$6 << '\n';
|
||||||
delete $2; delete $3; delete $4; delete $6;
|
delete $2; delete $3; delete $4; delete $6;
|
||||||
@ -933,19 +1275,19 @@ ConstPool : ConstPool OptAssign TYPE TypesV {
|
|||||||
}
|
}
|
||||||
| ConstPool OptAssign External GlobalType Types GlobalVarAttributes {
|
| ConstPool OptAssign External GlobalType Types GlobalVarAttributes {
|
||||||
if (!$2->empty()) {
|
if (!$2->empty()) {
|
||||||
std::string Name = getUniqueName($2,$5);
|
std::string Name = getGlobalName($2,*$3,$5->getPointerType(),
|
||||||
|
*$4 == "constant");
|
||||||
*O << Name << " = ";
|
*O << Name << " = ";
|
||||||
Globals[Name] = *$5;
|
|
||||||
}
|
}
|
||||||
*O << *$3 << ' ' << *$4 << ' ' << $5->getNewTy() << ' ' << *$6 << '\n';
|
*O << *$3 << ' ' << *$4 << ' ' << $5->getNewTy() << ' ' << *$6 << '\n';
|
||||||
delete $2; delete $3; delete $4; delete $6;
|
delete $2; delete $3; delete $4; delete $6;
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
| ConstPool OptAssign DLLIMPORT GlobalType Types GlobalVarAttributes {
|
| ConstPool OptAssign DLLIMPORT GlobalType Types GlobalVarAttributes {
|
||||||
if (!$2->empty()) {
|
if (!$2->empty()) {
|
||||||
std::string Name = getUniqueName($2,$5);
|
std::string Name = getGlobalName($2,*$3,$5->getPointerType(),
|
||||||
|
*$4 == "constant");
|
||||||
*O << Name << " = ";
|
*O << Name << " = ";
|
||||||
Globals[Name] = *$5;
|
|
||||||
}
|
}
|
||||||
*O << *$3 << ' ' << *$4 << ' ' << $5->getNewTy() << ' ' << *$6 << '\n';
|
*O << *$3 << ' ' << *$4 << ' ' << $5->getNewTy() << ' ' << *$6 << '\n';
|
||||||
delete $2; delete $3; delete $4; delete $6;
|
delete $2; delete $3; delete $4; delete $6;
|
||||||
@ -953,9 +1295,9 @@ ConstPool : ConstPool OptAssign TYPE TypesV {
|
|||||||
}
|
}
|
||||||
| ConstPool OptAssign EXTERN_WEAK GlobalType Types GlobalVarAttributes {
|
| ConstPool OptAssign EXTERN_WEAK GlobalType Types GlobalVarAttributes {
|
||||||
if (!$2->empty()) {
|
if (!$2->empty()) {
|
||||||
std::string Name = getUniqueName($2,$5);
|
std::string Name = getGlobalName($2,*$3,$5->getPointerType(),
|
||||||
|
*$4 == "constant");
|
||||||
*O << Name << " = ";
|
*O << Name << " = ";
|
||||||
Globals[Name] = *$5;
|
|
||||||
}
|
}
|
||||||
*O << *$3 << ' ' << *$4 << ' ' << $5->getNewTy() << ' ' << *$6 << '\n';
|
*O << *$3 << ' ' << *$4 << ' ' << $5->getNewTy() << ' ' << *$6 << '\n';
|
||||||
delete $2; delete $3; delete $4; delete $6;
|
delete $2; delete $3; delete $4; delete $6;
|
||||||
@ -1032,7 +1374,7 @@ OptName : Name | /*empty*/ { $$ = new std::string(); };
|
|||||||
ArgVal : Types OptName {
|
ArgVal : Types OptName {
|
||||||
$$ = new std::string($1->getNewTy());
|
$$ = new std::string($1->getNewTy());
|
||||||
if (!$2->empty()) {
|
if (!$2->empty()) {
|
||||||
std::string Name = getUniqueName($2, $1);
|
std::string Name = getUniqueName($2, $1->resolve());
|
||||||
*$$ += " " + Name;
|
*$$ += " " + Name;
|
||||||
}
|
}
|
||||||
delete $2;
|
delete $2;
|
||||||
@ -1152,12 +1494,12 @@ ValueRef
|
|||||||
: SymbolicValueRef {
|
: SymbolicValueRef {
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.constant = false;
|
$$.constant = false;
|
||||||
$$.type = new TypeInfo();
|
$$.type = 0;
|
||||||
}
|
}
|
||||||
| ConstValueRef {
|
| ConstValueRef {
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.constant = true;
|
$$.constant = true;
|
||||||
$$.type = new TypeInfo();
|
$$.type = 0;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -1165,11 +1507,10 @@ ValueRef
|
|||||||
// type immediately preceeds the value reference, and allows complex constant
|
// type immediately preceeds the value reference, and allows complex constant
|
||||||
// pool references (for things like: 'ret [2 x int] [ int 12, int 42]')
|
// pool references (for things like: 'ret [2 x int] [ int 12, int 42]')
|
||||||
ResolvedVal : Types ValueRef {
|
ResolvedVal : Types ValueRef {
|
||||||
ResolveType($1);
|
$1 = $1->resolve();
|
||||||
std::string Name = getUniqueName($2.val, $1);
|
std::string Name = getUniqueName($2.val, $1);
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
delete $$.val;
|
delete $$.val;
|
||||||
delete $$.type;
|
|
||||||
$$.val = new std::string($1->getNewTy() + " " + Name);
|
$$.val = new std::string($1->getNewTy() + " " + Name);
|
||||||
$$.type = $1;
|
$$.type = $1;
|
||||||
};
|
};
|
||||||
@ -1212,12 +1553,12 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
|||||||
}
|
}
|
||||||
| RET VOID { // Return with no result...
|
| RET VOID { // Return with no result...
|
||||||
*O << " " << *$1 << ' ' << $2->getNewTy() << '\n';
|
*O << " " << *$1 << ' ' << $2->getNewTy() << '\n';
|
||||||
delete $1; delete $2;
|
delete $1;
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
| BR LABEL ValueRef { // Unconditional Branch...
|
| BR LABEL ValueRef { // Unconditional Branch...
|
||||||
*O << " " << *$1 << ' ' << $2->getNewTy() << ' ' << *$3.val << '\n';
|
*O << " " << *$1 << ' ' << $2->getNewTy() << ' ' << *$3.val << '\n';
|
||||||
delete $1; delete $2; $3.destroy();
|
delete $1; $3.destroy();
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
} // Conditional Branch...
|
} // Conditional Branch...
|
||||||
| BR BOOL ValueRef ',' LABEL ValueRef ',' LABEL ValueRef {
|
| BR BOOL ValueRef ',' LABEL ValueRef ',' LABEL ValueRef {
|
||||||
@ -1225,15 +1566,14 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
|||||||
*O << " " << *$1 << ' ' << $2->getNewTy() << ' ' << Name << ", "
|
*O << " " << *$1 << ' ' << $2->getNewTy() << ' ' << Name << ", "
|
||||||
<< $5->getNewTy() << ' ' << *$6.val << ", " << $8->getNewTy() << ' '
|
<< $5->getNewTy() << ' ' << *$6.val << ", " << $8->getNewTy() << ' '
|
||||||
<< *$9.val << '\n';
|
<< *$9.val << '\n';
|
||||||
delete $1; delete $2; $3.destroy(); delete $5; $6.destroy();
|
delete $1; $3.destroy(); $6.destroy(); $9.destroy();
|
||||||
delete $8; $9.destroy();
|
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' {
|
| SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' {
|
||||||
std::string Name = getUniqueName($3.val, $2);
|
std::string Name = getUniqueName($3.val, $2);
|
||||||
*O << " " << *$1 << ' ' << $2->getNewTy() << ' ' << Name << ", "
|
*O << " " << *$1 << ' ' << $2->getNewTy() << ' ' << Name << ", "
|
||||||
<< $5->getNewTy() << ' ' << *$6.val << " [" << *$8 << " ]\n";
|
<< $5->getNewTy() << ' ' << *$6.val << " [" << *$8 << " ]\n";
|
||||||
delete $1; delete $2; $3.destroy(); delete $5; $6.destroy();
|
delete $1; $3.destroy(); $6.destroy();
|
||||||
delete $8;
|
delete $8;
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
@ -1241,12 +1581,12 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
|||||||
std::string Name = getUniqueName($3.val, $2);
|
std::string Name = getUniqueName($3.val, $2);
|
||||||
*O << " " << *$1 << ' ' << $2->getNewTy() << ' ' << Name << ", "
|
*O << " " << *$1 << ' ' << $2->getNewTy() << ' ' << Name << ", "
|
||||||
<< $5->getNewTy() << ' ' << *$6.val << "[]\n";
|
<< $5->getNewTy() << ' ' << *$6.val << "[]\n";
|
||||||
delete $1; delete $2; $3.destroy(); delete $5; $6.destroy();
|
delete $1; $3.destroy(); $6.destroy();
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
| OptAssign INVOKE OptCallingConv TypesV ValueRef '(' ValueRefListE ')'
|
| OptAssign INVOKE OptCallingConv TypesV ValueRef '(' ValueRefListE ')'
|
||||||
TO LABEL ValueRef Unwind LABEL ValueRef {
|
TO LABEL ValueRef Unwind LABEL ValueRef {
|
||||||
TypeInfo* ResTy = getFunctionReturnType($4);
|
const TypeInfo* ResTy = getFunctionReturnType($4);
|
||||||
*O << " ";
|
*O << " ";
|
||||||
if (!$1->empty()) {
|
if (!$1->empty()) {
|
||||||
std::string Name = getUniqueName($1, ResTy);
|
std::string Name = getUniqueName($1, ResTy);
|
||||||
@ -1262,9 +1602,8 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
|||||||
}
|
}
|
||||||
*O << ") " << *$9 << ' ' << $10->getNewTy() << ' ' << *$11.val << ' '
|
*O << ") " << *$9 << ' ' << $10->getNewTy() << ' ' << *$11.val << ' '
|
||||||
<< *$12 << ' ' << $13->getNewTy() << ' ' << *$14.val << '\n';
|
<< *$12 << ' ' << $13->getNewTy() << ' ' << *$14.val << '\n';
|
||||||
delete $1; delete $2; delete $3; delete $4; $5.destroy(); delete $7;
|
delete $1; delete $2; delete $3; $5.destroy(); delete $7;
|
||||||
delete $9; delete $10; $11.destroy(); delete $12; delete $13;
|
delete $9; $11.destroy(); delete $12; $14.destroy();
|
||||||
$14.destroy();
|
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
| Unwind {
|
| Unwind {
|
||||||
@ -1281,26 +1620,26 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
|||||||
JumpTable : JumpTable IntType ConstValueRef ',' LABEL ValueRef {
|
JumpTable : JumpTable IntType ConstValueRef ',' LABEL ValueRef {
|
||||||
*$1 += " " + $2->getNewTy() + " " + *$3 + ", " + $5->getNewTy() + " " +
|
*$1 += " " + $2->getNewTy() + " " + *$3 + ", " + $5->getNewTy() + " " +
|
||||||
*$6.val;
|
*$6.val;
|
||||||
delete $2; delete $3; delete $5; $6.destroy();
|
delete $3; $6.destroy();
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| IntType ConstValueRef ',' LABEL ValueRef {
|
| IntType ConstValueRef ',' LABEL ValueRef {
|
||||||
$2->insert(0, $1->getNewTy() + " " );
|
$2->insert(0, $1->getNewTy() + " " );
|
||||||
*$2 += ", " + $4->getNewTy() + " " + *$5.val;
|
*$2 += ", " + $4->getNewTy() + " " + *$5.val;
|
||||||
delete $1; delete $4; $5.destroy();
|
$5.destroy();
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
};
|
};
|
||||||
|
|
||||||
Inst
|
Inst
|
||||||
: OptAssign InstVal {
|
: OptAssign InstVal {
|
||||||
if (!$1->empty()) {
|
if (!$1->empty()) {
|
||||||
if (deleteUselessCastFlag && *deleteUselessCastName == *$1) {
|
// Get a unique name for this value, based on its type.
|
||||||
*$1 += " = ";
|
std::string Name = getUniqueName($1, $2.type);
|
||||||
$1->insert(0, "; "); // don't actually delete it, just comment it out
|
*$1 = Name + " = ";
|
||||||
|
if (deleteUselessCastFlag && *deleteUselessCastName == Name) {
|
||||||
|
// don't actually delete it, just comment it out
|
||||||
|
$1->insert(0, "; USELSS BITCAST: ");
|
||||||
delete deleteUselessCastName;
|
delete deleteUselessCastName;
|
||||||
} else {
|
|
||||||
// Get a unique name for the name of this value, based on its type.
|
|
||||||
*$1 = getUniqueName($1, $2.type) + " = ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*$1 += *$2.val;
|
*$1 += *$2.val;
|
||||||
@ -1374,7 +1713,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
|||||||
*$1 = getCompareOp(*$1, $2);
|
*$1 = getCompareOp(*$1, $2);
|
||||||
*$1 += " " + $2->getNewTy() + " " + Name1 + ", " + Name2;
|
*$1 += " " + $2->getNewTy() + " " + Name1 + ", " + Name2;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = new TypeInfo("bool",BoolTy);
|
$$.type = TypeInfo::get("bool",BoolTy);
|
||||||
$3.destroy(); $5.destroy();
|
$3.destroy(); $5.destroy();
|
||||||
}
|
}
|
||||||
| ICMP IPredicates Types ValueRef ',' ValueRef {
|
| ICMP IPredicates Types ValueRef ',' ValueRef {
|
||||||
@ -1382,7 +1721,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
|||||||
std::string Name2 = getUniqueName($6.val, $3);
|
std::string Name2 = getUniqueName($6.val, $3);
|
||||||
*$1 += " " + *$2 + " " + $3->getNewTy() + " " + Name1 + "," + Name2;
|
*$1 += " " + *$2 + " " + $3->getNewTy() + " " + Name1 + "," + Name2;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = new TypeInfo("bool",BoolTy);
|
$$.type = TypeInfo::get("bool",BoolTy);
|
||||||
delete $2; $4.destroy(); $6.destroy();
|
delete $2; $4.destroy(); $6.destroy();
|
||||||
}
|
}
|
||||||
| FCMP FPredicates Types ValueRef ',' ValueRef {
|
| FCMP FPredicates Types ValueRef ',' ValueRef {
|
||||||
@ -1390,7 +1729,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
|||||||
std::string Name2 = getUniqueName($6.val, $3);
|
std::string Name2 = getUniqueName($6.val, $3);
|
||||||
*$1 += " " + *$2 + " " + $3->getNewTy() + " " + Name1 + "," + Name2;
|
*$1 += " " + *$2 + " " + $3->getNewTy() + " " + Name1 + "," + Name2;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = new TypeInfo("bool",BoolTy);
|
$$.type = TypeInfo::get("bool",BoolTy);
|
||||||
delete $2; $4.destroy(); $6.destroy();
|
delete $2; $4.destroy(); $6.destroy();
|
||||||
}
|
}
|
||||||
| NOT ResolvedVal {
|
| NOT ResolvedVal {
|
||||||
@ -1409,21 +1748,21 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
|||||||
}
|
}
|
||||||
| CastOps ResolvedVal TO Types {
|
| CastOps ResolvedVal TO Types {
|
||||||
std::string source = *$2.val;
|
std::string source = *$2.val;
|
||||||
TypeInfo* SrcTy = $2.type;
|
const TypeInfo* SrcTy = $2.type->resolve();
|
||||||
TypeInfo* DstTy = ResolveType($4);
|
const TypeInfo* DstTy = $4->resolve();
|
||||||
$$.val = new std::string();
|
$$.val = new std::string();
|
||||||
|
$$.type = DstTy;
|
||||||
if (*$1 == "cast") {
|
if (*$1 == "cast") {
|
||||||
*$$.val += getCastUpgrade(source, SrcTy, DstTy, false);
|
*$$.val += getCastUpgrade(source, SrcTy, DstTy, false);
|
||||||
} else {
|
} else {
|
||||||
*$$.val += *$1 + " " + source + " to " + DstTy->getNewTy();
|
*$$.val += *$1 + " " + source + " to " + DstTy->getNewTy();
|
||||||
}
|
}
|
||||||
$$.type = $4;
|
|
||||||
// Check to see if this is a useless cast of a value to the same name
|
// Check to see if this is a useless cast of a value to the same name
|
||||||
// and the same type. Such casts will probably cause redefinition errors
|
// and the same type. Such casts will probably cause redefinition errors
|
||||||
// when assembled and perform no code gen action so just remove them.
|
// when assembled and perform no code gen action so just remove them.
|
||||||
if (*$1 == "cast" || *$1 == "bitcast")
|
if (*$1 == "cast" || *$1 == "bitcast")
|
||||||
if ($2.type->isInteger() && DstTy->isInteger() &&
|
if (SrcTy->isInteger() && DstTy->isInteger() &&
|
||||||
$2.type->getBitWidth() == DstTy->getBitWidth()) {
|
SrcTy->getBitWidth() == DstTy->getBitWidth()) {
|
||||||
deleteUselessCastFlag = true; // Flag the "Inst" rule
|
deleteUselessCastFlag = true; // Flag the "Inst" rule
|
||||||
deleteUselessCastName = new std::string(*$2.val); // save the name
|
deleteUselessCastName = new std::string(*$2.val); // save the name
|
||||||
size_t pos = deleteUselessCastName->find_first_of("%\"",0);
|
size_t pos = deleteUselessCastName->find_first_of("%\"",0);
|
||||||
@ -1450,7 +1789,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
|||||||
| EXTRACTELEMENT ResolvedVal ',' ResolvedVal {
|
| EXTRACTELEMENT ResolvedVal ',' ResolvedVal {
|
||||||
*$1 += " " + *$2.val + ", " + *$4.val;
|
*$1 += " " + *$2.val + ", " + *$4.val;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
ResolveType($2.type);
|
$2.type = $2.type->resolve();;
|
||||||
$$.type = $2.type->getElementType();
|
$$.type = $2.type->getElementType();
|
||||||
delete $2.val; $4.destroy();
|
delete $2.val; $4.destroy();
|
||||||
}
|
}
|
||||||
@ -1488,7 +1827,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
|||||||
*$1 += ")";
|
*$1 += ")";
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = getFunctionReturnType($3);
|
$$.type = getFunctionReturnType($3);
|
||||||
delete $2; delete $3; $4.destroy(); delete $6;
|
delete $2; $4.destroy(); delete $6;
|
||||||
}
|
}
|
||||||
| MemoryInst ;
|
| MemoryInst ;
|
||||||
|
|
||||||
@ -1510,7 +1849,7 @@ MemoryInst : MALLOC Types OptCAlign {
|
|||||||
*$1 += " " + *$3;
|
*$1 += " " + *$3;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = $2->getPointerType();
|
$$.type = $2->getPointerType();
|
||||||
delete $2; delete $3;
|
delete $3;
|
||||||
}
|
}
|
||||||
| MALLOC Types ',' UINT ValueRef OptCAlign {
|
| MALLOC Types ',' UINT ValueRef OptCAlign {
|
||||||
std::string Name = getUniqueName($5.val, $4);
|
std::string Name = getUniqueName($5.val, $4);
|
||||||
@ -1519,7 +1858,7 @@ MemoryInst : MALLOC Types OptCAlign {
|
|||||||
*$1 += " " + *$6;
|
*$1 += " " + *$6;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = $2->getPointerType();
|
$$.type = $2->getPointerType();
|
||||||
delete $2; delete $4; $5.destroy(); delete $6;
|
$5.destroy(); delete $6;
|
||||||
}
|
}
|
||||||
| ALLOCA Types OptCAlign {
|
| ALLOCA Types OptCAlign {
|
||||||
*$1 += " " + $2->getNewTy();
|
*$1 += " " + $2->getNewTy();
|
||||||
@ -1527,7 +1866,7 @@ MemoryInst : MALLOC Types OptCAlign {
|
|||||||
*$1 += " " + *$3;
|
*$1 += " " + *$3;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = $2->getPointerType();
|
$$.type = $2->getPointerType();
|
||||||
delete $2; delete $3;
|
delete $3;
|
||||||
}
|
}
|
||||||
| ALLOCA Types ',' UINT ValueRef OptCAlign {
|
| ALLOCA Types ',' UINT ValueRef OptCAlign {
|
||||||
std::string Name = getUniqueName($5.val, $4);
|
std::string Name = getUniqueName($5.val, $4);
|
||||||
@ -1536,12 +1875,12 @@ MemoryInst : MALLOC Types OptCAlign {
|
|||||||
*$1 += " " + *$6;
|
*$1 += " " + *$6;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = $2->getPointerType();
|
$$.type = $2->getPointerType();
|
||||||
delete $2; delete $4; $5.destroy(); delete $6;
|
$5.destroy(); delete $6;
|
||||||
}
|
}
|
||||||
| FREE ResolvedVal {
|
| FREE ResolvedVal {
|
||||||
*$1 += " " + *$2.val;
|
*$1 += " " + *$2.val;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = new TypeInfo("void", VoidTy);
|
$$.type = TypeInfo::get("void", VoidTy);
|
||||||
$2.destroy();
|
$2.destroy();
|
||||||
}
|
}
|
||||||
| OptVolatile LOAD Types ValueRef {
|
| OptVolatile LOAD Types ValueRef {
|
||||||
@ -1550,8 +1889,8 @@ MemoryInst : MALLOC Types OptCAlign {
|
|||||||
*$1 += " ";
|
*$1 += " ";
|
||||||
*$1 += *$2 + " " + $3->getNewTy() + " " + Name;
|
*$1 += *$2 + " " + $3->getNewTy() + " " + Name;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = $3->getElementType()->clone();
|
$$.type = $3->getElementType();
|
||||||
delete $2; delete $3; $4.destroy();
|
delete $2; $4.destroy();
|
||||||
}
|
}
|
||||||
| OptVolatile STORE ResolvedVal ',' Types ValueRef {
|
| OptVolatile STORE ResolvedVal ',' Types ValueRef {
|
||||||
std::string Name = getUniqueName($6.val, $5);
|
std::string Name = getUniqueName($6.val, $5);
|
||||||
@ -1559,8 +1898,8 @@ MemoryInst : MALLOC Types OptCAlign {
|
|||||||
*$1 += " ";
|
*$1 += " ";
|
||||||
*$1 += *$2 + " " + *$3.val + ", " + $5->getNewTy() + " " + Name;
|
*$1 += *$2 + " " + *$3.val + ", " + $5->getNewTy() + " " + Name;
|
||||||
$$.val = $1;
|
$$.val = $1;
|
||||||
$$.type = new TypeInfo("void", VoidTy);
|
$$.type = TypeInfo::get("void", VoidTy);
|
||||||
delete $2; $3.destroy(); delete $5; $6.destroy();
|
delete $2; $3.destroy(); $6.destroy();
|
||||||
}
|
}
|
||||||
| GETELEMENTPTR Types ValueRef IndexList {
|
| GETELEMENTPTR Types ValueRef IndexList {
|
||||||
std::string Name = getUniqueName($3.val, $2);
|
std::string Name = getUniqueName($3.val, $2);
|
||||||
@ -1573,7 +1912,7 @@ MemoryInst : MALLOC Types OptCAlign {
|
|||||||
*O << " %gep_upgrade" << unique << " = zext " << *old
|
*O << " %gep_upgrade" << unique << " = zext " << *old
|
||||||
<< " to i64\n";
|
<< " to i64\n";
|
||||||
VI.val = new std::string("i64 %gep_upgrade" + llvm::utostr(unique++));
|
VI.val = new std::string("i64 %gep_upgrade" + llvm::utostr(unique++));
|
||||||
VI.type->setOldTy(ULongTy);
|
VI.type = TypeInfo::get("i64",ULongTy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*$1 += " " + $2->getNewTy() + " " + Name;
|
*$1 += " " + $2->getNewTy() + " " + Name;
|
||||||
@ -1592,7 +1931,8 @@ int yyerror(const char *ErrorMsg) {
|
|||||||
std::string where
|
std::string where
|
||||||
= std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
|
= std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
|
||||||
+ ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
|
+ ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
|
||||||
std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
|
std::string errMsg = where + "error: " + std::string(ErrorMsg) +
|
||||||
|
" while reading ";
|
||||||
if (yychar == YYEMPTY || yychar == 0)
|
if (yychar == YYEMPTY || yychar == 0)
|
||||||
errMsg += "end-of-file.";
|
errMsg += "end-of-file.";
|
||||||
else
|
else
|
||||||
@ -1601,3 +1941,16 @@ int yyerror(const char *ErrorMsg) {
|
|||||||
*O << "llvm-upgrade parse failed.\n";
|
*O << "llvm-upgrade parse failed.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void warning(const std::string& ErrorMsg) {
|
||||||
|
std::string where
|
||||||
|
= std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
|
||||||
|
+ ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
|
||||||
|
std::string errMsg = where + "warning: " + std::string(ErrorMsg) +
|
||||||
|
" while reading ";
|
||||||
|
if (yychar == YYEMPTY || yychar == 0)
|
||||||
|
errMsg += "end-of-file.";
|
||||||
|
else
|
||||||
|
errMsg += "token: '" + std::string(Upgradetext, Upgradeleng) + "'";
|
||||||
|
std::cerr << "llvm-upgrade: " << errMsg << '\n';
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user