aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2011-07-13 10:26:04 +0000
committerJay Foad <jay.foad@gmail.com>2011-07-13 10:26:04 +0000
commitfc6d3a49867cd38954dc40936a88f1907252c6d2 (patch)
tree427850758eca130b1354d38d7281569bb3528c52 /include/llvm/Support
parent5d4f9909c49d28db9572acc4513c1a695b0c53da (diff)
downloadexternal_llvm-fc6d3a49867cd38954dc40936a88f1907252c6d2.zip
external_llvm-fc6d3a49867cd38954dc40936a88f1907252c6d2.tar.gz
external_llvm-fc6d3a49867cd38954dc40936a88f1907252c6d2.tar.bz2
Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/ConstantFolder.h10
-rw-r--r--include/llvm/Support/IRBuilder.h34
-rw-r--r--include/llvm/Support/NoFolder.h12
-rw-r--r--include/llvm/Support/TargetFolder.h11
4 files changed, 23 insertions, 44 deletions
diff --git a/include/llvm/Support/ConstantFolder.h b/include/llvm/Support/ConstantFolder.h
index d0eaa3e..7330235 100644
--- a/include/llvm/Support/ConstantFolder.h
+++ b/include/llvm/Support/ConstantFolder.h
@@ -210,14 +210,14 @@ public:
return ConstantExpr::getShuffleVector(V1, V2, Mask);
}
- Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
- unsigned NumIdx) const {
- return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx);
+ Constant *CreateExtractValue(Constant *Agg,
+ ArrayRef<unsigned> IdxList) const {
+ return ConstantExpr::getExtractValue(Agg, IdxList);
}
Constant *CreateInsertValue(Constant *Agg, Constant *Val,
- const unsigned *IdxList, unsigned NumIdx) const {
- return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx);
+ ArrayRef<unsigned> IdxList) const {
+ return ConstantExpr::getInsertValue(Agg, Val, IdxList);
}
};
diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h
index deea572..6bdbfbb 100644
--- a/include/llvm/Support/IRBuilder.h
+++ b/include/llvm/Support/IRBuilder.h
@@ -1194,43 +1194,21 @@ public:
return Insert(new ShuffleVectorInst(V1, V2, Mask), Name);
}
- Value *CreateExtractValue(Value *Agg, unsigned Idx,
- const Twine &Name = "") {
- if (Constant *AggC = dyn_cast<Constant>(Agg))
- return Insert(Folder.CreateExtractValue(AggC, &Idx, 1), Name);
- return Insert(ExtractValueInst::Create(Agg, Idx), Name);
- }
-
- template<typename RandomAccessIterator>
Value *CreateExtractValue(Value *Agg,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
+ ArrayRef<unsigned> Idxs,
const Twine &Name = "") {
if (Constant *AggC = dyn_cast<Constant>(Agg))
- return Insert(Folder.CreateExtractValue(AggC, IdxBegin, IdxEnd-IdxBegin),
- Name);
- return Insert(ExtractValueInst::Create(Agg, IdxBegin, IdxEnd), Name);
+ return Insert(Folder.CreateExtractValue(AggC, Idxs), Name);
+ return Insert(ExtractValueInst::Create(Agg, Idxs), Name);
}
- Value *CreateInsertValue(Value *Agg, Value *Val, unsigned Idx,
- const Twine &Name = "") {
- if (Constant *AggC = dyn_cast<Constant>(Agg))
- if (Constant *ValC = dyn_cast<Constant>(Val))
- return Insert(Folder.CreateInsertValue(AggC, ValC, &Idx, 1), Name);
- return Insert(InsertValueInst::Create(Agg, Val, Idx), Name);
- }
-
- template<typename RandomAccessIterator>
Value *CreateInsertValue(Value *Agg, Value *Val,
- RandomAccessIterator IdxBegin,
- RandomAccessIterator IdxEnd,
+ ArrayRef<unsigned> Idxs,
const Twine &Name = "") {
if (Constant *AggC = dyn_cast<Constant>(Agg))
if (Constant *ValC = dyn_cast<Constant>(Val))
- return Insert(Folder.CreateInsertValue(AggC, ValC, IdxBegin,
- IdxEnd - IdxBegin),
- Name);
- return Insert(InsertValueInst::Create(Agg, Val, IdxBegin, IdxEnd), Name);
+ return Insert(Folder.CreateInsertValue(AggC, ValC, Idxs), Name);
+ return Insert(InsertValueInst::Create(Agg, Val, Idxs), Name);
}
//===--------------------------------------------------------------------===//
diff --git a/include/llvm/Support/NoFolder.h b/include/llvm/Support/NoFolder.h
index 5ead26e..94359a5 100644
--- a/include/llvm/Support/NoFolder.h
+++ b/include/llvm/Support/NoFolder.h
@@ -22,6 +22,7 @@
#ifndef LLVM_SUPPORT_NOFOLDER_H
#define LLVM_SUPPORT_NOFOLDER_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
@@ -269,15 +270,14 @@ public:
return new ShuffleVectorInst(V1, V2, Mask);
}
- Instruction *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
- unsigned NumIdx) const {
- return ExtractValueInst::Create(Agg, IdxList, IdxList+NumIdx);
+ Instruction *CreateExtractValue(Constant *Agg,
+ ArrayRef<unsigned> IdxList) const {
+ return ExtractValueInst::Create(Agg, IdxList);
}
Instruction *CreateInsertValue(Constant *Agg, Constant *Val,
- const unsigned *IdxList,
- unsigned NumIdx) const {
- return InsertValueInst::Create(Agg, Val, IdxList, IdxList+NumIdx);
+ ArrayRef<unsigned> IdxList) const {
+ return InsertValueInst::Create(Agg, Val, IdxList);
}
};
diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h
index 20ca557..3233a98 100644
--- a/include/llvm/Support/TargetFolder.h
+++ b/include/llvm/Support/TargetFolder.h
@@ -21,6 +21,7 @@
#include "llvm/Constants.h"
#include "llvm/InstrTypes.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/Analysis/ConstantFolding.h"
namespace llvm {
@@ -226,14 +227,14 @@ public:
return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask));
}
- Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
- unsigned NumIdx) const {
- return Fold(ConstantExpr::getExtractValue(Agg, IdxList, NumIdx));
+ Constant *CreateExtractValue(Constant *Agg,
+ ArrayRef<unsigned> IdxList) const {
+ return Fold(ConstantExpr::getExtractValue(Agg, IdxList));
}
Constant *CreateInsertValue(Constant *Agg, Constant *Val,
- const unsigned *IdxList, unsigned NumIdx) const {
- return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx));
+ ArrayRef<unsigned> IdxList) const {
+ return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList));
}
};