-
Notifications
You must be signed in to change notification settings - Fork 15.1k
TargetLibraryInfo: Split off VectorLibrary enum and flag #166980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TargetLibraryInfo: Split off VectorLibrary enum and flag #166980
Conversation
|
@llvm/pr-subscribers-llvm-analysis @llvm/pr-subscribers-llvm-ir Author: Matt Arsenault (arsenm) ChangesMove this to a new shared header to facilitate the eventual Full diff: https://github.com/llvm/llvm-project/pull/166980.diff 5 Files Affected:
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index 3f39b4787eb11..78954431e81c3 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -23,6 +23,7 @@
namespace llvm {
template <typename T> class ArrayRef;
+enum class VectorLibrary;
/// Provides info so a possible vectorization of a function can be
/// computed. Function 'VectorFnName' is equivalent to 'ScalarFnName'
@@ -117,25 +118,6 @@ class TargetLibraryInfoImpl {
const Module &M) const;
public:
- /// List of known vector-functions libraries.
- ///
- /// The vector-functions library defines, which functions are vectorizable
- /// and with which factor. The library can be specified by either frontend,
- /// or a commandline option, and then used by
- /// addVectorizableFunctionsFromVecLib for filling up the tables of
- /// vectorizable functions.
- enum VectorLibrary {
- NoLibrary, // Don't use any vector library.
- Accelerate, // Use Accelerate framework.
- DarwinLibSystemM, // Use Darwin's libsystem_m.
- LIBMVEC, // GLIBC Vector Math library.
- MASSV, // IBM MASS vector library.
- SVML, // Intel short vector math library.
- SLEEFGNUABI, // SLEEF - SIMD Library for Evaluating Elementary Functions.
- ArmPL, // Arm Performance Libraries.
- AMDLIBM // AMD Math Vector library.
- };
-
TargetLibraryInfoImpl() = delete;
LLVM_ABI explicit TargetLibraryInfoImpl(const Triple &T);
diff --git a/llvm/include/llvm/IR/SystemLibraries.h b/llvm/include/llvm/IR/SystemLibraries.h
new file mode 100644
index 0000000000000..1713b07c1c86f
--- /dev/null
+++ b/llvm/include/llvm/IR/SystemLibraries.h
@@ -0,0 +1,39 @@
+//===------------------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_IR_SYSTEMLIBRARIES_H
+#define LLVM_IR_SYSTEMLIBRARIES_H
+
+namespace llvm {
+/// List of known vector-functions libraries.
+///
+/// The vector-functions library defines, which functions are vectorizable
+/// and with which factor. The library can be specified by either frontend,
+/// or a commandline option, and then used by
+/// addVectorizableFunctionsFromVecLib for filling up the tables of
+/// vectorizable functions.
+enum class VectorLibrary {
+ NoLibrary, // Don't use any vector library.
+ Accelerate, // Use Accelerate framework.
+ DarwinLibSystemM, // Use Darwin's libsystem_m.
+ LIBMVEC, // GLIBC Vector Math library.
+ MASSV, // IBM MASS vector library.
+ SVML, // Intel short vector math library.
+ SLEEFGNUABI, // SLEEF - SIMD Library for Evaluating Elementary Functions.
+ ArmPL, // Arm Performance Libraries.
+ AMDLIBM // AMD Math Vector library.
+};
+
+/// Command line flag value for the vector math library to use
+///
+/// FIXME: This should come from a module flag, and not be mutually exclusive
+extern VectorLibrary ClVectorLibrary;
+
+} // namespace llvm
+
+#endif // LLVM_IR_SYSTEMLIBRARIES_H
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 74f3a7d131c35..f97abc9a32707 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -15,33 +15,11 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/SystemLibraries.h"
#include "llvm/InitializePasses.h"
-#include "llvm/Support/CommandLine.h"
#include "llvm/TargetParser/Triple.h"
using namespace llvm;
-static cl::opt<TargetLibraryInfoImpl::VectorLibrary> ClVectorLibrary(
- "vector-library", cl::Hidden, cl::desc("Vector functions library"),
- cl::init(TargetLibraryInfoImpl::NoLibrary),
- cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary, "none",
- "No vector functions library"),
- clEnumValN(TargetLibraryInfoImpl::Accelerate, "Accelerate",
- "Accelerate framework"),
- clEnumValN(TargetLibraryInfoImpl::DarwinLibSystemM,
- "Darwin_libsystem_m", "Darwin libsystem_m"),
- clEnumValN(TargetLibraryInfoImpl::LIBMVEC, "LIBMVEC",
- "GLIBC Vector Math library"),
- clEnumValN(TargetLibraryInfoImpl::MASSV, "MASSV",
- "IBM MASS vector library"),
- clEnumValN(TargetLibraryInfoImpl::SVML, "SVML",
- "Intel SVML library"),
- clEnumValN(TargetLibraryInfoImpl::SLEEFGNUABI, "sleefgnuabi",
- "SIMD Library for Evaluating Elementary Functions"),
- clEnumValN(TargetLibraryInfoImpl::ArmPL, "ArmPL",
- "Arm Performance Libraries"),
- clEnumValN(TargetLibraryInfoImpl::AMDLIBM, "AMDLIBM",
- "AMD vector math library")));
-
StringLiteral const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] =
{
#define TLI_DEFINE_STRING
@@ -1392,15 +1370,15 @@ const VecDesc VecFuncs_AMDLIBM[] = {
void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
enum VectorLibrary VecLib, const llvm::Triple &TargetTriple) {
switch (VecLib) {
- case Accelerate: {
+ case VectorLibrary::Accelerate: {
addVectorizableFunctions(VecFuncs_Accelerate);
break;
}
- case DarwinLibSystemM: {
+ case VectorLibrary::DarwinLibSystemM: {
addVectorizableFunctions(VecFuncs_DarwinLibSystemM);
break;
}
- case LIBMVEC: {
+ case VectorLibrary::LIBMVEC: {
switch (TargetTriple.getArch()) {
default:
break;
@@ -1415,15 +1393,15 @@ void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
}
break;
}
- case MASSV: {
+ case VectorLibrary::MASSV: {
addVectorizableFunctions(VecFuncs_MASSV);
break;
}
- case SVML: {
+ case VectorLibrary::SVML: {
addVectorizableFunctions(VecFuncs_SVML);
break;
}
- case SLEEFGNUABI: {
+ case VectorLibrary::SLEEFGNUABI: {
switch (TargetTriple.getArch()) {
default:
break;
@@ -1439,7 +1417,7 @@ void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
}
break;
}
- case ArmPL: {
+ case VectorLibrary::ArmPL: {
switch (TargetTriple.getArch()) {
default:
break;
@@ -1450,11 +1428,11 @@ void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
}
break;
}
- case AMDLIBM: {
+ case VectorLibrary::AMDLIBM: {
addVectorizableFunctions(VecFuncs_AMDLIBM);
break;
}
- case NoLibrary:
+ case VectorLibrary::NoLibrary:
break;
}
}
diff --git a/llvm/lib/IR/CMakeLists.txt b/llvm/lib/IR/CMakeLists.txt
index 10572ff708bd3..ebdc2ca08d102 100644
--- a/llvm/lib/IR/CMakeLists.txt
+++ b/llvm/lib/IR/CMakeLists.txt
@@ -67,6 +67,7 @@ add_llvm_component_library(LLVMCore
ReplaceConstant.cpp
Statepoint.cpp
StructuralHash.cpp
+ SystemLibraries.cpp
Type.cpp
TypedPointerType.cpp
TypeFinder.cpp
diff --git a/llvm/lib/IR/SystemLibraries.cpp b/llvm/lib/IR/SystemLibraries.cpp
new file mode 100644
index 0000000000000..fa4ac2adb7296
--- /dev/null
+++ b/llvm/lib/IR/SystemLibraries.cpp
@@ -0,0 +1,34 @@
+//===-----------------------------------------------------------------------==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IR/SystemLibraries.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+
+VectorLibrary llvm::ClVectorLibrary;
+
+static cl::opt<VectorLibrary, true> ClVectorLibraryOpt(
+ "vector-library", cl::Hidden, cl::desc("Vector functions library"),
+ cl::location(llvm::ClVectorLibrary), cl::init(VectorLibrary::NoLibrary),
+ cl::values(
+ clEnumValN(VectorLibrary::NoLibrary, "none",
+ "No vector functions library"),
+ clEnumValN(VectorLibrary::Accelerate, "Accelerate",
+ "Accelerate framework"),
+ clEnumValN(VectorLibrary::DarwinLibSystemM, "Darwin_libsystem_m",
+ "Darwin libsystem_m"),
+ clEnumValN(VectorLibrary::LIBMVEC, "LIBMVEC",
+ "GLIBC Vector Math library"),
+ clEnumValN(VectorLibrary::MASSV, "MASSV", "IBM MASS vector library"),
+ clEnumValN(VectorLibrary::SVML, "SVML", "Intel SVML library"),
+ clEnumValN(VectorLibrary::SLEEFGNUABI, "sleefgnuabi",
+ "SIMD Library for Evaluating Elementary Functions"),
+ clEnumValN(VectorLibrary::ArmPL, "ArmPL", "Arm Performance Libraries"),
+ clEnumValN(VectorLibrary::AMDLIBM, "AMDLIBM",
+ "AMD vector math library")));
|
Move this to a new shared header to facilitate the eventual merger of RuntimeLibcallsInfo and TargetLibraryInfo. Ideally this would be replaced iwth a module flag. For now put it into a common header both can use.
1dc6659 to
065c7e7
Compare
RKSimon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* main: (63 commits) [libc++] Inline vector::__append into resize (llvm#162086) [Flang][OpenMP] Move char box bounds generation for Maps to DirectiveCommons.h (llvm#165918) RuntimeLibcalls: Add entries for vector sincospi functions (llvm#166981) [X86] _mm_addsub_pd is not valid for constexpr (llvm#167363) [CIR] Re-land: Recognize constant aggregate initialization of auto vars (llvm#167033) [gn build] Port d2521f1 [gn build] Port caed089 [gn build] Port 315d705 [gn build] Port 2345b7d [PowerPC] convert memmove to milicode call .___memmove64[PR] in 64-bit mode (llvm#167334) [HLSL] Add internal linkage attribute to resources (llvm#166844) AMDGPU: Update test after e95f6fa [bazel] Port llvm#166980: TLI/VectorLibrary refactor (llvm#167354) [libc++] Split macros related to hardening into their own header (llvm#167069) [libc++][NFC] Remove unused imports from generate_feature_test_macro_components.py (llvm#159591) [CIR][NFC] Add test for Complex imag with GUN extension (llvm#167215) [BOLT][AArch64] Add more heuristics on epilogue determination (llvm#167077) RegisterCoalescer: Enable terminal rule by default for AMDGPU (llvm#161621) Revert "[clang] Refactor option-related code from clangDriver into new clangOptions library" (llvm#167348) [libc++][docs] Update to refer to P3355R2 (llvm#167267) ...

Move this to a new shared header to facilitate the eventual
merger of RuntimeLibcallsInfo and TargetLibraryInfo. Ideally
this would be replaced with a module flag. For now put it into
a common header both can use.