mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
move DAGCombiner's allowableAlignment() helper function into the TLI
Making allowableAlignment() more accessible was suggested as a predecessor patch for D10662, so I've pulled it into TargetLowering. This let's us remove 4 instances of duplicate logic in LegalizeDAG. There's a subtle functional change in the implementation: the existing allowableAlignment() code was using getPrefTypeAlignment() when checking alignment with the DataLayout and assumed that was fast. In this implementation, we use getABITypeAlignment() and assume that is fast. See the TODO comment or the discussion in the Phab review for future improvements in this implementation (don't use the data layout at all). There are no regression test changes from this difference, and I'm not sure how to expose it via a test. I think we actually do want to provide the 'Fast' param when checking this from DAGCombiner::MergeConsecutiveStores(). Ie, we shouldn't merge stores if the new stores are not going to be fast. But that change will require fixing allowsMisalignedMemoryAccess() overrides as noted in D10662. Differential Revision: http://reviews.llvm.org/D10905 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243549 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1530,6 +1530,29 @@ unsigned TargetLoweringBase::getByValTypeAlignment(Type *Ty,
|
||||
return DL.getABITypeAlignment(Ty);
|
||||
}
|
||||
|
||||
bool TargetLoweringBase::allowsMemoryAccess(LLVMContext &Context,
|
||||
const DataLayout &DL, EVT VT,
|
||||
unsigned AddrSpace,
|
||||
unsigned Alignment,
|
||||
bool *Fast) const {
|
||||
// Check if the specified alignment is sufficient based on the data layout.
|
||||
// TODO: While using the data layout works in practice, a better solution
|
||||
// would be to implement this check directly (make this a virtual function).
|
||||
// For example, the ABI alignment may change based on software platform while
|
||||
// this function should only be affected by hardware implementation.
|
||||
Type *Ty = VT.getTypeForEVT(Context);
|
||||
if (Alignment >= DL.getABITypeAlignment(Ty)) {
|
||||
// Assume that an access that meets the ABI-specified alignment is fast.
|
||||
if (Fast != nullptr)
|
||||
*Fast = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is a misaligned access.
|
||||
return allowsMisalignedMemoryAccesses(VT, AddrSpace, Alignment, Fast);
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// TargetTransformInfo Helpers
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Reference in New Issue
Block a user