[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Instructions.cpp

2007-02-23 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Instruction.cpp updated: 1.69 -> 1.70
Instructions.cpp updated: 1.77 -> 1.78
---
Log message:

Refactor the setName stuff, moving it down the inheritance hierarchy, to
solve a crash in -instcombine -debug that was hit while investigating PR1217: 
http://llvm.org/PR1217 


---
Diffs of the changes:  (+199 -98)

 Instruction.cpp  |   33 --
 Instructions.cpp |  264 +--
 2 files changed, 199 insertions(+), 98 deletions(-)


Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.69 
llvm/lib/VMCore/Instruction.cpp:1.70
--- llvm/lib/VMCore/Instruction.cpp:1.69Mon Feb 19 13:46:17 2007
+++ llvm/lib/VMCore/Instruction.cpp Fri Feb 23 18:55:48 2007
@@ -19,7 +19,7 @@
 using namespace llvm;
 
 Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned 
NumOps,
- const std::string &Name, Instruction *InsertBefore)
+ Instruction *InsertBefore)
   : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
   // Make sure that we get added to a basicblock
   LeakDetector::addGarbageObject(this);
@@ -30,11 +30,10 @@
"Instruction to insert before is not in a basic block!");
 InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
   }
-  setName(Name);
 }
 
 Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned 
NumOps,
- const std::string &Name, BasicBlock *InsertAtEnd)
+ BasicBlock *InsertAtEnd)
   : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
   // Make sure that we get added to a basicblock
   LeakDetector::addGarbageObject(this);
@@ -42,34 +41,6 @@
   // append this instruction into the basic block
   assert(InsertAtEnd && "Basic block to append to may not be NULL!");
   InsertAtEnd->getInstList().push_back(this);
-  setName(Name);
-}
-
-Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned 
NumOps,
- const char *Name, Instruction *InsertBefore)
-  : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
-  // Make sure that we get added to a basicblock
-  LeakDetector::addGarbageObject(this);
-
-  // If requested, insert this instruction into a basic block...
-  if (InsertBefore) {
-assert(InsertBefore->getParent() &&
-   "Instruction to insert before is not in a basic block!");
-InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
-  }
-  if (Name && *Name) setName(Name);
-}
-
-Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned 
NumOps,
- const char *Name, BasicBlock *InsertAtEnd)
-  : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
-  // Make sure that we get added to a basicblock
-  LeakDetector::addGarbageObject(this);
-
-  // append this instruction into the basic block
-  assert(InsertAtEnd && "Basic block to append to may not be NULL!");
-  InsertAtEnd->getInstList().push_back(this);
-  if (Name && *Name) setName(Name);
 }
 
 


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.77 
llvm/lib/VMCore/Instructions.cpp:1.78
--- llvm/lib/VMCore/Instructions.cpp:1.77   Wed Feb 14 21:39:18 2007
+++ llvm/lib/VMCore/Instructions.cppFri Feb 23 18:55:48 2007
@@ -40,16 +40,6 @@
 //TerminatorInst Class
 
//===--===//
 
-TerminatorInst::TerminatorInst(Instruction::TermOps iType,
-   Use *Ops, unsigned NumOps, Instruction *IB)
-  : Instruction(Type::VoidTy, iType, Ops, NumOps, "", IB) {
-}
-
-TerminatorInst::TerminatorInst(Instruction::TermOps iType,
-   Use *Ops, unsigned NumOps, BasicBlock *IAE)
-  : Instruction(Type::VoidTy, iType, Ops, NumOps, "", IAE) {
-}
-
 // Out of line virtual method, so the vtable, etc has a home.
 TerminatorInst::~TerminatorInst() {
 }
@@ -272,63 +262,71 @@
const std::string &Name, BasicBlock *InsertAtEnd)
   : Instruction(cast(cast(Func->getType())
  ->getElementType())->getReturnType(),
-Instruction::Call, 0, 0, Name, InsertAtEnd) {
+Instruction::Call, 0, 0, InsertAtEnd) {
   init(Func, Args, NumArgs);
+  setName(Name);
 }
 CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs,
