mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-21 16:25:23 +00:00
Allow parsing select instruction and constant expr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12313 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -234,6 +234,7 @@ setge { RET_TOK(BinaryOpVal, SetGE, SETGE); }
|
|||||||
phi { RET_TOK(OtherOpVal, PHI, PHI_TOK); }
|
phi { RET_TOK(OtherOpVal, PHI, PHI_TOK); }
|
||||||
call { RET_TOK(OtherOpVal, Call, CALL); }
|
call { RET_TOK(OtherOpVal, Call, CALL); }
|
||||||
cast { RET_TOK(OtherOpVal, Cast, CAST); }
|
cast { RET_TOK(OtherOpVal, Cast, CAST); }
|
||||||
|
select { RET_TOK(OtherOpVal, Select, SELECT); }
|
||||||
shl { RET_TOK(OtherOpVal, Shl, SHL); }
|
shl { RET_TOK(OtherOpVal, Shl, SHL); }
|
||||||
shr { RET_TOK(OtherOpVal, Shr, SHR); }
|
shr { RET_TOK(OtherOpVal, Shr, SHR); }
|
||||||
va_arg { return VA_ARG; /* FIXME: OBSOLETE */}
|
va_arg { return VA_ARG; /* FIXME: OBSOLETE */}
|
||||||
|
@@ -876,7 +876,7 @@ using namespace llvm;
|
|||||||
|
|
||||||
// Other Operators
|
// Other Operators
|
||||||
%type <OtherOpVal> ShiftOps
|
%type <OtherOpVal> ShiftOps
|
||||||
%token <OtherOpVal> PHI_TOK CALL CAST SHL SHR VAARG VANEXT
|
%token <OtherOpVal> PHI_TOK CALL CAST SELECT SHL SHR VAARG VANEXT
|
||||||
%token VA_ARG // FIXME: OBSOLETE
|
%token VA_ARG // FIXME: OBSOLETE
|
||||||
|
|
||||||
%start Module
|
%start Module
|
||||||
@@ -1251,6 +1251,13 @@ ConstExpr: CAST '(' ConstVal TO Types ')' {
|
|||||||
|
|
||||||
$$ = ConstantExpr::getGetElementPtr($3, IdxVec);
|
$$ = ConstantExpr::getGetElementPtr($3, IdxVec);
|
||||||
}
|
}
|
||||||
|
| SELECT '(' ConstVal ',' ConstVal ',' ConstVal ')' {
|
||||||
|
if ($3->getType() != Type::BoolTy)
|
||||||
|
ThrowException("Select condition must be of boolean type!");
|
||||||
|
if ($5->getType() != $7->getType())
|
||||||
|
ThrowException("Select operand types must match!");
|
||||||
|
$$ = ConstantExpr::getSelect($3, $5, $7);
|
||||||
|
}
|
||||||
| BinaryOps '(' ConstVal ',' ConstVal ')' {
|
| BinaryOps '(' ConstVal ',' ConstVal ')' {
|
||||||
if ($3->getType() != $5->getType())
|
if ($3->getType() != $5->getType())
|
||||||
ThrowException("Binary operator types must match!");
|
ThrowException("Binary operator types must match!");
|
||||||
@@ -1802,6 +1809,13 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
|||||||
$$ = new CastInst($2, *$4);
|
$$ = new CastInst($2, *$4);
|
||||||
delete $4;
|
delete $4;
|
||||||
}
|
}
|
||||||
|
| SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
|
||||||
|
if ($2->getType() != Type::BoolTy)
|
||||||
|
ThrowException("select condition must be boolean!");
|
||||||
|
if ($4->getType() != $6->getType())
|
||||||
|
ThrowException("select value types should match!");
|
||||||
|
$$ = new SelectInst($2, $4, $6);
|
||||||
|
}
|
||||||
| VA_ARG ResolvedVal ',' Types {
|
| VA_ARG ResolvedVal ',' Types {
|
||||||
// FIXME: This is emulation code for an obsolete syntax. This should be
|
// FIXME: This is emulation code for an obsolete syntax. This should be
|
||||||
// removed at some point.
|
// removed at some point.
|
||||||
|
Reference in New Issue
Block a user