mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-26 18:20:39 +00:00
Extract code for reducing a type to a single value type into a helper function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163817 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -29,6 +29,26 @@ static Type *getPromotedType(Type *Ty) {
|
|||||||
return Ty;
|
return Ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// reduceToSingleValueType - Given an aggregate type which ultimately holds a
|
||||||
|
/// single scalar element, like {{{type}}} or [1 x type], return type.
|
||||||
|
static Type *reduceToSingleValueType(Type *T) {
|
||||||
|
while (!T->isSingleValueType()) {
|
||||||
|
if (StructType *STy = dyn_cast<StructType>(T)) {
|
||||||
|
if (STy->getNumElements() == 1)
|
||||||
|
T = STy->getElementType(0);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
} else if (ArrayType *ATy = dyn_cast<ArrayType>(T)) {
|
||||||
|
if (ATy->getNumElements() == 1)
|
||||||
|
T = ATy->getElementType();
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return T;
|
||||||
|
}
|
||||||
|
|
||||||
Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
|
Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
|
||||||
unsigned DstAlign = getKnownAlignment(MI->getArgOperand(0), TD);
|
unsigned DstAlign = getKnownAlignment(MI->getArgOperand(0), TD);
|
||||||
@@ -80,20 +100,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
|
|||||||
if (TD && SrcETy->isSized() && TD->getTypeStoreSize(SrcETy) == Size) {
|
if (TD && SrcETy->isSized() && TD->getTypeStoreSize(SrcETy) == Size) {
|
||||||
// The SrcETy might be something like {{{double}}} or [1 x double]. Rip
|
// The SrcETy might be something like {{{double}}} or [1 x double]. Rip
|
||||||
// down through these levels if so.
|
// down through these levels if so.
|
||||||
while (!SrcETy->isSingleValueType()) {
|
SrcETy = reduceToSingleValueType(SrcETy);
|
||||||
if (StructType *STy = dyn_cast<StructType>(SrcETy)) {
|
|
||||||
if (STy->getNumElements() == 1)
|
|
||||||
SrcETy = STy->getElementType(0);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
} else if (ArrayType *ATy = dyn_cast<ArrayType>(SrcETy)) {
|
|
||||||
if (ATy->getNumElements() == 1)
|
|
||||||
SrcETy = ATy->getElementType();
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SrcETy->isSingleValueType()) {
|
if (SrcETy->isSingleValueType()) {
|
||||||
NewSrcPtrTy = PointerType::get(SrcETy, SrcAddrSp);
|
NewSrcPtrTy = PointerType::get(SrcETy, SrcAddrSp);
|
||||||
@@ -102,7 +109,6 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If the memcpy/memmove provides better alignment info than we can
|
// If the memcpy/memmove provides better alignment info than we can
|
||||||
// infer, use it.
|
// infer, use it.
|
||||||
SrcAlign = std::max(SrcAlign, CopyAlign);
|
SrcAlign = std::max(SrcAlign, CopyAlign);
|
||||||
|
|||||||
Reference in New Issue
Block a user