mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
use Constant::getAggregateElement to simplify a bunch of code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148934 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1493,19 +1493,12 @@ Value *llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range,
|
||||
"Not looking at a struct or array?");
|
||||
assert(ExtractValueInst::getIndexedType(V->getType(), idx_range) &&
|
||||
"Invalid indices for type?");
|
||||
CompositeType *PTy = cast<CompositeType>(V->getType());
|
||||
|
||||
if (isa<UndefValue>(V))
|
||||
return UndefValue::get(ExtractValueInst::getIndexedType(PTy, idx_range));
|
||||
if (isa<ConstantAggregateZero>(V))
|
||||
return Constant::getNullValue(ExtractValueInst::getIndexedType(PTy,
|
||||
idx_range));
|
||||
if (isa<ConstantArray>(V) || isa<ConstantStruct>(V))
|
||||
// Recursively process this constant
|
||||
return FindInsertedValue(cast<Constant>(V)->getOperand(idx_range[0]),
|
||||
idx_range.slice(1), InsertBefore);
|
||||
if (ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(V))
|
||||
return CDS->getElementAsConstant(idx_range[0]);
|
||||
if (Constant *C = dyn_cast<Constant>(V)) {
|
||||
C = C->getAggregateElement(idx_range[0]);
|
||||
if (C == 0) return 0;
|
||||
return FindInsertedValue(C, idx_range.slice(1), InsertBefore);
|
||||
}
|
||||
|
||||
if (InsertValueInst *I = dyn_cast<InsertValueInst>(V)) {
|
||||
// Loop the indices for the insertvalue instruction in parallel with the
|
||||
|
Reference in New Issue
Block a user