mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-17 17:06:59 +00:00
Support several new upgrades:
div -> fdiv/udiv/sdiv rem -> frem/urem/srem except -> unwind uninitialized -> external as well as tracking the element type of pointers, packed, and array. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32127 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
72348df75e
commit
a8ca090440
@ -56,9 +56,12 @@ enum Types {
|
|||||||
struct TypeInfo {
|
struct TypeInfo {
|
||||||
std::string* newTy;
|
std::string* newTy;
|
||||||
Types oldTy;
|
Types oldTy;
|
||||||
|
Types elemTy;
|
||||||
|
|
||||||
void destroy() const { delete newTy; }
|
void destroy() const { delete newTy; }
|
||||||
|
|
||||||
|
Types getElementType() const { return elemTy; }
|
||||||
|
|
||||||
bool isSigned() const {
|
bool isSigned() const {
|
||||||
return oldTy == SByteTy || oldTy == ShortTy ||
|
return oldTy == SByteTy || oldTy == ShortTy ||
|
||||||
oldTy == IntTy || oldTy == LongTy;
|
oldTy == IntTy || oldTy == LongTy;
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#define RET_TY(sym,OldTY,NewTY,sign) \
|
#define RET_TY(sym,OldTY,NewTY,sign) \
|
||||||
Upgradelval.Type.newTy = new std::string(NewTY); \
|
Upgradelval.Type.newTy = new std::string(NewTY); \
|
||||||
Upgradelval.Type.oldTy = OldTY; \
|
Upgradelval.Type.oldTy = OldTY; \
|
||||||
|
Upgradelval.Type.elemTy = VoidTy; \
|
||||||
return sym
|
return sym
|
||||||
|
|
||||||
#define YY_NEVER_INTERACTIVE 1
|
#define YY_NEVER_INTERACTIVE 1
|
||||||
@ -114,6 +115,7 @@ dllimport { RET_TOK( DLLIMPORT); }
|
|||||||
dllexport { RET_TOK( DLLEXPORT); }
|
dllexport { RET_TOK( DLLEXPORT); }
|
||||||
extern_weak { RET_TOK( EXTERN_WEAK); }
|
extern_weak { RET_TOK( EXTERN_WEAK); }
|
||||||
external { RET_TOK( EXTERNAL); }
|
external { RET_TOK( EXTERNAL); }
|
||||||
|
uninitialized { RET_TOK( UNINITIALIZED); } // alias for external
|
||||||
implementation { RET_TOK( IMPLEMENTATION); }
|
implementation { RET_TOK( IMPLEMENTATION); }
|
||||||
zeroinitializer { RET_TOK( ZEROINITIALIZER); }
|
zeroinitializer { RET_TOK( ZEROINITIALIZER); }
|
||||||
\.\.\. { RET_TOK( DOTDOTDOT); }
|
\.\.\. { RET_TOK( DOTDOTDOT); }
|
||||||
@ -163,11 +165,11 @@ type { RET_TOK(TYPE); }
|
|||||||
add { RET_TOK( ADD); }
|
add { RET_TOK( ADD); }
|
||||||
sub { RET_TOK( SUB); }
|
sub { RET_TOK( SUB); }
|
||||||
mul { RET_TOK( MUL); }
|
mul { RET_TOK( MUL); }
|
||||||
div { RET_TOK( UDIV); }
|
div { RET_TOK( DIV); }
|
||||||
udiv { RET_TOK( UDIV); }
|
udiv { RET_TOK( UDIV); }
|
||||||
sdiv { RET_TOK( SDIV); }
|
sdiv { RET_TOK( SDIV); }
|
||||||
fdiv { RET_TOK( FDIV); }
|
fdiv { RET_TOK( FDIV); }
|
||||||
rem { RET_TOK( UREM); }
|
rem { RET_TOK( REM); }
|
||||||
urem { RET_TOK( UREM); }
|
urem { RET_TOK( UREM); }
|
||||||
srem { RET_TOK( SREM); }
|
srem { RET_TOK( SREM); }
|
||||||
frem { RET_TOK( FREM); }
|
frem { RET_TOK( FREM); }
|
||||||
@ -207,7 +209,7 @@ br { RET_TOK( BR); }
|
|||||||
switch { RET_TOK( SWITCH); }
|
switch { RET_TOK( SWITCH); }
|
||||||
invoke { RET_TOK( INVOKE); }
|
invoke { RET_TOK( INVOKE); }
|
||||||
unwind { RET_TOK( UNWIND); }
|
unwind { RET_TOK( UNWIND); }
|
||||||
except { RET_TOK( UNWIND); }
|
except { RET_TOK( EXCEPT); } // alias for unwind
|
||||||
unreachable { RET_TOK( UNREACHABLE); }
|
unreachable { RET_TOK( UNREACHABLE); }
|
||||||
|
|
||||||
malloc { RET_TOK( MALLOC); }
|
malloc { RET_TOK( MALLOC); }
|
||||||
|
@ -84,73 +84,77 @@
|
|||||||
LITTLE = 310,
|
LITTLE = 310,
|
||||||
BIG = 311,
|
BIG = 311,
|
||||||
ALIGN = 312,
|
ALIGN = 312,
|
||||||
DEPLIBS = 313,
|
UNINITIALIZED = 313,
|
||||||
CALL = 314,
|
DEPLIBS = 314,
|
||||||
TAIL = 315,
|
CALL = 315,
|
||||||
ASM_TOK = 316,
|
TAIL = 316,
|
||||||
MODULE = 317,
|
ASM_TOK = 317,
|
||||||
SIDEEFFECT = 318,
|
MODULE = 318,
|
||||||
CC_TOK = 319,
|
SIDEEFFECT = 319,
|
||||||
CCC_TOK = 320,
|
CC_TOK = 320,
|
||||||
CSRETCC_TOK = 321,
|
CCC_TOK = 321,
|
||||||
FASTCC_TOK = 322,
|
CSRETCC_TOK = 322,
|
||||||
COLDCC_TOK = 323,
|
FASTCC_TOK = 323,
|
||||||
X86_STDCALLCC_TOK = 324,
|
COLDCC_TOK = 324,
|
||||||
X86_FASTCALLCC_TOK = 325,
|
X86_STDCALLCC_TOK = 325,
|
||||||
DATALAYOUT = 326,
|
X86_FASTCALLCC_TOK = 326,
|
||||||
RET = 327,
|
DATALAYOUT = 327,
|
||||||
BR = 328,
|
RET = 328,
|
||||||
SWITCH = 329,
|
BR = 329,
|
||||||
INVOKE = 330,
|
SWITCH = 330,
|
||||||
UNWIND = 331,
|
INVOKE = 331,
|
||||||
UNREACHABLE = 332,
|
EXCEPT = 332,
|
||||||
ADD = 333,
|
UNWIND = 333,
|
||||||
SUB = 334,
|
UNREACHABLE = 334,
|
||||||
MUL = 335,
|
ADD = 335,
|
||||||
UDIV = 336,
|
SUB = 336,
|
||||||
SDIV = 337,
|
MUL = 337,
|
||||||
FDIV = 338,
|
DIV = 338,
|
||||||
UREM = 339,
|
UDIV = 339,
|
||||||
SREM = 340,
|
SDIV = 340,
|
||||||
FREM = 341,
|
FDIV = 341,
|
||||||
AND = 342,
|
REM = 342,
|
||||||
OR = 343,
|
UREM = 343,
|
||||||
XOR = 344,
|
SREM = 344,
|
||||||
SETLE = 345,
|
FREM = 345,
|
||||||
SETGE = 346,
|
AND = 346,
|
||||||
SETLT = 347,
|
OR = 347,
|
||||||
SETGT = 348,
|
XOR = 348,
|
||||||
SETEQ = 349,
|
SETLE = 349,
|
||||||
SETNE = 350,
|
SETGE = 350,
|
||||||
MALLOC = 351,
|
SETLT = 351,
|
||||||
ALLOCA = 352,
|
SETGT = 352,
|
||||||
FREE = 353,
|
SETEQ = 353,
|
||||||
LOAD = 354,
|
SETNE = 354,
|
||||||
STORE = 355,
|
MALLOC = 355,
|
||||||
GETELEMENTPTR = 356,
|
ALLOCA = 356,
|
||||||
PHI_TOK = 357,
|
FREE = 357,
|
||||||
SELECT = 358,
|
LOAD = 358,
|
||||||
SHL = 359,
|
STORE = 359,
|
||||||
SHR = 360,
|
GETELEMENTPTR = 360,
|
||||||
ASHR = 361,
|
PHI_TOK = 361,
|
||||||
LSHR = 362,
|
SELECT = 362,
|
||||||
VAARG = 363,
|
SHL = 363,
|
||||||
EXTRACTELEMENT = 364,
|
SHR = 364,
|
||||||
INSERTELEMENT = 365,
|
ASHR = 365,
|
||||||
SHUFFLEVECTOR = 366,
|
LSHR = 366,
|
||||||
CAST = 367,
|
VAARG = 367,
|
||||||
TRUNC = 368,
|
EXTRACTELEMENT = 368,
|
||||||
ZEXT = 369,
|
INSERTELEMENT = 369,
|
||||||
SEXT = 370,
|
SHUFFLEVECTOR = 370,
|
||||||
FPTRUNC = 371,
|
CAST = 371,
|
||||||
FPEXT = 372,
|
TRUNC = 372,
|
||||||
FPTOUI = 373,
|
ZEXT = 373,
|
||||||
FPTOSI = 374,
|
SEXT = 374,
|
||||||
UITOFP = 375,
|
FPTRUNC = 375,
|
||||||
SITOFP = 376,
|
FPEXT = 376,
|
||||||
PTRTOINT = 377,
|
FPTOUI = 377,
|
||||||
INTTOPTR = 378,
|
FPTOSI = 378,
|
||||||
BITCAST = 379
|
UITOFP = 379,
|
||||||
|
SITOFP = 380,
|
||||||
|
PTRTOINT = 381,
|
||||||
|
INTTOPTR = 382,
|
||||||
|
BITCAST = 383
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
/* Tokens. */
|
/* Tokens. */
|
||||||
@ -209,79 +213,83 @@
|
|||||||
#define LITTLE 310
|
#define LITTLE 310
|
||||||
#define BIG 311
|
#define BIG 311
|
||||||
#define ALIGN 312
|
#define ALIGN 312
|
||||||
#define DEPLIBS 313
|
#define UNINITIALIZED 313
|
||||||
#define CALL 314
|
#define DEPLIBS 314
|
||||||
#define TAIL 315
|
#define CALL 315
|
||||||
#define ASM_TOK 316
|
#define TAIL 316
|
||||||
#define MODULE 317
|
#define ASM_TOK 317
|
||||||
#define SIDEEFFECT 318
|
#define MODULE 318
|
||||||
#define CC_TOK 319
|
#define SIDEEFFECT 319
|
||||||
#define CCC_TOK 320
|
#define CC_TOK 320
|
||||||
#define CSRETCC_TOK 321
|
#define CCC_TOK 321
|
||||||
#define FASTCC_TOK 322
|
#define CSRETCC_TOK 322
|
||||||
#define COLDCC_TOK 323
|
#define FASTCC_TOK 323
|
||||||
#define X86_STDCALLCC_TOK 324
|
#define COLDCC_TOK 324
|
||||||
#define X86_FASTCALLCC_TOK 325
|
#define X86_STDCALLCC_TOK 325
|
||||||
#define DATALAYOUT 326
|
#define X86_FASTCALLCC_TOK 326
|
||||||
#define RET 327
|
#define DATALAYOUT 327
|
||||||
#define BR 328
|
#define RET 328
|
||||||
#define SWITCH 329
|
#define BR 329
|
||||||
#define INVOKE 330
|
#define SWITCH 330
|
||||||
#define UNWIND 331
|
#define INVOKE 331
|
||||||
#define UNREACHABLE 332
|
#define EXCEPT 332
|
||||||
#define ADD 333
|
#define UNWIND 333
|
||||||
#define SUB 334
|
#define UNREACHABLE 334
|
||||||
#define MUL 335
|
#define ADD 335
|
||||||
#define UDIV 336
|
#define SUB 336
|
||||||
#define SDIV 337
|
#define MUL 337
|
||||||
#define FDIV 338
|
#define DIV 338
|
||||||
#define UREM 339
|
#define UDIV 339
|
||||||
#define SREM 340
|
#define SDIV 340
|
||||||
#define FREM 341
|
#define FDIV 341
|
||||||
#define AND 342
|
#define REM 342
|
||||||
#define OR 343
|
#define UREM 343
|
||||||
#define XOR 344
|
#define SREM 344
|
||||||
#define SETLE 345
|
#define FREM 345
|
||||||
#define SETGE 346
|
#define AND 346
|
||||||
#define SETLT 347
|
#define OR 347
|
||||||
#define SETGT 348
|
#define XOR 348
|
||||||
#define SETEQ 349
|
#define SETLE 349
|
||||||
#define SETNE 350
|
#define SETGE 350
|
||||||
#define MALLOC 351
|
#define SETLT 351
|
||||||
#define ALLOCA 352
|
#define SETGT 352
|
||||||
#define FREE 353
|
#define SETEQ 353
|
||||||
#define LOAD 354
|
#define SETNE 354
|
||||||
#define STORE 355
|
#define MALLOC 355
|
||||||
#define GETELEMENTPTR 356
|
#define ALLOCA 356
|
||||||
#define PHI_TOK 357
|
#define FREE 357
|
||||||
#define SELECT 358
|
#define LOAD 358
|
||||||
#define SHL 359
|
#define STORE 359
|
||||||
#define SHR 360
|
#define GETELEMENTPTR 360
|
||||||
#define ASHR 361
|
#define PHI_TOK 361
|
||||||
#define LSHR 362
|
#define SELECT 362
|
||||||
#define VAARG 363
|
#define SHL 363
|
||||||
#define EXTRACTELEMENT 364
|
#define SHR 364
|
||||||
#define INSERTELEMENT 365
|
#define ASHR 365
|
||||||
#define SHUFFLEVECTOR 366
|
#define LSHR 366
|
||||||
#define CAST 367
|
#define VAARG 367
|
||||||
#define TRUNC 368
|
#define EXTRACTELEMENT 368
|
||||||
#define ZEXT 369
|
#define INSERTELEMENT 369
|
||||||
#define SEXT 370
|
#define SHUFFLEVECTOR 370
|
||||||
#define FPTRUNC 371
|
#define CAST 371
|
||||||
#define FPEXT 372
|
#define TRUNC 372
|
||||||
#define FPTOUI 373
|
#define ZEXT 373
|
||||||
#define FPTOSI 374
|
#define SEXT 374
|
||||||
#define UITOFP 375
|
#define FPTRUNC 375
|
||||||
#define SITOFP 376
|
#define FPEXT 376
|
||||||
#define PTRTOINT 377
|
#define FPTOUI 377
|
||||||
#define INTTOPTR 378
|
#define FPTOSI 378
|
||||||
#define BITCAST 379
|
#define UITOFP 379
|
||||||
|
#define SITOFP 380
|
||||||
|
#define PTRTOINT 381
|
||||||
|
#define INTTOPTR 382
|
||||||
|
#define BITCAST 383
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||||
#line 211 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
|
#line 239 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeParser.y"
|
||||||
typedef union YYSTYPE {
|
typedef union YYSTYPE {
|
||||||
std::string* String;
|
std::string* String;
|
||||||
TypeInfo Type;
|
TypeInfo Type;
|
||||||
@ -290,7 +298,7 @@ typedef union YYSTYPE {
|
|||||||
ValueList* ValList;
|
ValueList* ValList;
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
/* Line 1447 of yacc.c. */
|
/* Line 1447 of yacc.c. */
|
||||||
#line 294 "UpgradeParser.tab.h"
|
#line 302 "UpgradeParser.tab.h"
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
|
@ -65,9 +65,10 @@ void UpgradeAssembly(const std::string &infile, std::istream& in,
|
|||||||
static void ResolveType(TypeInfo& Ty) {
|
static void ResolveType(TypeInfo& Ty) {
|
||||||
if (Ty.oldTy == UnresolvedTy) {
|
if (Ty.oldTy == UnresolvedTy) {
|
||||||
TypeMap::iterator I = NamedTypes.find(*Ty.newTy);
|
TypeMap::iterator I = NamedTypes.find(*Ty.newTy);
|
||||||
if (I != NamedTypes.end())
|
if (I != NamedTypes.end()) {
|
||||||
Ty.oldTy = I->second.oldTy;
|
Ty.oldTy = I->second.oldTy;
|
||||||
else {
|
Ty.elemTy = I->second.elemTy;
|
||||||
|
} else {
|
||||||
std::string msg("Can't resolve type: ");
|
std::string msg("Can't resolve type: ");
|
||||||
msg += *Ty.newTy;
|
msg += *Ty.newTy;
|
||||||
yyerror(msg.c_str());
|
yyerror(msg.c_str());
|
||||||
@ -76,6 +77,7 @@ static void ResolveType(TypeInfo& Ty) {
|
|||||||
unsigned ref = atoi(&((Ty.newTy->c_str())[1])); // Skip the '\\'
|
unsigned ref = atoi(&((Ty.newTy->c_str())[1])); // Skip the '\\'
|
||||||
if (ref < EnumeratedTypes.size()) {
|
if (ref < EnumeratedTypes.size()) {
|
||||||
Ty.oldTy = EnumeratedTypes[ref].oldTy;
|
Ty.oldTy = EnumeratedTypes[ref].oldTy;
|
||||||
|
Ty.elemTy = EnumeratedTypes[ref].elemTy;
|
||||||
} else {
|
} else {
|
||||||
std::string msg("Can't resolve type: ");
|
std::string msg("Can't resolve type: ");
|
||||||
msg += *Ty.newTy;
|
msg += *Ty.newTy;
|
||||||
@ -204,6 +206,32 @@ static std::string getCastUpgrade(
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* getDivRemOpcode(const std::string& opcode, const TypeInfo& TI) {
|
||||||
|
const char* op = opcode.c_str();
|
||||||
|
TypeInfo Ty = TI;
|
||||||
|
ResolveType(Ty);
|
||||||
|
if (Ty.isPacked())
|
||||||
|
Ty.oldTy = Ty.getElementType();
|
||||||
|
if (opcode == "div")
|
||||||
|
if (Ty.isFloatingPoint())
|
||||||
|
op = "fdiv";
|
||||||
|
else if (Ty.isUnsigned())
|
||||||
|
op = "udiv";
|
||||||
|
else if (Ty.isSigned())
|
||||||
|
op = "sdiv";
|
||||||
|
else
|
||||||
|
yyerror("Invalid type for div instruction");
|
||||||
|
else if (opcode == "rem")
|
||||||
|
if (Ty.isFloatingPoint())
|
||||||
|
op = "frem";
|
||||||
|
else if (Ty.isUnsigned())
|
||||||
|
op = "urem";
|
||||||
|
else if (Ty.isSigned())
|
||||||
|
op = "srem";
|
||||||
|
else
|
||||||
|
yyerror("Invalid type for rem instruction");
|
||||||
|
return op;
|
||||||
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%file-prefix="UpgradeParser"
|
%file-prefix="UpgradeParser"
|
||||||
@ -226,13 +254,13 @@ static std::string getCastUpgrade(
|
|||||||
%token <String> TO DOTDOTDOT CONST INTERNAL LINKONCE WEAK
|
%token <String> TO DOTDOTDOT CONST INTERNAL LINKONCE WEAK
|
||||||
%token <String> DLLIMPORT DLLEXPORT EXTERN_WEAK APPENDING
|
%token <String> DLLIMPORT DLLEXPORT EXTERN_WEAK APPENDING
|
||||||
%token <String> NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
|
%token <String> NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
|
||||||
%token <String> ALIGN
|
%token <String> ALIGN UNINITIALIZED
|
||||||
%token <String> DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
|
%token <String> DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
|
||||||
%token <String> CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK
|
%token <String> CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK
|
||||||
%token <String> X86_STDCALLCC_TOK X86_FASTCALLCC_TOK
|
%token <String> X86_STDCALLCC_TOK X86_FASTCALLCC_TOK
|
||||||
%token <String> DATALAYOUT
|
%token <String> DATALAYOUT
|
||||||
%token <String> RET BR SWITCH INVOKE UNWIND UNREACHABLE
|
%token <String> RET BR SWITCH INVOKE EXCEPT UNWIND UNREACHABLE
|
||||||
%token <String> ADD SUB MUL UDIV SDIV FDIV UREM SREM FREM AND OR XOR
|
%token <String> ADD SUB MUL DIV UDIV SDIV FDIV REM UREM SREM FREM AND OR XOR
|
||||||
%token <String> SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comparators
|
%token <String> SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comparators
|
||||||
%token <String> MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR
|
%token <String> MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR
|
||||||
%token <String> PHI_TOK SELECT SHL SHR ASHR LSHR VAARG
|
%token <String> PHI_TOK SELECT SHL SHR ASHR LSHR VAARG
|
||||||
@ -247,10 +275,10 @@ static std::string getCastUpgrade(
|
|||||||
%type <String> ArgVal ArgListH ArgList FunctionHeaderH BEGIN FunctionHeader END
|
%type <String> ArgVal ArgListH ArgList FunctionHeaderH BEGIN FunctionHeader END
|
||||||
%type <String> Function FunctionProto BasicBlock TypeListI
|
%type <String> Function FunctionProto BasicBlock TypeListI
|
||||||
%type <String> InstructionList BBTerminatorInst JumpTable Inst PHIList
|
%type <String> InstructionList BBTerminatorInst JumpTable Inst PHIList
|
||||||
%type <String> OptTailCall InstVal OptVolatile
|
%type <String> OptTailCall InstVal OptVolatile Unwind
|
||||||
%type <String> MemoryInst SymbolicValueRef OptSideEffect GlobalType
|
%type <String> MemoryInst SymbolicValueRef OptSideEffect GlobalType
|
||||||
%type <String> FnDeclareLinkage BasicBlockList BigOrLittle AsmBlock
|
%type <String> FnDeclareLinkage BasicBlockList BigOrLittle AsmBlock
|
||||||
%type <String> Name ConstValueRef ConstVector
|
%type <String> Name ConstValueRef ConstVector External
|
||||||
%type <String> ShiftOps SetCondOps LogicalOps ArithmeticOps CastOps
|
%type <String> ShiftOps SetCondOps LogicalOps ArithmeticOps CastOps
|
||||||
|
|
||||||
%type <ValList> ValueRefList ValueRefListE IndexList
|
%type <ValList> ValueRefList ValueRefListE IndexList
|
||||||
@ -273,7 +301,8 @@ EInt64Val : ESINT64VAL | EUINT64VAL;
|
|||||||
|
|
||||||
// Operations that are notably excluded from this list include:
|
// Operations that are notably excluded from this list include:
|
||||||
// RET, BR, & SWITCH because they end basic blocks and are treated specially.
|
// RET, BR, & SWITCH because they end basic blocks and are treated specially.
|
||||||
ArithmeticOps: ADD | SUB | MUL | UDIV | SDIV | FDIV | UREM | SREM | FREM;
|
ArithmeticOps: ADD | SUB | MUL | DIV | UDIV | SDIV | FDIV
|
||||||
|
| REM | UREM | SREM | FREM;
|
||||||
LogicalOps : AND | OR | XOR;
|
LogicalOps : AND | OR | XOR;
|
||||||
SetCondOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE;
|
SetCondOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE;
|
||||||
ShiftOps : SHL | SHR | ASHR | LSHR;
|
ShiftOps : SHL | SHR | ASHR | LSHR;
|
||||||
@ -378,12 +407,10 @@ UpRTypes
|
|||||||
$$.newTy = $1;
|
$$.newTy = $1;
|
||||||
$$.oldTy = UnresolvedTy;
|
$$.oldTy = UnresolvedTy;
|
||||||
}
|
}
|
||||||
| PrimType
|
| PrimType {
|
||||||
;
|
$$ = $1;
|
||||||
|
}
|
||||||
// Include derived types in the Types production.
|
| '\\' EUINT64VAL { // Type UpReference
|
||||||
//
|
|
||||||
UpRTypes : '\\' EUINT64VAL { // Type UpReference
|
|
||||||
$2->insert(0, "\\");
|
$2->insert(0, "\\");
|
||||||
$$.newTy = $2;
|
$$.newTy = $2;
|
||||||
$$.oldTy = NumericTy;
|
$$.oldTy = NumericTy;
|
||||||
@ -400,6 +427,7 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference
|
|||||||
delete $4.newTy;
|
delete $4.newTy;
|
||||||
$$.newTy = $2;
|
$$.newTy = $2;
|
||||||
$$.oldTy = ArrayTy;
|
$$.oldTy = ArrayTy;
|
||||||
|
$$.elemTy = $4.oldTy;
|
||||||
}
|
}
|
||||||
| '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type?
|
| '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type?
|
||||||
$2->insert(0,"< ");
|
$2->insert(0,"< ");
|
||||||
@ -407,6 +435,7 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference
|
|||||||
delete $4.newTy;
|
delete $4.newTy;
|
||||||
$$.newTy = $2;
|
$$.newTy = $2;
|
||||||
$$.oldTy = PackedTy;
|
$$.oldTy = PackedTy;
|
||||||
|
$$.elemTy = $4.oldTy;
|
||||||
}
|
}
|
||||||
| '{' TypeListI '}' { // Structure type?
|
| '{' TypeListI '}' { // Structure type?
|
||||||
$2->insert(0, "{ ");
|
$2->insert(0, "{ ");
|
||||||
@ -420,6 +449,7 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference
|
|||||||
}
|
}
|
||||||
| UpRTypes '*' { // Pointer type?
|
| UpRTypes '*' { // Pointer type?
|
||||||
*$1.newTy += '*';
|
*$1.newTy += '*';
|
||||||
|
$$.elemTy = $1.oldTy;
|
||||||
$1.oldTy = PointerTy;
|
$1.oldTy = PointerTy;
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
};
|
};
|
||||||
@ -586,9 +616,10 @@ ConstExpr: CastOps '(' ConstVal TO Types ')' {
|
|||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| ArithmeticOps '(' ConstVal ',' ConstVal ')' {
|
| ArithmeticOps '(' ConstVal ',' ConstVal ')' {
|
||||||
*$1 += "(" + *$3.cnst + "," + *$5.cnst + ")";
|
const char* op = getDivRemOpcode(*$1, $3.type);
|
||||||
$3.destroy(); $5.destroy();
|
$$ = new std::string(op);
|
||||||
$$ = $1;
|
*$$ += "(" + *$3.cnst + "," + *$5.cnst + ")";
|
||||||
|
delete $1; $3.destroy(); $5.destroy();
|
||||||
}
|
}
|
||||||
| LogicalOps '(' ConstVal ',' ConstVal ')' {
|
| LogicalOps '(' ConstVal ',' ConstVal ')' {
|
||||||
*$1 += "(" + *$3.cnst + "," + *$5.cnst + ")";
|
*$1 += "(" + *$3.cnst + "," + *$5.cnst + ")";
|
||||||
@ -671,12 +702,15 @@ DefinitionList : DefinitionList Function {
|
|||||||
}
|
}
|
||||||
| ConstPool { $$ = 0; }
|
| ConstPool { $$ = 0; }
|
||||||
|
|
||||||
|
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].newTy = new std::string(*$4.newTy);
|
NamedTypes[*$2].newTy = new std::string(*$4.newTy);
|
||||||
NamedTypes[*$2].oldTy = $4.oldTy;
|
NamedTypes[*$2].oldTy = $4.oldTy;
|
||||||
|
NamedTypes[*$2].elemTy = $4.elemTy;
|
||||||
*O << *$2 << " = ";
|
*O << *$2 << " = ";
|
||||||
}
|
}
|
||||||
*O << "type " << *$4.newTy << "\n";
|
*O << "type " << *$4.newTy << "\n";
|
||||||
@ -700,7 +734,7 @@ ConstPool : ConstPool OptAssign TYPE TypesV {
|
|||||||
delete $2; delete $3; delete $4; $5.destroy(); delete $6;
|
delete $2; delete $3; delete $4; $5.destroy(); delete $6;
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
| ConstPool OptAssign EXTERNAL GlobalType Types GlobalVarAttributes {
|
| ConstPool OptAssign External GlobalType Types GlobalVarAttributes {
|
||||||
if (!$2->empty())
|
if (!$2->empty())
|
||||||
*O << *$2 << " = ";
|
*O << *$2 << " = ";
|
||||||
*O << *$3 << " " << *$4 << " " << *$5.newTy << " " << *$6 << "\n";
|
*O << *$3 << " " << *$4 << " " << *$5.newTy << " " << *$6 << "\n";
|
||||||
@ -837,12 +871,8 @@ FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')'
|
|||||||
$$ = $1;
|
$$ = $1;
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN : BEGINTOK {
|
BEGIN : BEGINTOK { $$ = new std::string("{"); delete $1; }
|
||||||
$$ = new std::string("begin");
|
| '{' { $$ = new std::string ("{"); }
|
||||||
}
|
|
||||||
| '{' {
|
|
||||||
$$ = new std::string ("{");
|
|
||||||
}
|
|
||||||
|
|
||||||
FunctionHeader : OptLinkage FunctionHeaderH BEGIN {
|
FunctionHeader : OptLinkage FunctionHeaderH BEGIN {
|
||||||
if (!$1->empty()) {
|
if (!$1->empty()) {
|
||||||
@ -853,7 +883,7 @@ FunctionHeader : OptLinkage FunctionHeaderH BEGIN {
|
|||||||
$$ = 0;
|
$$ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
END : ENDTOK { $$ = new std::string("end"); }
|
END : ENDTOK { $$ = new std::string("}"); delete $1; }
|
||||||
| '}' { $$ = new std::string("}"); };
|
| '}' { $$ = new std::string("}"); };
|
||||||
|
|
||||||
Function : FunctionHeader BasicBlockList END {
|
Function : FunctionHeader BasicBlockList END {
|
||||||
@ -960,6 +990,8 @@ InstructionList : InstructionList Inst {
|
|||||||
$$ = 0;
|
$$ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Unwind : UNWIND | EXCEPT { $$ = $1; *$$ = "unwind"; }
|
||||||
|
|
||||||
BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
||||||
*O << " " << *$1 << " " << *$2.val << "\n";
|
*O << " " << *$1 << " " << *$2.val << "\n";
|
||||||
delete $1; $2.destroy();
|
delete $1; $2.destroy();
|
||||||
@ -997,7 +1029,7 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
|||||||
$$ = 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 {
|
||||||
*O << " ";
|
*O << " ";
|
||||||
if (!$1->empty())
|
if (!$1->empty())
|
||||||
*O << *$1 << " = ";
|
*O << *$1 << " = ";
|
||||||
@ -1016,7 +1048,7 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
|||||||
$14.destroy();
|
$14.destroy();
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
| UNWIND {
|
| Unwind {
|
||||||
*O << " " << *$1 << "\n";
|
*O << " " << *$1 << "\n";
|
||||||
delete $1;
|
delete $1;
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
@ -1089,9 +1121,10 @@ OptTailCall
|
|||||||
;
|
;
|
||||||
|
|
||||||
InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
||||||
*$1 += " " + *$2.newTy + " " + *$3.val + ", " + *$5.val;
|
const char* op = getDivRemOpcode(*$1, $2);
|
||||||
$2.destroy(); $3.destroy(); $5.destroy();
|
$$ = new std::string(op);
|
||||||
$$ = $1;
|
*$$ += " " + *$2.newTy + " " + *$3.val + ", " + *$5.val;
|
||||||
|
delete $1; $2.destroy(); $3.destroy(); $5.destroy();
|
||||||
}
|
}
|
||||||
| LogicalOps Types ValueRef ',' ValueRef {
|
| LogicalOps Types ValueRef ',' ValueRef {
|
||||||
*$1 += " " + *$2.newTy + " " + *$3.val + ", " + *$5.val;
|
*$1 += " " + *$2.newTy + " " + *$3.val + ", " + *$5.val;
|
||||||
|
Loading…
Reference in New Issue
Block a user