Allow the new cast instructions.

llvm-svn: 32104
This commit is contained in:
Reid Spencer 2006-12-01 22:34:43 +00:00
parent c3f57a2f8b
commit 7956c3647b
10 changed files with 3116 additions and 2676 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -184,6 +184,18 @@ setge { RET_TOK( SETGE); }
phi { RET_TOK( PHI_TOK); }
call { RET_TOK( CALL); }
cast { RET_TOK( CAST); }
trunc { RET_TOK( TRUNC); }
zext { RET_TOK( ZEXT); }
sext { RET_TOK( SEXT); }
fptrunc { RET_TOK( FPTRUNC); }
fpext { RET_TOK( FPEXT); }
fptoui { RET_TOK( FPTOUI); }
fptosi { RET_TOK( FPTOSI); }
uitofp { RET_TOK( UITOFP); }
sitofp { RET_TOK( SITOFP); }
ptrtoint { RET_TOK( PTRTOINT); }
inttoptr { RET_TOK( INTTOPTR); }
bitcast { RET_TOK( BITCAST); }
select { RET_TOK( SELECT); }
shl { RET_TOK( SHL); }
shr { RET_TOK( SHR); }

View File

@ -184,6 +184,18 @@ setge { RET_TOK( SETGE); }
phi { RET_TOK( PHI_TOK); }
call { RET_TOK( CALL); }
cast { RET_TOK( CAST); }
trunc { RET_TOK( TRUNC); }
zext { RET_TOK( ZEXT); }
sext { RET_TOK( SEXT); }
fptrunc { RET_TOK( FPTRUNC); }
fpext { RET_TOK( FPEXT); }
fptoui { RET_TOK( FPTOUI); }
fptosi { RET_TOK( FPTOSI); }
uitofp { RET_TOK( UITOFP); }
sitofp { RET_TOK( SITOFP); }
ptrtoint { RET_TOK( PTRTOINT); }
inttoptr { RET_TOK( INTTOPTR); }
bitcast { RET_TOK( BITCAST); }
select { RET_TOK( SELECT); }
shl { RET_TOK( SHL); }
shr { RET_TOK( SHR); }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -138,7 +138,19 @@
EXTRACTELEMENT = 364,
INSERTELEMENT = 365,
SHUFFLEVECTOR = 366,
CAST = 367
CAST = 367,
TRUNC = 368,
ZEXT = 369,
SEXT = 370,
FPTRUNC = 371,
FPEXT = 372,
FPTOUI = 373,
FPTOSI = 374,
UITOFP = 375,
SITOFP = 376,
PTRTOINT = 377,
INTTOPTR = 378,
BITCAST = 379
};
#endif
/* Tokens. */
@ -252,6 +264,18 @@
#define INSERTELEMENT 365
#define SHUFFLEVECTOR 366
#define CAST 367
#define TRUNC 368
#define ZEXT 369
#define SEXT 370
#define FPTRUNC 371
#define FPEXT 372
#define FPTOUI 373
#define FPTOSI 374
#define UITOFP 375
#define SITOFP 376
#define PTRTOINT 377
#define INTTOPTR 378
#define BITCAST 379
@ -265,7 +289,7 @@ typedef union YYSTYPE {
ConstInfo Const;
} YYSTYPE;
/* Line 1447 of yacc.c. */
#line 269 "UpgradeParser.tab.h"
#line 293 "UpgradeParser.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1

View File

@ -138,7 +138,19 @@
EXTRACTELEMENT = 364,
INSERTELEMENT = 365,
SHUFFLEVECTOR = 366,
CAST = 367
CAST = 367,
TRUNC = 368,
ZEXT = 369,
SEXT = 370,
FPTRUNC = 371,
FPEXT = 372,
FPTOUI = 373,
FPTOSI = 374,
UITOFP = 375,
SITOFP = 376,
PTRTOINT = 377,
INTTOPTR = 378,
BITCAST = 379
};
#endif
/* Tokens. */
@ -252,6 +264,18 @@
#define INSERTELEMENT 365
#define SHUFFLEVECTOR 366
#define CAST 367
#define TRUNC 368
#define ZEXT 369
#define SEXT 370
#define FPTRUNC 371
#define FPEXT 372
#define FPTOUI 373
#define FPTOSI 374
#define UITOFP 375
#define SITOFP 376
#define PTRTOINT 377
#define INTTOPTR 378
#define BITCAST 379
@ -265,7 +289,7 @@ typedef union YYSTYPE {
ConstInfo Const;
} YYSTYPE;
/* Line 1447 of yacc.c. */
#line 269 "UpgradeParser.tab.h"
#line 293 "UpgradeParser.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1

View File

