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

Reid Spencer reid at x10sys.com
Thu Feb 1 18:17:37 PST 2007



Changes in directory llvm/include/llvm:

Constants.h updated: 1.122 -> 1.123
Instruction.def updated: 1.28 -> 1.29
Instruction.h updated: 1.78 -> 1.79
Instructions.h updated: 1.52 -> 1.53
---
Log message:

Changes to support making the shift instructions be true BinaryOperators.
This feature is needed in order to support shifts of more than 255 bits
on large integer types.  This changes the syntax for llvm assembly to 
make shl, ashr and lshr instructions look like a binary operator:
   shl i32 %X, 1
instead of
   shl i32 %X, i8 1
Additionally, this should help a few passes perform additional optimizations.


---
Diffs of the changes:  (+56 -114)

 Constants.h     |    2 -
 Instruction.def |   70 +++++++++++++++++++++++++-------------------------
 Instruction.h   |   21 +++++++++++++++
 Instructions.h  |   77 --------------------------------------------------------
 4 files changed, 56 insertions(+), 114 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.122 llvm/include/llvm/Constants.h:1.123
--- llvm/include/llvm/Constants.h:1.122	Tue Jan 30 22:39:29 2007
+++ llvm/include/llvm/Constants.h	Thu Feb  1 20:16:21 2007
@@ -442,8 +442,6 @@
                          Constant *C1, Constant *C2);
   static Constant *getCompareTy(unsigned short pred, Constant *C1, 
                                 Constant *C2);
-  static Constant *getShiftTy(const Type *Ty,
-                              unsigned Opcode, Constant *C1, Constant *C2);
   static Constant *getSelectTy(const Type *Ty,
                                Constant *C1, Constant *C2, Constant *C3);
   static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,


Index: llvm/include/llvm/Instruction.def
diff -u llvm/include/llvm/Instruction.def:1.28 llvm/include/llvm/Instruction.def:1.29
--- llvm/include/llvm/Instruction.def:1.28	Sat Dec 23 00:05:40 2006
+++ llvm/include/llvm/Instruction.def	Thu Feb  1 20:16:21 2007
@@ -114,49 +114,49 @@
 HANDLE_BINARY_INST(14, SRem , BinaryOperator)
 HANDLE_BINARY_INST(15, FRem , BinaryOperator)
 
-// Logical operators...
-HANDLE_BINARY_INST(16, And   , BinaryOperator)
-HANDLE_BINARY_INST(17, Or    , BinaryOperator)
-HANDLE_BINARY_INST(18, Xor   , BinaryOperator)
-  LAST_BINARY_INST(18)
+// Logical operators (integer operands)
+HANDLE_BINARY_INST(16, Shl  , BinaryOperator) // Shift left  (logical)
+HANDLE_BINARY_INST(17, LShr , BinaryOperator) // Shift right (logical) 
+HANDLE_BINARY_INST(18, AShr , BinaryOperator) // shift right (arithmetic)
+HANDLE_BINARY_INST(19, And  , BinaryOperator)
+HANDLE_BINARY_INST(20, Or   , BinaryOperator)
+HANDLE_BINARY_INST(21, Xor  , BinaryOperator)
+  LAST_BINARY_INST(21)
 
 // Memory operators...
- FIRST_MEMORY_INST(19)
-HANDLE_MEMORY_INST(19, Malloc, MallocInst)  // Heap management instructions
-HANDLE_MEMORY_INST(20, Free  , FreeInst  )
-HANDLE_MEMORY_INST(21, Alloca, AllocaInst)  // Stack management
-HANDLE_MEMORY_INST(22, Load  , LoadInst  )  // Memory manipulation instrs
-HANDLE_MEMORY_INST(23, Store , StoreInst )
-HANDLE_MEMORY_INST(24, GetElementPtr, GetElementPtrInst)
-  LAST_MEMORY_INST(24)
+ FIRST_MEMORY_INST(22)
+HANDLE_MEMORY_INST(22, Malloc, MallocInst)  // Heap management instructions
+HANDLE_MEMORY_INST(23, Free  , FreeInst  )
+HANDLE_MEMORY_INST(24, Alloca, AllocaInst)  // Stack management
+HANDLE_MEMORY_INST(25, Load  , LoadInst  )  // Memory manipulation instrs
+HANDLE_MEMORY_INST(26, Store , StoreInst )
+HANDLE_MEMORY_INST(27, GetElementPtr, GetElementPtrInst)
+  LAST_MEMORY_INST(27)
 
 // Cast operators ...
 // NOTE: The order matters here because CastInst::isEliminableCastPair 
 // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
