Files
clang-p2996/libc/cmake/modules/LLVMLibCArchitectures.cmake
Joseph Huber 55151e138d [libc] Add initial support for a libc implementation for the GPU
This patch contains the initial support for building LLVM's libc as a
target for the GPU. Currently this only supports a handful of very basic
functions that can be implemented without an operating system. The GPU
code is build using the existing OpenMP toolchain. This allows us to
minimally change the existing codebase and get a functioning static
library. This patch allows users to create a static library called
`libcgpu.a` that contains fat binaries containing device IR.

Current limitations are the lack of test support and the fact that only
one target OS can be built at a time. That is, the user cannot get a
`libc` for Linux and one for the GPU simultaneously.

This introduces two new CMake variables to control the behavior
`LLVM_LIBC_TARET_OS` is exported so the user can now specify it to equal
`"gpu"`. `LLVM_LIBC_GPU_ARCHITECTURES` is also used to configure how
many targets to build for at once.

Depends on D138607

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D138608
2022-11-29 14:51:54 -06:00

26 lines
1.1 KiB
CMake

# ------------------------------------------------------------------------------
# Architecture definitions
# ------------------------------------------------------------------------------
if(LIBC_TARGET_OS MATCHES "gpu")
set(LIBC_TARGET_ARCHITECTURE_IS_GPU TRUE)
set(LIBC_TARGET_ARCHITECTURE "gpu")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
set(LIBC_TARGET_ARCHITECTURE_IS_MIPS TRUE)
set(LIBC_TARGET_ARCHITECTURE "mips")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(LIBC_TARGET_ARCHITECTURE_IS_ARM TRUE)
set(LIBC_TARGET_ARCHITECTURE "arm")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
set(LIBC_TARGET_ARCHITECTURE_IS_AARCH64 TRUE)
set(LIBC_TARGET_ARCHITECTURE "aarch64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
set(LIBC_TARGET_ARCHITECTURE_IS_X86 TRUE)
set(LIBC_TARGET_ARCHITECTURE "x86_64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
set(LIBC_TARGET_ARCHITECTURE_IS_POWER TRUE)
set(LIBC_TARGET_ARCHITECTURE "power")
else()
message(FATAL_ERROR "Unsupported processor ${CMAKE_SYSTEM_PROCESSOR}")
endif()