[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Chris Lattner
lattner at cs.uiuc.edu
Tue Sep 10 14:58:00 PDT 2002
Changes in directory llvm/lib/AsmParser:
llvmAsmParser.y updated: 1.89 -> 1.90
---
Log message:
Tighten up error checking in parser, disallowing instructions that f.e.,
add pointers together.
---
Diffs of the changes:
Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.89 llvm/lib/AsmParser/llvmAsmParser.y:1.90
--- llvm/lib/AsmParser/llvmAsmParser.y:1.89 Thu Aug 22 17:48:51 2002
+++ llvm/lib/AsmParser/llvmAsmParser.y Tue Sep 10 14:57:26 2002
@@ -686,6 +686,7 @@
// Binary Operators
%type <BinaryOpVal> BinaryOps // all the binary operators
+%type <BinaryOpVal> ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories
%token <BinaryOpVal> ADD SUB MUL DIV REM AND OR XOR
%token <BinaryOpVal> SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comarators
@@ -720,8 +721,11 @@
// Operations that are notably excluded from this list include:
// RET, BR, & SWITCH because they end basic blocks and are treated specially.
//
-BinaryOps : ADD | SUB | MUL | DIV | REM | AND | OR | XOR;
-BinaryOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE;
+ArithmeticOps: ADD | SUB | MUL | DIV | REM;
+LogicalOps : AND | OR | XOR;
+SetCondOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE;
+BinaryOps : ArithmeticOps | LogicalOps | SetCondOps;
+
ShiftOps : SHL | SHR;
// These are some types that allow classification if we only want a particular
@@ -1507,7 +1511,23 @@
// ValueRefListE - Just like ValueRefList, except that it may also be empty!
ValueRefListE : ValueRefList | /*empty*/ { $$ = 0; };
-InstVal : BinaryOps Types ValueRef ',' ValueRef {
+InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
+ if (!(*$2)->isInteger() && !(*$2)->isFloatingPoint())
+ ThrowException("Arithmetic operator requires integer or FP operands!");
+ $$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5));
+ if ($$ == 0)
+ ThrowException("binary operator returned null!");
+ delete $2;
+ }
+ | LogicalOps Types ValueRef ',' ValueRef {
+ if (!(*$2)->isIntegral())
+ ThrowException("Logical operator requires integral operands!");
+ $$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5));
+ if ($$ == 0)
+ ThrowException("binary operator returned null!");
+ delete $2;
+ }
+ | SetCondOps Types ValueRef ',' ValueRef {
$$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5));
if ($$ == 0)
ThrowException("binary operator returned null!");
More information about the llvm-commits
mailing list