[mlir][sparse] Inline the definition of LLVM_ATTRIBUTE_WEAK

This library is supposed not to have a dependency on LLVM, and linking
LLVMSupport into it breaks its shared library setup.
This commit is contained in:
Benjamin Kramer 2022-06-17 22:40:00 +02:00
parent 9d5e6ccd9b
commit d5c29b23e1
2 changed files with 15 additions and 9 deletions

View File

@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//
#include "mlir/ExecutionEngine/Float16bits.h"
#include "llvm/Support/Compiler.h"
namespace {
@ -145,13 +144,23 @@ std::ostream &operator<<(std::ostream &os, const bf16 &d) {
// Provide a float->bfloat conversion routine in case the runtime doesn't have
// one.
extern "C" uint16_t LLVM_ATTRIBUTE_WEAK __truncsfbf2(float f) {
extern "C" uint16_t
#if defined(__has_attribute) && __has_attribute(weak) && \
!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32)
__attribute__((__weak__))
#endif
__truncsfbf2(float f) {
return float2bfloat(f);
}
// Provide a double->bfloat conversion routine in case the runtime doesn't have
// one.
extern "C" uint16_t LLVM_ATTRIBUTE_WEAK __truncdfbf2(double d) {
extern "C" uint16_t
#if defined(__has_attribute) && __has_attribute(weak) && \
!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32)
__attribute__((__weak__))
#endif
__truncdfbf2(double d) {
// This does a double rounding step, but it's precise enough for our use
// cases.
return __truncsfbf2(static_cast<float>(d));

View File

@ -2226,14 +2226,14 @@ cc_library(
"lib/Dialect/NVGPU/Transforms/PassDetail.h",
],
hdrs = [
"include/mlir/Dialect/NVGPU/Transforms/Transforms.h",
"include/mlir/Dialect/NVGPU/Passes.h",
"include/mlir/Dialect/NVGPU/Transforms/Transforms.h",
],
includes = ["include"],
deps = [
":FuncDialect",
":AffineDialect",
":ArithmeticDialect",
":FuncDialect",
":GPUDialect",
":IR",
":MemRefDialect",
@ -6264,8 +6264,8 @@ cc_library(
":MemRefTransforms",
":NVGPUDialect",
":NVGPUPassIncGen",
":NVGPUTransforms",
":NVGPUToNVVM",
":NVGPUTransforms",
":NVVMDialect",
":OpenACCDialect",
":OpenMPDialect",
@ -6409,9 +6409,6 @@ cc_library(
"include/mlir/ExecutionEngine/SparseTensorUtils.h",
],
includes = ["include"],
deps = [
"//llvm:Support",
],
)
cc_library(