################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from           #
# compiler/plugins/target/LLVMCPU/BUILD.bazel                                  #
#                                                                              #
# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary   #
# CMake-only content.                                                          #
#                                                                              #
# To disable autogeneration for this file entirely, delete this header.        #
################################################################################

iree_add_all_subdirs()

iree_compiler_register_plugin(
  PLUGIN_ID
    hal_target_llvm_cpu
  TARGET
    ::LLVMCPU
)

iree_cc_library(
  NAME
    LLVMCPU
  HDRS
    "LibraryBuilder.h"
  SRCS
    "LLVMCPUTarget.cpp"
    "LibraryBuilder.cpp"
  DEPS
    ::LLVMIRPasses
    ::LLVMTargetOptions
    ::LinkerTool
    ::StaticLibraryGenerator
    IREELLVMCPUTargetDeps
    IREELinalgTransformDialect
    LLVMAnalysis
    LLVMBitReader
    LLVMBitWriter
    LLVMCore
    LLVMLinker
    LLVMSupport
    LLVMTargetParser
    MLIRArmNeonDialect
    MLIRArmSMEDialect
    MLIRArmSMEToLLVMIRTranslation
    MLIRArmSVEDialect
    MLIRArmSVEToLLVMIRTranslation
    MLIRBuiltinToLLVMIRTranslation
    MLIRIR
    MLIRLLVMDialect
    MLIRLLVMToLLVMIRTranslation
    MLIRPDLDialect
    MLIRPDLInterpDialect
    MLIRSupport
    MLIRTargetLLVMIRExport
    MLIRTransformDialect
    iree::compiler::Codegen::Common
    iree::compiler::Codegen::Dialect::CPU::IR::IREECPUDialect
    iree::compiler::Codegen::Dialect::Codegen::IR::IREECodegenDialect
    iree::compiler::Codegen::LLVMCPU
    iree::compiler::Codegen::Utils
    iree::compiler::Dialect::HAL::Target
    iree::compiler::Dialect::HAL::Target::Devices
    iree::compiler::Dialect::HAL::Utils::LLVMLinkerUtils
    iree::compiler::Dialect::LinalgExt::IR
    iree::compiler::Dialect::Util::IR
    iree::compiler::PluginAPI
    iree::compiler::Utils
    iree::compiler::plugins::target::LLVMCPU::Builtins
  PUBLIC
)

iree_cc_library(
  NAME
    LLVMIRPasses
  HDRS
    "LLVMIRPasses.h"
  SRCS
    "LLVMIRPasses.cpp"
  DEPS
    ::LLVMTargetOptions
    LLVMAnalysis
    LLVMCore
    LLVMInstrumentation
    LLVMMC
    LLVMPasses
    LLVMSupport
    LLVMTarget
    LLVMTargetParser
    MLIRSupport
  PUBLIC
)

iree_cc_library(
  NAME
    ResolveCPUAndCPUFeatures
  HDRS
    "ResolveCPUAndCPUFeatures.h"
  SRCS
    "ResolveCPUAndCPUFeatures.cpp"
  DEPS
    LLVMSupport
    LLVMTarget
    LLVMTargetParser
  PUBLIC
)

iree_cc_library(
  NAME
    LLVMTargetOptions
  HDRS
    "LLVMTargetOptions.h"
  SRCS
    "LLVMTargetOptions.cpp"
  DEPS
    ::ResolveCPUAndCPUFeatures
    LLVMAnalysis
    LLVMCore
    LLVMMC
    LLVMPasses
    LLVMSupport
    LLVMTarget
    LLVMTargetParser
    MLIRIR
    iree::compiler::Utils
  PUBLIC
)

iree_cc_library(
  NAME
    LinkerTool
  HDRS
    "LinkerTool.h"
  SRCS
    "LinkerTool.cpp"
  DEPS
    ::LLVMTargetOptions
    LLVMCore
    LLVMSupport
    LLVMTargetParser
    MLIRSupport
    iree::compiler::Utils
    iree::compiler::plugins::target::LLVMCPU::internal::LinkerTools_internal
  PUBLIC
)

iree_cc_library(
  NAME
    LinkerTool_hdrs
  HDRS
    "LinkerTool.h"
  DEPS
    ::LLVMTargetOptions
    LLVMCore
    LLVMSupport
    LLVMTargetParser
    MLIRSupport
  PUBLIC
)

iree_cc_library(
  NAME
    StaticLibraryGenerator
  HDRS
    "StaticLibraryGenerator.h"
  SRCS
    "StaticLibraryGenerator.cpp"
  DEPS
    LLVMSupport
  PUBLIC
)

### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###

add_library(IREELLVMCPUTargetDeps INTERFACE)

function(_add_optional_llvm_target_deps target)
  # Key off of the CodeGen target and then include the rest.
  # Note that for LLVM DYLIB builds, we just key off of the presence of the
  # static CodeGen target and iree_redirect_llvm_dylib_deps will replace it
  # with the dylib accordingly (it is just a check to see if we have compiled in
  # support for the target).
  if(TARGET "LLVM${target}CodeGen")
    set(_target_deps
      "LLVM${target}AsmParser"
      "LLVM${target}CodeGen"
      "LLVM${target}Desc"
      "LLVM${target}Info"
    )
    iree_redirect_llvm_dylib_deps(_target_deps)
    target_link_libraries(IREELLVMCPUTargetDeps INTERFACE ${_target_deps})
  endif()
endfunction()

# This is just the CPU backends that we hard-link to. Single-target backends
# like CUDA and ROCM bring their dependencies explicitly.
# TODO: More archaeology and tieing this to explicit top-level configuration
# of backends.
_add_optional_llvm_target_deps(AArch64)
_add_optional_llvm_target_deps(ARM)
_add_optional_llvm_target_deps(RISCV)
_add_optional_llvm_target_deps(WebAssembly)
_add_optional_llvm_target_deps(X86)
