From 18595a086273fc98ff8422f1c4a4e0f1fc609107 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 24 Aug 2015 16:51:46 +0000 Subject: [PATCH] [WebAssembly] Tell TargetTransformInfo about popcnt and sqrt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245853 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../WebAssembly/WebAssemblyTargetTransformInfo.cpp | 11 ++++++++--- .../WebAssembly/WebAssemblyTargetTransformInfo.h | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp b/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp index fa88ed526df..559932f5fb4 100644 --- a/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp +++ b/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp @@ -21,8 +21,13 @@ using namespace llvm; #define DEBUG_TYPE "wasmtti" TargetTransformInfo::PopcntSupportKind -WebAssemblyTTIImpl::getPopcntSupport(unsigned TyWidth) { +WebAssemblyTTIImpl::getPopcntSupport(unsigned TyWidth) const { assert(isPowerOf2_32(TyWidth) && "Ty width must be power of 2"); - // TODO: Make Math.popcount32 happen in WebAssembly. - return TTI::PSK_Software; + return TargetTransformInfo::PSK_FastHardware; +} + +bool +WebAssemblyTTIImpl::haveFastSqrt(Type *Ty) const { + assert(Ty->isFPOrFPVectorTy() && "Ty must be floating point"); + return true; } diff --git a/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h b/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h index 7ffb6047b96..f2158ca0dfc 100644 --- a/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h +++ b/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h @@ -54,7 +54,8 @@ public: // TODO: Implement more Scalar TTI for WebAssembly - TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); + TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const; + bool haveFastSqrt(Type *Ty) const; /// @} -- 2.34.1