summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instructions.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-05-23 00:36:11 +0000
committerDan Gohman <gohman@apple.com>2008-05-23 00:36:11 +0000
commit0752bffe9aa0051518316d410e7373b7f896bc2d (patch)
tree7e2b5099c1c095321e8df4967dd18927765ab949 /llvm/lib/VMCore/Instructions.cpp
parent396ed504f1a39959befcf13e3303eb21a4af555e (diff)
downloadbcm5719-llvm-0752bffe9aa0051518316d410e7373b7f896bc2d.tar.gz
bcm5719-llvm-0752bffe9aa0051518316d410e7373b7f896bc2d.zip
Add more IR support for the new extractvalue and insertvalue
instructions. llvm-svn: 51461
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 40eea138350..95e0fc5199e 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -1333,9 +1333,69 @@ int ShuffleVectorInst::getMaskValue(unsigned i) const {
}
//===----------------------------------------------------------------------===//
+// InsertValueInst Class
+//===----------------------------------------------------------------------===//
+
+void InsertValueInst::init(Value *Agg, Value *Val, Value* const *Idx, unsigned NumIdx) {
+ assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
+ Use *OL = OperandList;
+ OL[0].init(Agg, this);
+ OL[1].init(Val, this);
+
+ for (unsigned i = 0; i != NumIdx; ++i)
+ OL[i+2].init(Idx[i], this);
+}
+
+void InsertValueInst::init(Value *Agg, Value *Val, Value *Idx) {
+ assert(NumOperands == 3 && "NumOperands not initialized?");
+ Use *OL = OperandList;
+ OL[0].init(Agg, this);
+ OL[1].init(Val, this);
+ OL[2].init(Idx, this);
+}
+
+InsertValueInst::InsertValueInst(const InsertValueInst &IVI)
+ : Instruction(reinterpret_cast<const Type*>(IVI.getType()), InsertValue,
+ OperandTraits<InsertValueInst>::op_end(this)
+ - IVI.getNumOperands(),
+ IVI.getNumOperands()) {
+ Use *OL = OperandList;
+ Use *IVIOL = IVI.OperandList;
+ for (unsigned i = 0, E = NumOperands; i != E; ++i)
+ OL[i].init(IVIOL[i], this);
+}
+
+//===----------------------------------------------------------------------===//
// ExtractValueInst Class
//===----------------------------------------------------------------------===//
+void ExtractValueInst::init(Value *Agg, Value* const *Idx, unsigned NumIdx) {
+ assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
+ Use *OL = OperandList;
+ OL[0].init(Agg, this);
+
+ for (unsigned i = 0; i != NumIdx; ++i)
+ OL[i+1].init(Idx[i], this);
+}
+
+void ExtractValueInst::init(Value *Agg, Value *Idx) {
+ assert(NumOperands == 2 && "NumOperands not initialized?");
+ Use *OL = OperandList;
+ OL[0].init(Agg, this);
+ OL[1].init(Idx, this);
+}
+
+ExtractValueInst::ExtractValueInst(const ExtractValueInst &EVI)
+ : Instruction(reinterpret_cast<const Type*>(EVI.getType()), ExtractValue,
+ OperandTraits<ExtractValueInst>::op_end(this)
+ - EVI.getNumOperands(),
+ EVI.getNumOperands()) {
+ Use *OL = OperandList;
+ Use *EVIOL = EVI.OperandList;
+ for (unsigned i = 0, E = NumOperands; i != E; ++i)
+ OL[i].init(EVIOL[i], this);
+}
+
// getIndexedType - Returns the type of the element that would be extracted
// with an extractvalue instruction with the specified parameters.
//
@@ -2809,6 +2869,14 @@ VICmpInst* VICmpInst::clone() const {
return new VICmpInst(getPredicate(), Op<0>(), Op<1>());
}
+ExtractValueInst *ExtractValueInst::clone() const {
+ return new(getNumOperands()) ExtractValueInst(*this);
+}
+InsertValueInst *InsertValueInst::clone() const {
+ return new(getNumOperands()) InsertValueInst(*this);
+}
+
+
MallocInst *MallocInst::clone() const { return new MallocInst(*this); }
AllocaInst *AllocaInst::clone() const { return new AllocaInst(*this); }
FreeInst *FreeInst::clone() const { return new FreeInst(getOperand(0)); }
OpenPOWER on IntegriCloud