mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-26 05:56:51 +00:00
Add insertvalue and extractvalue folding support in IRBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53931 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8502112419
commit
a3da832705
@ -573,29 +573,40 @@ public:
|
||||
return Insert(new GetResultInst(V, Index), Name);
|
||||
}
|
||||
|
||||
ExtractValueInst *CreateExtractValue(Value *Agg, unsigned Idx,
|
||||
const char *Name = "") {
|
||||
Value *CreateExtractValue(Value *Agg, unsigned Idx,
|
||||
const char *Name = "") {
|
||||
if (Constant *AggC = dyn_cast<Constant>(Agg))
|
||||
return ConstantExpr::getExtractValue(AggC, &Idx, 1);
|
||||
return Insert(ExtractValueInst::Create(Agg, Idx), Name);
|
||||
}
|
||||
|
||||
template<typename InputIterator>
|
||||
ExtractValueInst *CreateExtractValue(Value *Agg,
|
||||
InputIterator IdxBegin,
|
||||
InputIterator IdxEnd,
|
||||
const char *Name = "") {
|
||||
Value *CreateExtractValue(Value *Agg,
|
||||
InputIterator IdxBegin,
|
||||
InputIterator IdxEnd,
|
||||
const char *Name = "") {
|
||||
if (Constant *AggC = dyn_cast<Constant>(Agg))
|
||||
return ConstantExpr::getExtractValue(AggC, IdxBegin, IdxEnd - IdxBegin);
|
||||
return Insert(ExtractValueInst::Create(Agg, IdxBegin, IdxEnd), Name);
|
||||
}
|
||||
|
||||
InsertValueInst *CreateInsertValue(Value *Agg, Value *Val, unsigned Idx,
|
||||
const char *Name = "") {
|
||||
Value *CreateInsertValue(Value *Agg, Value *Val, unsigned Idx,
|
||||
const char *Name = "") {
|
||||
if (Constant *AggC = dyn_cast<Constant>(Agg))
|
||||
if (Constant *ValC = dyn_cast<Constant>(Val))
|
||||
return ConstantExpr::getInsertValue(AggC, ValC, &Idx, 1);
|
||||
return Insert(InsertValueInst::Create(Agg, Val, Idx), Name);
|
||||
}
|
||||
|
||||
template<typename InputIterator>
|
||||
InsertValueInst *CreateInsertValue(Value *Agg, Value *Val,
|
||||
InputIterator IdxBegin,
|
||||
InputIterator IdxEnd,
|
||||
const char *Name = "") {
|
||||
Value *CreateInsertValue(Value *Agg, Value *Val,
|
||||
InputIterator IdxBegin,
|
||||
InputIterator IdxEnd,
|
||||
const char *Name = "") {
|
||||
if (Constant *AggC = dyn_cast<Constant>(Agg))
|
||||
if (Constant *ValC = dyn_cast<Constant>(Val))
|
||||
return ConstantExpr::getInsertValue(AggC, ValC,
|
||||
IdxBegin, IdxEnd - IdxBegin);
|
||||
return Insert(InsertValueInst::Create(Agg, Val, IdxBegin, IdxEnd), Name);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user