- FIRST_CAST_INST(25)
-HANDLE_CAST_INST(25, Trunc   , TruncInst   )  // Truncate integers
-HANDLE_CAST_INST(26, ZExt    , ZExtInst    )  // Zero extend integers
-HANDLE_CAST_INST(27, SExt    , SExtInst    )  // Sign extend integers
-HANDLE_CAST_INST(28, FPToUI  , FPToUIInst  )  // floating point -> UInt
-HANDLE_CAST_INST(29, FPToSI  , FPToSIInst  )  // floating point -> SInt
-HANDLE_CAST_INST(30, UIToFP  , UIToFPInst  )  // UInt -> floating point
-HANDLE_CAST_INST(31, SIToFP  , SIToFPInst  )  // SInt -> floating point
-HANDLE_CAST_INST(32, FPTrunc , FPTruncInst )  // Truncate floating point
-HANDLE_CAST_INST(33, FPExt   , FPExtInst   )  // Extend floating point
-HANDLE_CAST_INST(34, PtrToInt, PtrToIntInst)  // Pointer -> Integer
-HANDLE_CAST_INST(35, IntToPtr, IntToPtrInst)  // Integer -> Pointer
-HANDLE_CAST_INST(36, BitCast , BitCastInst )  // Type cast
-  LAST_CAST_INST(36)
+ FIRST_CAST_INST(28)
+HANDLE_CAST_INST(28, Trunc   , TruncInst   )  // Truncate integers
+HANDLE_CAST_INST(29, ZExt    , ZExtInst    )  // Zero extend integers
+HANDLE_CAST_INST(30, SExt    , SExtInst    )  // Sign extend integers
+HANDLE_CAST_INST(31, FPToUI  , FPToUIInst  )  // floating point -> UInt
+HANDLE_CAST_INST(32, FPToSI  , FPToSIInst  )  // floating point -> SInt
+HANDLE_CAST_INST(33, UIToFP  , UIToFPInst  )  // UInt -> floating point
+HANDLE_CAST_INST(34, SIToFP  , SIToFPInst  )  // SInt -> floating point
+HANDLE_CAST_INST(35, FPTrunc , FPTruncInst )  // Truncate floating point
+HANDLE_CAST_INST(36, FPExt   , FPExtInst   )  // Extend floating point
+HANDLE_CAST_INST(37, PtrToInt, PtrToIntInst)  // Pointer -> Integer
+HANDLE_CAST_INST(38, IntToPtr, IntToPtrInst)  // Integer -> Pointer
+HANDLE_CAST_INST(39, BitCast , BitCastInst )  // Type cast
+  LAST_CAST_INST(39)
 
 // Other operators...
- FIRST_OTHER_INST(37)
-HANDLE_OTHER_INST(37, ICmp   , ICmpInst   )  // Integer comparison instruction
-HANDLE_OTHER_INST(38, FCmp   , FCmpInst   )  // Floating point comparison instr.
-HANDLE_OTHER_INST(39, PHI    , PHINode    )  // PHI node instruction
-HANDLE_OTHER_INST(40, Call   , CallInst   )  // Call a function
-HANDLE_OTHER_INST(41, Shl    , ShiftInst  )  // Shift Left operations (logical)
-HANDLE_OTHER_INST(42, LShr   , ShiftInst  )  // Logical Shift right (unsigned) 
-HANDLE_OTHER_INST(43, AShr   , ShiftInst  )  // Arithmetic shift right (signed)
+ FIRST_OTHER_INST(40)
+HANDLE_OTHER_INST(40, ICmp   , ICmpInst   )  // Integer comparison instruction
+HANDLE_OTHER_INST(41, FCmp   , FCmpInst   )  // Floating point comparison instr.
+HANDLE_OTHER_INST(42, PHI    , PHINode    )  // PHI node instruction
+HANDLE_OTHER_INST(43, Call   , CallInst   )  // Call a function
 HANDLE_OTHER_INST(44, Select , SelectInst )  // select instruction
 HANDLE_OTHER_INST(45, UserOp1, Instruction)  // May be used internally in a pass
 HANDLE_OTHER_INST(46, UserOp2, Instruction)  // Internal to passes only


