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

Reid Spencer reid at x10sys.com
Wed Nov 1 17:54:34 PST 2006



Changes in directory llvm/lib/AsmParser:

Lexer.l updated: 1.80 -> 1.81
llvmAsmParser.y updated: 1.271 -> 1.272
---
Log message:

For PR950: http://llvm.org/PR950 :
Replace the REM instruction with UREM, SREM and FREM.


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

 Lexer.l         |    5 ++++-
 llvmAsmParser.y |   22 +++++++++++++++-------
 2 files changed, 19 insertions(+), 8 deletions(-)


Index: llvm/lib/AsmParser/Lexer.l
diff -u llvm/lib/AsmParser/Lexer.l:1.80 llvm/lib/AsmParser/Lexer.l:1.81
--- llvm/lib/AsmParser/Lexer.l:1.80	Thu Oct 26 01:15:43 2006
+++ llvm/lib/AsmParser/Lexer.l	Wed Nov  1 19:53:58 2006
@@ -261,7 +261,10 @@
 udiv            { RET_TOK(BinaryOpVal, UDiv, UDIV); }
 sdiv            { RET_TOK(BinaryOpVal, SDiv, SDIV); }
 fdiv            { RET_TOK(BinaryOpVal, FDiv, FDIV); }
-rem             { RET_TOK(BinaryOpVal, Rem, REM); }
+rem             { RET_TOK_OBSOLETE(BinaryOpVal, URem, UREM); }
+urem            { RET_TOK(BinaryOpVal, URem, UREM); }
+srem            { RET_TOK(BinaryOpVal, SRem, SREM); }
+frem            { RET_TOK(BinaryOpVal, FRem, FREM); }
 and             { RET_TOK(BinaryOpVal, And, AND); }
 or              { RET_TOK(BinaryOpVal, Or , OR ); }
 xor             { RET_TOK(BinaryOpVal, Xor, XOR); }


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.271 llvm/lib/AsmParser/llvmAsmParser.y:1.272
--- llvm/lib/AsmParser/llvmAsmParser.y:1.271	Thu Oct 26 01:15:43 2006
+++ llvm/lib/AsmParser/llvmAsmParser.y	Wed Nov  1 19:53:58 2006
@@ -836,7 +836,7 @@
   // Depending on the opcode ..
   switch (OI.opcode) {
     default:
-      GenerateError("Invalid Obsolete OpCode");
+      GenerateError("Invalid obsolete opCode (check Lexer.l)");
       break;
     case Instruction::UDiv:
       // Handle cases where the opcode needs to change
@@ -845,12 +845,17 @@
       else if (Ty->isSigned())
         OI.opcode = Instruction::SDiv;
       break;
+    case Instruction::URem:
+      if (Ty->isFloatingPoint()) 
+        OI.opcode = Instruction::FRem;
+      else if (Ty->isSigned())
+        OI.opcode = Instruction::SRem;
+      break;
   }
   // Its not obsolete any more, we fixed it.
   OI.obsolete = false;
 }
-
-
+  
 // common code from the two 'RunVMAsmParser' functions
 static Module* RunParser(Module * M) {
 
@@ -1113,7 +1118,7 @@
 
 // Binary Operators
 %type  <BinaryOpVal> ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories
-%token <BinaryOpVal> ADD SUB MUL UDIV SDIV FDIV REM AND OR XOR
+%token <BinaryOpVal> ADD SUB MUL UDIV SDIV FDIV UREM SREM FREM AND OR XOR
 %token <BinaryOpVal> SETLE SETGE SETLT SETGT SETEQ SETNE  // Binary Comparators
 
 // Memory Instructions
@@ -1151,7 +1156,7 @@
 // Operations that are notably excluded from this list include:
 // RET, BR, & SWITCH because they end basic blocks and are treated specially.
 //
-ArithmeticOps: ADD | SUB | MUL | UDIV | SDIV | FDIV | REM ;
+ArithmeticOps: ADD | SUB | MUL | UDIV | SDIV | FDIV | UREM | SREM | FREM;
 LogicalOps   : AND | OR | XOR;
 SetCondOps   : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE;
 
@@ -2465,8 +2470,11 @@
         !isa<PackedType>((*$2).get()))
       GEN_ERROR(
         "Arithmetic operator requires integer, FP, or packed operands!");
-    if (isa<PackedType>((*$2).get()) && $1.opcode == Instruction::Rem)
-      GEN_ERROR("Rem not supported on packed types!");
+    if (isa<PackedType>((*$2).get()) && 
+        ($1.opcode == Instruction::URem || 
+         $1.opcode == Instruction::SRem ||
+         $1.opcode == Instruction::FRem))
+      GEN_ERROR("U/S/FRem not supported on packed types!");
     // Upgrade the opcode from obsolete versions before we do anything with it.
     sanitizeOpCode($1,*$2);
     CHECK_FOR_ERROR;






More information about the llvm-commits mailing list