Use isValidOperands instead of duplicating or eliding checks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27525 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-04-08 04:08:32 +00:00
parent 1cbe05b208
commit 2d7349a62d

View File

@ -1541,14 +1541,13 @@ ConstExpr: CAST '(' ConstVal TO Types ')' {
$$ = ConstantExpr::get($1, $3, $5); $$ = ConstantExpr::get($1, $3, $5);
} }
| EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' { | EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' {
if (!isa<PackedType>($3->getType())) if (!ExtractElementInst::isValidOperands($3, $5))
ThrowException("First operand of extractelement must be " ThrowException("Invalid extractelement operands!");
"packed type!");
if ($5->getType() != Type::UIntTy)
ThrowException("Second operand of extractelement must be uint!");
$$ = ConstantExpr::getExtractElement($3, $5); $$ = ConstantExpr::getExtractElement($3, $5);
} }
| INSERTELEMENT '(' ConstVal ',' ConstVal ',' ConstVal ')' { | INSERTELEMENT '(' ConstVal ',' ConstVal ',' ConstVal ')' {
if (!InsertElementInst::isValidOperands($3, $5, $7))
ThrowException("Invalid insertelement operands!");
$$ = ConstantExpr::getInsertElement($3, $5, $7); $$ = ConstantExpr::getInsertElement($3, $5, $7);
} }
| SHUFFLEVECTOR '(' ConstVal ',' ConstVal ',' ConstVal ')' { | SHUFFLEVECTOR '(' ConstVal ',' ConstVal ',' ConstVal ')' {
@ -2250,23 +2249,13 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
delete $4; delete $4;
} }
| EXTRACTELEMENT ResolvedVal ',' ResolvedVal { | EXTRACTELEMENT ResolvedVal ',' ResolvedVal {
if (!isa<PackedType>($2->getType())) if (!ExtractElementInst::isValidOperands($2, $4))
ThrowException("First operand of extractelement must be " ThrowException("Invalid extractelement operands!");
"packed type!");
if ($4->getType() != Type::UIntTy)
ThrowException("Second operand of extractelement must be uint!");
$$ = new ExtractElementInst($2, $4); $$ = new ExtractElementInst($2, $4);
} }
| INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal { | INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
if (!isa<PackedType>($2->getType())) if (!InsertElementInst::isValidOperands($2, $4, $6))
ThrowException("First operand of insertelement must be " ThrowException("Invalid insertelement operands!");
"packed type!");
if ($4->getType() !=
cast<PackedType>($2->getType())->getElementType())
ThrowException("Second operand of insertelement must be "
"packed element type!");
if ($6->getType() != Type::UIntTy)
ThrowException("Third operand of insertelement must be uint!");
$$ = new InsertElementInst($2, $4, $6); $$ = new InsertElementInst($2, $4, $6);
} }
| SHUFFLEVECTOR ResolvedVal ',' ResolvedVal ',' ResolvedVal { | SHUFFLEVECTOR ResolvedVal ',' ResolvedVal ',' ResolvedVal {