Index: llvm/include/llvm/Instruction.h
diff -u llvm/include/llvm/Instruction.h:1.78 llvm/include/llvm/Instruction.h:1.79
--- llvm/include/llvm/Instruction.h:1.78	Wed Jan  3 20:15:37 2007
+++ llvm/include/llvm/Instruction.h	Thu Feb  1 20:16:21 2007
@@ -129,6 +129,27 @@
     return getOpcode() >= BinaryOpsBegin && getOpcode() < BinaryOpsEnd;
   }
 
+  /// @brief Determine if the Opcode is one of the shift instructions.
+  static inline bool isShift(unsigned Opcode) {
+    return Opcode >= Shl && Opcode <= AShr;
+  }
+
+  /// @brief Determine if the instruction's opcode is one of the shift 
+  /// instructions.
+  inline bool isShift() { return isShift(getOpcode()); }
+
+  /// isLogicalShift - Return true if this is a logical shift left or a logical
+  /// shift right.
+  inline bool isLogicalShift() {
+    return getOpcode() == Shl || getOpcode() == LShr;
+  }
+
+  /// isLogicalShift - Return true if this is a logical shift left or a logical
+  /// shift right.
+  inline bool isArithmeticShift() {
+    return getOpcode() == AShr;
+  }
+
   /// @brief Determine if the OpCode is one of the CastInst instructions.
   static inline bool isCast(unsigned OpCode) {
     return OpCode >= CastOpsBegin && OpCode < CastOpsEnd;


Index: llvm/include/llvm/Instructions.h
diff -u llvm/include/llvm/Instructions.h:1.52 llvm/include/llvm/Instructions.h:1.53
--- llvm/include/llvm/Instructions.h:1.52	Wed Jan 31 13:47:18 2007
+++ llvm/include/llvm/Instructions.h	Thu Feb  1 20:16:21 2007
@@ -760,83 +760,6 @@
   }
 };
 
-
-//===----------------------------------------------------------------------===//
-//                                 ShiftInst Class
-//===----------------------------------------------------------------------===//
-
-/// ShiftInst - This class represents left and right shift instructions.
-///
-class ShiftInst : public Instruction {
-  Use Ops[2];
-  ShiftInst(const ShiftInst &SI)
-    : Instruction(SI.getType(), SI.getOpcode(), Ops, 2) {
-    Ops[0].init(SI.Ops[0], this);
-    Ops[1].init(SI.Ops[1], this);
-  }
-  void init(OtherOps Opcode, Value *S, Value *SA) {
-    assert((Opcode == Shl || Opcode == LShr || Opcode == AShr) && 
-      "ShiftInst Opcode invalid!");
-    Ops[0].init(S, this);
-    Ops[1].init(SA, this);
-  }
-
-public:
-  ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "",
-            Instruction *InsertBefore = 0)
-    : Instruction(S->getType(), Opcode, Ops, 2, Name, InsertBefore) {
-    init(Opcode, S, SA);
-  }
-  ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name,
-            BasicBlock *InsertAtEnd)
-    : Instruction(S->getType(), Opcode, Ops, 2, Name, InsertAtEnd) {
-    init(Opcode, S, SA);
-  }
-
-  OtherOps getOpcode() const {
-    return static_cast<OtherOps>(Instruction::getOpcode());
-  }
-
-  /// Transparently provide more efficient getOperand methods.
-  Value *getOperand(unsigned i) const {
-    assert(i < 2 && "getOperand() out of range!");
-    return Ops[i];
-  }
-  void setOperand(unsigned i, Value *Val) {
-    assert(i < 2 && "setOperand() out of range!");
-    Ops[i] = Val;
-  }
-  unsigned getNumOperands() const { return 2; }
-
-  /// isLogicalShift - Return true if this is a logical shift left or a logical
-  /// shift right.
-  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.
-  bool isArithmeticShift() const {
-    return !isLogicalShift();
-  }
-
-
-  virtual ShiftInst *clone() const;
-
-  // 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::LShr) |
-           (I->getOpcode() == Instruction::AShr) |
-           (I->getOpcode() == Instruction::Shl);
-  }
-  static inline bool classof(const Value *V) {
-    return isa<Instruction>(V) && classof(cast<Instruction>(V));
-  }
-};
-
 //===----------------------------------------------------------------------===//
 //                               SelectInst Class
 //===----------------------------------------------------------------------===//






More information about the llvm-commits mailing list