const std::string &Name, Instruction *InsertBefore)
 : Instruction(cast(cast(Func->getType())
  ->getElementType())->getReturnType(),
-  Instruction::Call, 0, 0, Name, InsertBefore) {
+  Instruction::Call, 0, 0, InsertBefore) {
   init(Func, Args, NumArgs);
+  setName(Name);
 }
 
 CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2,
const std::string &Name, Instruction  *InsertBe

[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Instructions.cpp

2007-02-12 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Instruction.cpp updated: 1.64 -> 1.65
Instructions.cpp updated: 1.74 -> 1.75
---
Log message:

Switch UnaryOperators to default to passing names up by const char* when 
possible.
This speeds up bcreading by 1.5%.


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

 Instruction.cpp  |   28 
 Instructions.cpp |   54 ++
 2 files changed, 74 insertions(+), 8 deletions(-)


Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.64 
llvm/lib/VMCore/Instruction.cpp:1.65
--- llvm/lib/VMCore/Instruction.cpp:1.64Sun Feb 11 23:18:08 2007
+++ llvm/lib/VMCore/Instruction.cpp Tue Feb 13 01:54:42 2007
@@ -44,6 +44,34 @@
   setName(Name);
 }
 
+Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned 
NumOps,
+ const char *Name, Instruction *InsertBefore)
+  : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
+  // Make sure that we get added to a basicblock
+  LeakDetector::addGarbageObject(this);
+
+  // If requested, insert this instruction into a basic block...
+  if (InsertBefore) {
+assert(InsertBefore->getParent() &&
+   "Instruction to insert before is not in a basic block!");
+InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
+  }
+  if (Name && *Name) setName(Name);
+}
+
+Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned 
NumOps,
+ const char *Name, BasicBlock *InsertAtEnd)
+  : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
+  // Make sure that we get added to a basicblock
+  LeakDetector::addGarbageObject(this);
+
+  // append this instruction into the basic block
+  assert(InsertAtEnd && "Basic block to append to may not be NULL!");
+  InsertAtEnd->getInstList().push_back(this);
+  if (Name && *Name) setName(Name);
+}
+
+
 // Out of line virtual method, so the vtable, etc has a home.
 Instruction::~Instruction() {
   assert(Parent == 0 && "Instruction still linked in the program!");


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.74 
llvm/lib/VMCore/Instructions.cpp:1.75
--- llvm/lib/VMCore/Instructions.cpp:1.74   Tue Feb 13 00:22:32 2007
+++ llvm/lib/VMCore/Instructions.cppTue Feb 13 01:54:42 2007
@@ -531,18 +531,20 @@
unsigned Align, const std::string &Name,
Instruction *InsertBefore)
   : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
- Name, InsertBefore), Alignment(Align) {
+ 0, InsertBefore), Alignment(Align) {
   assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
   assert(Ty != Type::VoidTy && "Cannot allocate void!");
+  setName(Name);
 }
 
 AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
unsigned Align, const std::string &Name,
BasicBlock *InsertAtEnd)
   : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
- Name, InsertAtEnd), Alignment(Align) {
+ 0, InsertAtEnd), Alignment(Align) {
   assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
   assert(Ty != Type::VoidTy && "Cannot allocate void!");
+  setName(Name);
 }
 
 // Out of line virtual method, so the vtable, etc has a home.
@@ -579,12 +581,12 @@
 }
 
 FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore)
-  : UnaryInstruction(Type::VoidTy, Free, Ptr, "", InsertBefore) {
+  : UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertBefore) {
   AssertOK();
 }
 
 FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd)
-  : UnaryInstruction(Type::VoidTy, Free, Ptr, "", InsertAtEnd) {
+  : UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertAtEnd) {
   AssertOK();
 }
 
@@ -600,30 +602,66 @@
 
 LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
   : UnaryInstruction(cast(Ptr->getType())->getElementType(),
- Load, Ptr, Name, InsertBef) {
+ Load, Ptr, 0, InsertBef) {
   setVolatile(false);
   AssertOK();
+  setName(Name);
 }
 
 LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
   : UnaryInstruction(cast(Ptr->getType())->getElementType(),
- Load, Ptr, Name, InsertAE) {
+ Load, Ptr, 0, InsertAE) {
   setVolatile(false);
   AssertOK();
+  setName(Name);
 }
 
 LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
