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

Chris Lattner lattner at cs.uiuc.edu
Thu Mar 11 23:52:32 PST 2004


Changes in directory llvm/lib/AsmParser:

Lexer.l updated: 1.45 -> 1.46
llvmAsmParser.y updated: 1.158 -> 1.159

---
Log message:

Allow parsing select instruction and constant expr



---
Diffs of the changes:  (+16 -1)

Index: llvm/lib/AsmParser/Lexer.l
diff -u llvm/lib/AsmParser/Lexer.l:1.45 llvm/lib/AsmParser/Lexer.l:1.46
--- llvm/lib/AsmParser/Lexer.l:1.45	Sun Feb  8 15:48:25 2004
+++ llvm/lib/AsmParser/Lexer.l	Thu Mar 11 23:51:36 2004
@@ -234,6 +234,7 @@
 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 */}


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.158 llvm/lib/AsmParser/llvmAsmParser.y:1.159
--- llvm/lib/AsmParser/llvmAsmParser.y:1.158	Mon Mar  8 10:14:19 2004
+++ llvm/lib/AsmParser/llvmAsmParser.y	Thu Mar 11 23:51:36 2004
@@ -876,7 +876,7 @@
 
 // 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 @@
 
     $$ = 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!");
@@ -1801,6 +1808,13 @@
                      $4->get()->getDescription() + "'!");
     $$ = 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





More information about the llvm-commits mailing list