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

Chris Lattner sabre at nondot.org
Wed Oct 4 23:25:13 PDT 2006



Changes in directory llvm/lib/VMCore:

Instructions.cpp updated: 1.41 -> 1.42
---
Log message:

Add insertelement/extractelement helper ctors.


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

 Instructions.cpp |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+)


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.41 llvm/lib/VMCore/Instructions.cpp:1.42
--- llvm/lib/VMCore/Instructions.cpp:1.41	Sun Sep 17 23:54:57 2006
+++ llvm/lib/VMCore/Instructions.cpp	Thu Oct  5 01:24:58 2006
@@ -844,6 +844,19 @@
   Ops[1].init(Index, this);
 }
 
+ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
+                                       const std::string &Name,
+                                       Instruction *InsertBef)
+  : Instruction(cast<PackedType>(Val->getType())->getElementType(),
+                ExtractElement, Ops, 2, Name, InsertBef) {
+  Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV);
+  assert(isValidOperands(Val, Index) &&
+         "Invalid extractelement instruction operands!");
+  Ops[0].init(Val, this);
+  Ops[1].init(Index, this);
+}
+
+
 ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
                                        const std::string &Name,
                                        BasicBlock *InsertAE)
@@ -856,6 +869,20 @@
   Ops[1].init(Index, this);
 }
 
+ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
+                                       const std::string &Name,
+                                       BasicBlock *InsertAE)
+  : Instruction(cast<PackedType>(Val->getType())->getElementType(),
+                ExtractElement, Ops, 2, Name, InsertAE) {
+  Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV);
+  assert(isValidOperands(Val, Index) &&
+         "Invalid extractelement instruction operands!");
+  
+  Ops[0].init(Val, this);
+  Ops[1].init(Index, this);
+}
+
+
 bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
   if (!isa<PackedType>(Val->getType()) || Index->getType() != Type::UIntTy)
     return false;
@@ -884,6 +911,19 @@
   Ops[2].init(Index, this);
 }
 
+InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
+                                     const std::string &Name,
+                                     Instruction *InsertBef)
+  : Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertBef) {
+  Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV);
+  assert(isValidOperands(Vec, Elt, Index) &&
+         "Invalid insertelement instruction operands!");
+  Ops[0].init(Vec, this);
+  Ops[1].init(Elt, this);
+  Ops[2].init(Index, this);
+}
+
+
 InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
                                      const std::string &Name,
                                      BasicBlock *InsertAE)
@@ -896,6 +936,19 @@
   Ops[2].init(Index, this);
 }
 
+InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
+                                     const std::string &Name,
+                                     BasicBlock *InsertAE)
+: Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertAE) {
+  Constant *Index = ConstantUInt::get(Type::UIntTy, IndexV);
+  assert(isValidOperands(Vec, Elt, Index) &&
+         "Invalid insertelement instruction operands!");
+  
+  Ops[0].init(Vec, this);
+  Ops[1].init(Elt, this);
+  Ops[2].init(Index, this);
+}
+
 bool InsertElementInst::isValidOperands(const Value *Vec, const Value *Elt, 
                                         const Value *Index) {
   if (!isa<PackedType>(Vec->getType()))






More information about the llvm-commits mailing list