aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-04-08 04:08:32 +0000
committerChris Lattner <sabre@nondot.org>2006-04-08 04:08:32 +0000
commit2d7349a62d7853ba749a6f44d91778450197c8aa (patch)
tree0829a3f680da0b7d3386ffa89764f7d76a739ec9
parent1cbe05b20845f5085953e293797fbbd1afbf5471 (diff)
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
-rw-r--r--lib/AsmParser/llvmAsmParser.y27
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index d95ea31beb..cf746007a2 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -1541,14 +1541,13 @@ ConstExpr: CAST '(' ConstVal TO Types ')' {
$$ = ConstantExpr::get($1, $3, $5);
}
| EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' {
- if (!isa<PackedType>($3->getType()))
- ThrowException("First operand of extractelement must be "
- "packed type!");
- if ($5->getType() != Type::UIntTy)
- ThrowException("Second operand of extractelement must be uint!");
+ if (!ExtractElementInst::isValidOperands($3, $5))
+ ThrowException("Invalid extractelement operands!");
$$ = ConstantExpr::getExtractElement($3, $5);
}
| INSERTELEMENT '(' ConstVal ',' ConstVal ',' ConstVal ')' {
+ if (!InsertElementInst::isValidOperands($3, $5, $7))
+ ThrowException("Invalid insertelement operands!");
$$ = ConstantExpr::getInsertElement($3, $5, $7);
}
| SHUFFLEVECTOR '(' ConstVal ',' ConstVal ',' ConstVal ')' {
@@ -2250,23 +2249,13 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
delete $4;
}
| EXTRACTELEMENT ResolvedVal ',' ResolvedVal {
- if (!isa<PackedType>($2->getType()))
- ThrowException("First operand of extractelement must be "
- "packed type!");
- if ($4->getType() != Type::UIntTy)
- ThrowException("Second operand of extractelement must be uint!");
+ if (!ExtractElementInst::isValidOperands($2, $4))
+ ThrowException("Invalid extractelement operands!");
$$ = new ExtractElementInst($2, $4);
}
| INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
- if (!isa<PackedType>($2->getType()))
- ThrowException("First operand of insertelement must be "
- "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!");
+ if (!InsertElementInst::isValidOperands($2, $4, $6))
+ ThrowException("Invalid insertelement operands!");
$$ = new InsertElementInst($2, $4, $6);
}
| SHUFFLEVECTOR ResolvedVal ',' ResolvedVal ',' ResolvedVal {