[llvm-commits] CVS: llvm/include/llvm/Constants.h Instruction.def Instructions.h

Reid Spencer reid at x10sys.com
Tue Nov 7 22:48:17 PST 2006



Changes in directory llvm/include/llvm:

Constants.h updated: 1.93 -> 1.94
Instruction.def updated: 1.21 -> 1.22
Instructions.h updated: 1.44 -> 1.45
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch converts the old SHR instruction into two instructions, 
AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not
dependent on the sign of their operands.


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

 Constants.h     |    6 ++----
 Instruction.def |   25 +++++++++++++------------
 Instructions.h  |   12 +++++++++---
 3 files changed, 24 insertions(+), 19 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.93 llvm/include/llvm/Constants.h:1.94
--- llvm/include/llvm/Constants.h:1.93	Wed Nov  1 19:53:58 2006
+++ llvm/include/llvm/Constants.h	Wed Nov  8 00:47:32 2006
@@ -564,10 +564,8 @@
   static Constant *getSetLE(Constant *C1, Constant *C2);
   static Constant *getSetGE(Constant *C1, Constant *C2);
   static Constant *getShl(Constant *C1, Constant *C2);
-  static Constant *getShr(Constant *C1, Constant *C2);
-
-  static Constant *getUShr(Constant *C1, Constant *C2); // unsigned shr
-  static Constant *getSShr(Constant *C1, Constant *C2); // signed shr
+  static Constant *getLShr(Constant *C1, Constant *C2);
+  static Constant *getAShr(Constant *C1, Constant *C2);
 
   /// Getelementptr form.  std::vector<Value*> is only accepted for convenience:
   /// all elements must be Constant's.


Index: llvm/include/llvm/Instruction.def
diff -u llvm/include/llvm/Instruction.def:1.21 llvm/include/llvm/Instruction.def:1.22
--- llvm/include/llvm/Instruction.def:1.21	Wed Nov  1 19:53:58 2006
+++ llvm/include/llvm/Instruction.def	Wed Nov  8 00:47:32 2006
@@ -15,8 +15,8 @@
 
 // NOTE: NO INCLUDE GUARD DESIRED!
 
-// Provide definitions of macros so that users of this file do not have to define
-// everything to use it...
+// Provide definitions of macros so that users of this file do not have to 
+// define everything to use it...
 //
 #ifndef FIRST_TERM_INST
 #define FIRST_TERM_INST(num)
@@ -129,16 +129,17 @@
 HANDLE_OTHER_INST(31, PHI    , PHINode    )  // PHI node instruction
 HANDLE_OTHER_INST(32, Cast   , CastInst   )  // Type cast
 HANDLE_OTHER_INST(33, Call   , CallInst   )  // Call a function
-HANDLE_OTHER_INST(34, Shl    , ShiftInst  )  // Shift operations
-HANDLE_OTHER_INST(35, Shr    , ShiftInst  )
-HANDLE_OTHER_INST(36, Select , SelectInst )  // select instruction
-HANDLE_OTHER_INST(37, UserOp1, Instruction)  // May be used internally in a pass
-HANDLE_OTHER_INST(38, UserOp2, Instruction)
-HANDLE_OTHER_INST(39, VAArg  , VAArgInst  )  // vaarg instruction
-HANDLE_OTHER_INST(40, ExtractElement, ExtractElementInst)// extract from vector.
-HANDLE_OTHER_INST(41, InsertElement, InsertElementInst)  // insert into vector
-HANDLE_OTHER_INST(42, ShuffleVector, ShuffleVectorInst)  // shuffle two vectors.
-  LAST_OTHER_INST(42)
+HANDLE_OTHER_INST(34, Shl    , ShiftInst  )  // Shift Left operations (logical)
+HANDLE_OTHER_INST(35, LShr   , ShiftInst  )  // Logical Shift right (unsigned) 
+HANDLE_OTHER_INST(36, AShr   , ShiftInst  )  // Arithmetic shift right (signed)
+HANDLE_OTHER_INST(37, Select , SelectInst )  // select instruction
+HANDLE_OTHER_INST(38, UserOp1, Instruction)  // May be used internally in a pass
+HANDLE_OTHER_INST(39, UserOp2, Instruction)  // Internal to passes only
+HANDLE_OTHER_INST(40, VAArg  , VAArgInst  )  // vaarg instruction
+HANDLE_OTHER_INST(41, ExtractElement, ExtractElementInst)// extract from vector.
+HANDLE_OTHER_INST(42, InsertElement, InsertElementInst)  // insert into vector
+HANDLE_OTHER_INST(43, ShuffleVector, ShuffleVectorInst)  // shuffle two vectors.
+  LAST_OTHER_INST(43)
 
 #undef  FIRST_TERM_INST
 #undef HANDLE_TERM_INST


Index: llvm/include/llvm/Instructions.h
diff -u llvm/include/llvm/Instructions.h:1.44 llvm/include/llvm/Instructions.h:1.45
--- llvm/include/llvm/Instructions.h:1.44	Thu Oct  5 01:24:58 2006
+++ llvm/include/llvm/Instructions.h	Wed Nov  8 00:47:32 2006
@@ -604,7 +604,8 @@
     Ops[1].init(SI.Ops[1], this);
   }
   void init(OtherOps Opcode, Value *S, Value *SA) {
-    assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
+    assert((Opcode == Shl || Opcode == LShr || Opcode == AShr) && 
+      "ShiftInst Opcode invalid!");
     Ops[0].init(S, this);
     Ops[1].init(SA, this);
   }
@@ -638,7 +639,11 @@
 
   /// isLogicalShift - Return true if this is a logical shift left or a logical
   /// shift right.
-  bool isLogicalShift() const;
+  bool isLogicalShift() const {
+    unsigned opcode = getOpcode();
+    return opcode == Instruction::Shl || opcode == Instruction::LShr;
+  }
+
 
   /// isArithmeticShift - Return true if this is a sign-extending shift right
   /// operation.
@@ -652,7 +657,8 @@
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ShiftInst *) { return true; }
   static inline bool classof(const Instruction *I) {
-    return (I->getOpcode() == Instruction::Shr) |
+    return (I->getOpcode() == Instruction::LShr) |
+           (I->getOpcode() == Instruction::AShr) |
            (I->getOpcode() == Instruction::Shl);
   }
   static inline bool classof(const Value *V) {






More information about the llvm-commits mailing list