@ -155,7 +155,8 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
%token <String> MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR
%token <String> PHI_TOK SELECT SHL SHR ASHR LSHR VAARG
%token <String> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
%token <String> CAST
%token <String> CAST TRUNC ZEXT SEXT FPTRUNC FPEXT FPTOUI FPTOSI UITOFP SITOFP
%token <String> PTRTOINT INTTOPTR BITCAST
%type <String> OptAssign OptLinkage OptCallingConv OptAlign OptCAlign
%type <String> SectionString OptSection GlobalVarAttributes GlobalVarAttribute
@ -167,8 +168,8 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
%type <String> ValueRefList OptTailCall InstVal IndexList OptVolatile
%type <String> MemoryInst SymbolicValueRef OptSideEffect GlobalType
%type <String> FnDeclareLinkage BasicBlockList BigOrLittle AsmBlock
%type <String> Name ValueRef ValueRefListE
%type <String> ShiftOps SetCondOps LogicalOps ArithmeticOps ConstValueRef
%type <String> Name ValueRef ValueRefListE ConstValueRef
%type <String> ShiftOps SetCondOps LogicalOps ArithmeticOps CastOps
%type <String> ConstVector
@ -194,6 +195,9 @@ ArithmeticOps: ADD | SUB | MUL | UDIV | SDIV | FDIV | UREM | SREM | FREM;
LogicalOps : AND | OR | XOR;
SetCondOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE;
ShiftOps : SHL | SHR | ASHR | LSHR;
CastOps : TRUNC | ZEXT | SEXT | FPTRUNC | FPEXT | FPTOUI | FPTOSI |
UITOFP | SITOFP | PTRTOINT | INTTOPTR | BITCAST | CAST
;
// These are some types that allow classification if we only want a particular
// thing... for example, only a signed, unsigned, or integral type.
@ -462,9 +466,11 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
};
ConstExpr: CAST '(' ConstVal TO Types ')' {
ConstExpr: CastOps '(' ConstVal TO Types ')' {
// We must infer the cast opcode from the types of the operands.
const char *opcode = getCastOpcode($3.type, $5);
const char *opcode = $1->c_str();
if (*$1 == "cast")
opcode = getCastOpcode($3.type, $5);
$$ = new std::string(opcode);
*$$ += "(" + *$3.cnst + " " + *$4 + " " + *$5.newTy + ")";
delete $1; $3.destroy(); delete $4; $5.destroy();
@ -976,8 +982,10 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
*$$ += " " + *$2.val + ", " + *$4.val;
delete $1; $2.destroy(); $4.destroy();
}
| CAST ResolvedVal TO Types {
const char *opcode = getCastOpcode($2.type, $4);
| CastOps ResolvedVal TO Types {
const char *opcode = $1->c_str();
if (*$1 == "cast")
opcode = getCastOpcode($2.type, $4);
$$ = new std::string(opcode);
*$$ += *$2.val + " " + *$3 + " " + *$4.newTy;
delete $1; $2.destroy();

View File

@ -155,7 +155,8 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
%token <String> MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR
%token <String> PHI_TOK SELECT SHL SHR ASHR LSHR VAARG
%token <String> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
%token <String> CAST
%token <String> CAST TRUNC ZEXT SEXT FPTRUNC FPEXT FPTOUI FPTOSI UITOFP SITOFP
%token <String> PTRTOINT INTTOPTR BITCAST
%type <String> OptAssign OptLinkage OptCallingConv OptAlign OptCAlign
%type <String> SectionString OptSection GlobalVarAttributes GlobalVarAttribute
@ -167,8 +168,8 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
%type <String> ValueRefList OptTailCall InstVal IndexList OptVolatile
%type <String> MemoryInst SymbolicValueRef OptSideEffect GlobalType
%type <String> FnDeclareLinkage BasicBlockList BigOrLittle AsmBlock
%type <String> Name ValueRef ValueRefListE
%type <String> ShiftOps SetCondOps LogicalOps ArithmeticOps ConstValueRef
%type <String> Name ValueRef ValueRefListE ConstValueRef
%type <String> ShiftOps SetCondOps LogicalOps ArithmeticOps CastOps
%type <String> ConstVector
@ -194,6 +195,9 @@ ArithmeticOps: ADD | SUB | MUL | UDIV | SDIV | FDIV | UREM | SREM | FREM;
LogicalOps : AND | OR | XOR;
SetCondOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE;
ShiftOps : SHL | SHR | ASHR | LSHR;
CastOps : TRUNC | ZEXT | SEXT | FPTRUNC | FPEXT | FPTOUI | FPTOSI |
UITOFP | SITOFP | PTRTOINT | INTTOPTR | BITCAST | CAST
;
// These are some types that allow classification if we only want a particular
// thing... for example, only a signed, unsigned, or integral type.
@ -462,9 +466,11 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
};
ConstExpr: CAST '(' ConstVal TO Types ')' {
ConstExpr: CastOps '(' ConstVal TO Types ')' {
// We must infer the cast opcode from the types of the operands.
const char *opcode = getCastOpcode($3.type, $5);
const char *opcode = $1->c_str();
if (*$1 == "cast")
opcode = getCastOpcode($3.type, $5);
$$ = new std::string(opcode);
*$$ += "(" + *$3.cnst + " " + *$4 + " " + *$5.newTy + ")";
delete $1; $3.destroy(); delete $4; $5.destroy();
@ -976,8 +982,10 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
*$$ += " " + *$2.val + ", " + *$4.val;
delete $1; $2.destroy(); $4.destroy();
}
| CAST ResolvedVal TO Types {
const char *opcode = getCastOpcode($2.type, $4);
| CastOps ResolvedVal TO Types {
const char *opcode = $1->c_str();
if (*$1 == "cast")
opcode = getCastOpcode($2.type, $4);
$$ = new std::string(opcode);
*$$ += *$2.val + " " + *$3 + " " + *$4.newTy;
delete $1; $2.destroy();