Implement full multiplication `UInt<A> * UInt<B> -> UInt<A + B>` and
`quick_mul_hi` that returns the higher half of the product `UInt<A> * UInt<A>`.
These 2 functions will be used for dyadic floating point class.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D138541
When we search through the dependencies for a test we somtimes query
`get_target_property` on a target that has not been defined. This is the
case for targets that have minimal entrypoints defined such as the WIP
GPU target. This patch changes all tests whose dependencies are
undefined to be skipped entirely.
Reviewed By: sivachandra, lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D139216
The only safe way to implement strlen involves reading the string one
char at a time. It is faster to read in larger blocks, but this leads to
reading beyond the string boundary, which is undefined behavior. This
patch adds an implementation and flag to use this fast but unsafe
version of strlen.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D129808
Summary:
A previous change removed a transient inclusion of `stdlib.h` from the
`string_utils.h` file which this test depended on. Include it directly
here.
This patch introduces documentation for the new GPU mode added in
D138608. The documentation includes instructions for building and using
the library, along with a description of the supported functions and
headers.
Reviewed By: sivachandra, lntue, michaelrj
Differential Revision: https://reviews.llvm.org/D138856
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
The `strdup` family of functions rely on `malloc` to be implemented.
Its presence in the `string_utils.h` header meant that compiling many of
the string functions relied on `malloc` being implementated as well.
This patch simply moves the implementation into a new file to avoid
including `stdlib.h` from the other string functions. This was a barrier
for compiling string functions for the GPU where there is no malloc
currently.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D138607
This variable is derived from LLVM_DEFAULT_TARGET_TRIPLE by default,
but using a separate variable allows additional normalization to be
performed if needed.
Differential Revision: https://reviews.llvm.org/D137451
The memory functions are highly performance sensitive and use builtins
where possible, but also need to define those functions names when they
don't exist to avoid compilation errors. Previously all those
redefinitions were behind the SSE2 flag for x86, which caused errors on
CPUs that supported SSE2 but not AVX512. This patch splits the various
CPU extensions out to avoid errors on such CPUs.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D138163
This patch adds scanf, sscanf, and fscanf entrypoints. It also adds unit
tests for sscanf and a basic test to fscanf. The scanf function is
basically impossible to test in an automated fashion due to it recieving
user input.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D138076
The memory functions are highly performance sensitive and use builtins
where possible, but also need to define those functions names when they
don't exist to avoid compilation errors. Previously all those
redefinitions were behind the SSE2 flag for x86, which caused errors on
CPUs that supported SSE2 but not AVX512. This patch splits the various
CPU extensions out to avoid errors on such CPUs.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D137868
The `assert.h` and `ctype.h` headers are never built despite their
entrypoints being present in the generated library. This patch adds a
dependency on these headers so that they will be built properly.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D138142
+ Avoid the `clockid` var and just passed `long(CLOCK_REALTIME)`
to the syscall.
Reviewed By: rtenneti
Differential Revision: https://reviews.llvm.org/D138070
The mprotect test has been failing and causing significant buildbot
noise. Given that this is a simple functions it's more important that
the buildbot errors be useful than having more thorough tests for this
function.
Reviewed By: sivachandra, lntue
Differential Revision: https://reviews.llvm.org/D138061
+ Deleted duplicate definitions of StructTimeVal and StructTimeValPtr.
+ Caled syscall clock_gettime to get timespec data.
+ Added tests to test for sleeping 200 and 1000 microseconds.
+ Fixed comments from https://reviews.llvm.org/D137881
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D138064
The assert functions were disabled while the signal functions were being
fixed. This patch re-enables them.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D138056
When using `LLVM_ENABLE_RUNTIMES=libc` we need to perform a few extra
steps to include LLVM utilities similar to if we were performing a
standalone build. Libc depends on the tablegen utilities and the LLVM
libraries when performing a full build. When using an
`LLVM_ENABLE_PROJECTS=libc` build these are included as a part of the
greater LLVM build, but here we need to perform it maunally. This patch
should allow using `LLVM_LIBC_FULL_BUILD=ON` when building with
runtimes.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D138040
Implement gettimeofday per
.../onlinepubs/9699919799/functions/gettimeofday.html.
This call clock_gettime to implement gettimeofday function.
Tested:
Limited unit test: This makes a call and checks that no error was
returned. Used nanosleep for 100 microseconds and verfified it
returns a value that elapses more than 100 microseconds and less
than 300 microseconds.
Co-authored-by: Jeff Bailey <jeffbailey@google.com>
Differential Revision: https://reviews.llvm.org/D137881
Fork, as a thread function, should go in the threads folder.
Additionally, it depends on the thread mutex, and it was causing build
issues for targets where we don't support threads.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D137867
In the code
const char *str = "abc"
if you do sizeof(str) you get the size of the pointer, not the string.
This patch fixes that mistake.
Differential Revision: https://reviews.llvm.org/D137586
This patch adds the basic conversion facilities to scanf as well as unit
tests for them. It also adds scanf_main which will be used for the
eventual scanf entrypoints.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D137376
This is the interface that will be used to read from a file or string in
scanf. This patch also adds the string and file implementations of the
reader, although the file reader is not yet complete since ungetc has
not yet been implemented.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D137117
Previously, the printf parser would treat "%\0" as a conversion with the
name "\0", and advance past the null byte causing a buffer overflow.
This patch corrects that in both printf and scanf.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D137367