[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y

Chris Lattner lattner at cs.uiuc.edu
Fri Apr 7 21:08:45 PDT 2006



Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.252 -> 1.253
---
Log message:

Use isValidOperands instead of duplicating or eliding checks.


---
Diffs of the changes:  (+8 -19)

 llvmAsmParser.y |   27 ++++++++-------------------
 1 files changed, 8 insertions(+), 19 deletions(-)


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.252 llvm/lib/AsmParser/llvmAsmParser.y:1.253
--- llvm/lib/AsmParser/llvmAsmParser.y:1.252	Fri Apr  7 22:53:34 2006
+++ llvm/lib/AsmParser/llvmAsmParser.y	Fri Apr  7 23:08:32 2006
@@ -1541,14 +1541,13 @@
     $$ = 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 @@
     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 {






More information about the llvm-commits mailing list