Instruction *InsertBef)
   : UnaryInstruction(cast(Ptr->getType())->getElementType(),
- Load, Ptr, Name, InsertBef) {
+ Load, Ptr, 0, InsertBef) {
   setVolatile(isVolatile);
   AssertOK();
+  setName(Name);
 }
 
 LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
   

[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Instructions.cpp Verifier.cpp

2006-11-19 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Instruction.cpp updated: 1.57 -> 1.58
Instructions.cpp updated: 1.46 -> 1.47
Verifier.cpp updated: 1.165 -> 1.166
---
Log message:

For PR950: http://llvm.org/PR950 :
First in a series of patches to convert SetCondInst into ICmpInst and 
FCmpInst using only two opcodes and having the instructions contain their
predicate value. Nothing uses these classes yet. More patches to follow.


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

 Instruction.cpp  |2 
 Instructions.cpp |  196 +++
 Verifier.cpp |   29 
 3 files changed, 226 insertions(+), 1 deletion(-)


Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.57 
llvm/lib/VMCore/Instruction.cpp:1.58
--- llvm/lib/VMCore/Instruction.cpp:1.57Wed Nov  8 00:47:33 2006
+++ llvm/lib/VMCore/Instruction.cpp Sun Nov 19 19:22:35 2006
@@ -11,10 +11,10 @@
 //
 
//===--===//
 
+#include "llvm/Type.h"
 #include "llvm/Instructions.h"
 #include "llvm/Function.h"
 #include "llvm/SymbolTable.h"
-#include "llvm/Type.h"
 #include "llvm/Support/LeakDetector.h"
 using namespace llvm;
 


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.46 
llvm/lib/VMCore/Instructions.cpp:1.47
--- llvm/lib/VMCore/Instructions.cpp:1.46   Wed Nov  8 00:47:33 2006
+++ llvm/lib/VMCore/Instructions.cppSun Nov 19 19:22:35 2006
@@ -1290,6 +1290,197 @@
   }
 }
 
