This revision was automatically updated to reflect the committed changes. Closed by commit rGbaca3c150733: Move SIMD alignment calculation to LLVM Frontend (authored by domada).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141910/new/ https://reviews.llvm.org/D141910 Files: clang/include/clang/Basic/TargetInfo.h clang/lib/AST/ASTContext.cpp clang/lib/AST/CMakeLists.txt clang/lib/Basic/TargetInfo.cpp clang/lib/Basic/Targets/PPC.h clang/lib/Basic/Targets/WebAssembly.h clang/lib/Basic/Targets/X86.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp =================================================================== --- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -3053,6 +3053,23 @@ Builder.CreateBr(NewBlocks.front()); } +unsigned +OpenMPIRBuilder::getOpenMPDefaultSimdAlign(const Triple &TargetTriple, + const StringMap<bool> &Features) { + if (TargetTriple.isX86()) { + if (Features.lookup("avx512f")) + return 512; + else if (Features.lookup("avx")) + return 256; + return 128; + } + if (TargetTriple.isPPC()) + return 128; + if (TargetTriple.isWasm()) + return 128; + return 0; +} + void OpenMPIRBuilder::applySimd(CanonicalLoopInfo *CanonicalLoop, MapVector<Value *, Value *> AlignedVars, Value *IfCond, OrderKind Order, Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h =================================================================== --- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h +++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h @@ -502,6 +502,13 @@ ArrayRef<CanonicalLoopInfo *> Loops, InsertPointTy ComputeIP); + /// Get the default alignment value for given target + /// + /// \param TargetTriple Target triple + /// \param Features StringMap which describes extra CPU features + static unsigned getOpenMPDefaultSimdAlign(const Triple &TargetTriple, + const StringMap<bool> &Features); + private: /// Modifies the canonical loop to be a statically-scheduled workshare loop. /// Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -500,8 +500,6 @@ auto target_info = TargetInfo::CreateTargetInfo( m_compiler->getDiagnostics(), m_compiler->getInvocation().TargetOpts); if (log) { - LLDB_LOGF(log, "Using SIMD alignment: %d", - target_info->getSimdDefaultAlign()); LLDB_LOGF(log, "Target datalayout string: '%s'", target_info->getDataLayoutString()); LLDB_LOGF(log, "Target ABI: '%s'", target_info->getABI().str().c_str()); Index: clang/lib/Basic/Targets/X86.cpp =================================================================== --- clang/lib/Basic/Targets/X86.cpp +++ clang/lib/Basic/Targets/X86.cpp @@ -400,9 +400,6 @@ return false; } - SimdDefaultAlign = - hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128; - // FIXME: We should allow long double type on 32-bits to match with GCC. // This requires backend to be able to lower f80 without x87 first. if (!HasX87 && LongDoubleFormat == &llvm::APFloat::x87DoubleExtended()) Index: clang/lib/Basic/Targets/WebAssembly.h =================================================================== --- clang/lib/Basic/Targets/WebAssembly.h +++ clang/lib/Basic/Targets/WebAssembly.h @@ -49,7 +49,6 @@ SuitableAlign = 128; LargeArrayMinWidth = 128; LargeArrayAlign = 128; - SimdDefaultAlign = 128; SigAtomicType = SignedLong; LongDoubleWidth = LongDoubleAlign = 128; LongDoubleFormat = &llvm::APFloat::IEEEquad(); Index: clang/lib/Basic/Targets/PPC.h =================================================================== --- clang/lib/Basic/Targets/PPC.h +++ clang/lib/Basic/Targets/PPC.h @@ -87,7 +87,6 @@ PPCTargetInfo(const llvm::Triple &Triple, const TargetOptions &) : TargetInfo(Triple) { SuitableAlign = 128; - SimdDefaultAlign = 128; LongDoubleWidth = LongDoubleAlign = 128; LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble(); HasStrictFP = true; Index: clang/lib/Basic/TargetInfo.cpp =================================================================== --- clang/lib/Basic/TargetInfo.cpp +++ clang/lib/Basic/TargetInfo.cpp @@ -119,7 +119,6 @@ MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0; MaxVectorAlign = 0; MaxTLSAlign = 0; - SimdDefaultAlign = 0; SizeType = UnsignedLong; PtrDiffType = SignedLong; IntMaxType = SignedLongLong; Index: clang/lib/AST/CMakeLists.txt =================================================================== --- clang/lib/AST/CMakeLists.txt +++ clang/lib/AST/CMakeLists.txt @@ -132,4 +132,5 @@ ClangAttrDocTable Opcodes omp_gen + intrinsics_gen ) Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -77,6 +77,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Frontend/OpenMP/OMPIRBuilder.h" #include "llvm/Support/Capacity.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" @@ -2539,7 +2540,8 @@ } unsigned ASTContext::getOpenMPDefaultSimdAlign(QualType T) const { - unsigned SimdAlign = getTargetInfo().getSimdDefaultAlign(); + unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign( + getTargetInfo().getTriple(), Target->getTargetOpts().FeatureMap); return SimdAlign; } Index: clang/include/clang/Basic/TargetInfo.h =================================================================== --- clang/include/clang/Basic/TargetInfo.h +++ clang/include/clang/Basic/TargetInfo.h @@ -225,7 +225,6 @@ bool HasStrictFP; unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; - unsigned short SimdDefaultAlign; std::string DataLayoutString; const char *UserLabelPrefix; const char *MCountName; @@ -794,10 +793,6 @@ /// Return the maximum vector alignment supported for the given target. unsigned getMaxVectorAlign() const { return MaxVectorAlign; } - /// Return default simd alignment for the given target. Generally, this - /// value is type-specific, but this alignment can be used for most of the - /// types for the given target. - unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; } unsigned getMaxOpenCLWorkGroupSize() const { return MaxOpenCLWorkGroupSize; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits