summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-12 05:51:36 +0000
committerChris Lattner <sabre@nondot.org>2004-03-12 05:51:36 +0000
commit6536f0c35f5014c2ad56eeb71d32719aab2cda13 (patch)
tree24524d2c430138e86b253e97d783f9fcfa7e095c /llvm/lib
parent26cca63a7e205218909a5cb1801702211f76fe78 (diff)
downloadbcm5719-llvm-6536f0c35f5014c2ad56eeb71d32719aab2cda13.tar.gz
bcm5719-llvm-6536f0c35f5014c2ad56eeb71d32719aab2cda13.zip
Allow parsing select instruction and constant expr
llvm-svn: 12313
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/AsmParser/Lexer.l1
-rw-r--r--llvm/lib/AsmParser/llvmAsmParser.y16
2 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/Lexer.l b/llvm/lib/AsmParser/Lexer.l
index 999a5762998..c2db5a26348 100644
--- a/llvm/lib/AsmParser/Lexer.l
+++ b/llvm/lib/AsmParser/Lexer.l
@@ -234,6 +234,7 @@ setge { RET_TOK(BinaryOpVal, SetGE, SETGE); }
phi { RET_TOK(OtherOpVal, PHI, PHI_TOK); }
call { RET_TOK(OtherOpVal, Call, CALL); }
cast { RET_TOK(OtherOpVal, Cast, CAST); }
+select { RET_TOK(OtherOpVal, Select, SELECT); }
shl { RET_TOK(OtherOpVal, Shl, SHL); }
shr { RET_TOK(OtherOpVal, Shr, SHR); }
va_arg { return VA_ARG; /* FIXME: OBSOLETE */}
diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y
index 9c68cfca5d2..2868fdd1b34 100644
--- a/llvm/lib/AsmParser/llvmAsmParser.y
+++ b/llvm/lib/AsmParser/llvmAsmParser.y
@@ -876,7 +876,7 @@ using namespace llvm;
// Other Operators
%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
%start Module
@@ -1251,6 +1251,13 @@ ConstExpr: CAST '(' ConstVal TO Types ')' {
$$ = 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 ')' {
if ($3->getType() != $5->getType())
ThrowException("Binary operator types must match!");
@@ -1802,6 +1809,13 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
$$ = new CastInst($2, *$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 {
// FIXME: This is emulation code for an obsolete syntax. This should be
// removed at some point.
OpenPOWER on IntegriCloud