+
+//===--===//
+//   CmpInst Classes
+//===--===//
+
+CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
+ const std::string &Name, Instruction *InsertBefore)
+  : Instruction(Type::BoolTy, op, Ops, 2, Name, InsertBefore) {
+Ops[0].init(LHS, this);
+Ops[1].init(RHS, this);
+  SubclassData = predicate;
+  if (op == Instruction::ICmp) {
+assert(predicate >= ICmpInst::FIRST_ICMP_PREDICATE &&
+   predicate <= ICmpInst::LAST_ICMP_PREDICATE &&
+   "Invalid ICmp predicate value");
+const Type* Op0Ty = getOperand(0)->getType();
+const Type* Op1Ty = getOperand(1)->getType();
+assert(Op0Ty == Op1Ty &&
+   "Both operands to ICmp instruction are not of the same type!");
+// Check that the operands are the right type
+assert(Op0Ty->isIntegral() || Op0Ty->getTypeID() == Type::PointerTyID ||
+   (isa(Op0Ty) && 
+cast(Op0Ty)->getElementType()->isIntegral()) &&
+   "Invalid operand types for ICmp instruction");
+return;
+  }
+  assert(op == Instruction::FCmp && "Invalid CmpInst opcode");
+  assert(predicate <= FCmpInst::LAST_FCMP_PREDICATE &&
+ "Invalid FCmp predicate value");
+  const Type* Op0Ty = getOperand(0)->getType();
+  const Type* Op1Ty = getOperand(1)->getType();
+  assert(Op0Ty == Op1Ty &&
+ "Both operands to FCmp instruction are not of the same type!");
+  // Check that the operands are the right type
+  assert(Op0Ty->isFloatingPoint() || (isa(Op0Ty) &&
+ cast(Op0Ty)->getElementType()->isFloatingPoint()) &&
+ "Invalid operand types for FCmp instruction");
+}
+  
+CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
+ const std::string &Name, BasicBlock *InsertAtEnd)
+  : Instruction(Type::BoolTy, op, Ops, 2, Name, InsertAtEnd) {
+  Ops[0].init(LHS, this);
+  Ops[1].init(RHS, this);
+  SubclassData = predicate;
+  if (op == Instruction::ICmp) {
+assert(predicate >= ICmpInst::FIRST_ICMP_PREDICATE &&
+   predicate <= ICmpInst::LAST_ICMP_PREDICATE &&
+   "Invalid ICmp predicate value");
+
+const Type* Op0Ty = getOperand(0)->getType();
+const Type* Op1Ty = getOperand(1)->getType();
+assert(Op0Ty == Op1Ty &&
+  "Both operands to ICmp instruction are not of the same type!");
+// Check that the operands are the right type
+assert(Op0Ty->isIntegral() || Op0Ty->getTypeID() == Type::PointerTyID ||
+   (isa(Op0Ty) && 
+cast(Op0Ty)->getElementType()->isIntegral()) &&
+   "Invalid operand types for ICmp instruction");
+return;
+  }
+  assert(op == Instruction::FCmp && "Invalid CmpInst opcode");
+  assert(predicate <= FCmpInst::LAST_FCMP_PREDICATE &&
+ "Invalid FCmp predicate value");
+  const Type* Op0Ty = getOperand(0)->getType();
+  const Type* Op1Ty = getOperand(1)->getType();
+  assert(Op0Ty == Op1Ty &&
+  "Both operands to FCmp instruction are not of the same type!");
+  // Check that the operands are the right type
+  assert(Op0Ty->isFloatingPoint() || (isa(Op0Ty) &&
+ cast(Op0Ty)->getElementType()->isFloatingPoint()) &&
+"Invalid operand types for FCmp instruction");
+}
+
+CmpInst *
+CmpInst::create(OtherOps Op, unsigned short predicate, Va

[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Instructions.cpp

2006-06-21 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Instruction.cpp updated: 1.51 -> 1.52
Instructions.cpp updated: 1.38 -> 1.39
---
Log message:

Add some out-of-line virtual dtors so that the class has a "home", preventing
vtables for (e.g.) Instruction from being emitted into every .o file.


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

 Instruction.cpp  |6 ++
 Instructions.cpp |   13 +
 2 files changed, 19 insertions(+)


Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.51 
llvm/lib/VMCore/Instruction.cpp:1.52
--- llvm/lib/VMCore/Instruction.cpp:1.51Fri Apr  7 20:18:18 2006
+++ llvm/lib/VMCore/Instruction.cpp Wed Jun 21 11:53:47 2006
@@ -43,6 +43,12 @@
   InsertAtEnd->getInstList().push_back(this);
 }
 
+// Out of line virtual method, so the vtable, etc has a home.
+Instruction::~Instruction() {
+  assert(Parent == 0 && "Instruction still linked in the program!");
+}
+
+
 void Instruction::setOpcode(unsigned opc) {
   setValueType(Value::InstructionVal + opc);
 }


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.38 
llvm/lib/VMCore/Instructions.cpp:1.39
--- llvm/lib/VMCore/Instructions.cpp:1.38   Sun May 14 13:34:36 2006
+++ llvm/lib/VMCore/Instructions.cppWed Jun 21 11:53:47 2006
@@ -34,6 +34,8 @@
 }
 
 
+
+
 
//===--===//
 //TerminatorInst Class
 
//===--===//
@@ -48,6 +50,13 @@
   : Instruction(Type::VoidTy, iType, Ops, NumOps, "", IAE) {
 }
 
+// Out of line virtual method, so the vtable, etc has a home.
+TerminatorInst::~TerminatorInst() {
+}
+
+// Out of line virtual method, so the vtable, etc has a home.
+UnaryInstruction::~UnaryInstruction() {
+}
 
 
 
//===--===//
@@ -532,6 +541,10 @@
   assert(Ty != Type::VoidTy && "Cannot allocate void!");
 }
 
+// Out of line virtual method, so the vtable, etc has a home.
+AllocationInst::~AllocationInst() {
+}
+
 bool AllocationInst::isArrayAllocation() const {
   if (ConstantUInt *CUI = dyn_cast(getOperand(0)))
 return CUI->getValue() != 1;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits