Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Showing
14 changed files
with
162 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
include "config/public_api.td" | ||
|
||
include "spec/stdc.td" | ||
|
||
def NullMacro : MacroDef<"NULL"> { | ||
let Defn = [{ | ||
#define __need_NULL | ||
#include <stddef.h> | ||
}]; | ||
} | ||
|
||
def StringAPI : PublicAPI<"string.h"> { | ||
let Types = ["size_t"]; | ||
|
||
let Macros = [ | ||
NullMacro, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
set(TARGET_LIBC_ENTRYPOINTS | ||
# ctype.h entrypoints | ||
libc.src.ctype.isalnum | ||
libc.src.ctype.isalpha | ||
libc.src.ctype.isascii | ||
libc.src.ctype.isblank | ||
libc.src.ctype.iscntrl | ||
libc.src.ctype.isdigit | ||
libc.src.ctype.isgraph | ||
libc.src.ctype.islower | ||
libc.src.ctype.isprint | ||
libc.src.ctype.ispunct | ||
libc.src.ctype.isspace | ||
libc.src.ctype.isupper | ||
libc.src.ctype.isxdigit | ||
libc.src.ctype.toascii | ||
libc.src.ctype.tolower | ||
libc.src.ctype.toupper | ||
|
||
# string.h entrypoints | ||
libc.src.string.bcmp | ||
libc.src.string.bzero | ||
libc.src.string.memccpy | ||
libc.src.string.memchr | ||
libc.src.string.memcmp | ||
libc.src.string.memcpy | ||
libc.src.string.memmove | ||
libc.src.string.mempcpy | ||
libc.src.string.memrchr | ||
libc.src.string.memset | ||
libc.src.string.stpcpy | ||
libc.src.string.stpncpy | ||
libc.src.string.strcat | ||
libc.src.string.strchr | ||
libc.src.string.strcmp | ||
libc.src.string.strcpy | ||
libc.src.string.strcspn | ||
libc.src.string.strlcat | ||
libc.src.string.strlcpy | ||
libc.src.string.strlen | ||
libc.src.string.strncat | ||
libc.src.string.strncmp | ||
libc.src.string.strncpy | ||
libc.src.string.strnlen | ||
libc.src.string.strpbrk | ||
libc.src.string.strrchr | ||
libc.src.string.strspn | ||
libc.src.string.strstr | ||
libc.src.string.strtok | ||
libc.src.string.strtok_r | ||
) | ||
|
||
set(TARGET_LLVMLIBC_ENTRYPOINTS | ||
${TARGET_LIBC_ENTRYPOINTS} | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
set(TARGET_PUBLIC_HEADERS | ||
libc.include.ctype | ||
libc.include.string | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters