From 9dd045f1784274c5341437dec16566ec6c124e13 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Fri, 26 Oct 2012 04:28:02 +0000 Subject: [PATCH] Add VectorTargetTransform::getNumberOfParts. As discussed on IRC, add VectorTargetTransform::getNumberOfParts to provide a stable interface to the vector legalization splitting factor. llvm-svn: 166751 --- llvm/include/llvm/Target/TargetTransformImpl.h | 2 ++ llvm/include/llvm/TargetTransformInfo.h | 5 +++++ llvm/lib/Target/TargetTransformImpl.cpp | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/llvm/include/llvm/Target/TargetTransformImpl.h b/llvm/include/llvm/Target/TargetTransformImpl.h index 25a7ede..133be87 100644 --- a/llvm/include/llvm/Target/TargetTransformImpl.h +++ b/llvm/include/llvm/Target/TargetTransformImpl.h @@ -68,6 +68,8 @@ public: virtual unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace) const; + + virtual unsigned getNumberOfParts(Type *Tp) const; }; } // end llvm namespace diff --git a/llvm/include/llvm/TargetTransformInfo.h b/llvm/include/llvm/TargetTransformInfo.h index 96470c3..71c78ec 100644 --- a/llvm/include/llvm/TargetTransformInfo.h +++ b/llvm/include/llvm/TargetTransformInfo.h @@ -156,6 +156,11 @@ public: return 1; } + /// Returns the number of pieces into which the provided type must be + /// split during legalization. Zero is returned when the answer is unknown. + virtual unsigned getNumberOfParts(Type *Tp) const { + return 0; + } }; } // End llvm namespace diff --git a/llvm/lib/Target/TargetTransformImpl.cpp b/llvm/lib/Target/TargetTransformImpl.cpp index c8bd80e..3bf4bf7 100644 --- a/llvm/lib/Target/TargetTransformImpl.cpp +++ b/llvm/lib/Target/TargetTransformImpl.cpp @@ -196,3 +196,11 @@ VectorTargetTransformImpl::getMemoryOpCost(unsigned Opcode, Type *Src, // Assume that all loads of legal types cost 1. return LT.first; } + +unsigned +VectorTargetTransformImpl::getNumberOfParts(Type *Tp) const { + std::pair LT = + getTypeLegalizationCost(Tp->getContext(), TLI->getValueType(Tp)); + return LT.first; +} + -- 2.7.4