Skip to content

Commit 78ba7ab

Browse files
committed
[libc][stdfix] Initial support for stdfix.h and fixed point arithmetic.
1 parent 0d7f232 commit 78ba7ab

37 files changed

+1062
-1
lines changed

libc/cmake/modules/CheckCompilerFeatures.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ------------------------------------------------------------------------------
44

55
# Initialize ALL_COMPILER_FEATURES as empty list.
6-
set(ALL_COMPILER_FEATURES "float128")
6+
set(ALL_COMPILER_FEATURES "float128" "fixedpoint")
77

88
# Making sure ALL_COMPILER_FEATURES is sorted.
99
list(SORT ALL_COMPILER_FEATURES)
@@ -52,6 +52,8 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES)
5252
list(APPEND AVAILABLE_COMPILER_FEATURES ${feature})
5353
if(${feature} STREQUAL "float128")
5454
set(LIBC_COMPILER_HAS_FLOAT128 TRUE)
55+
elseif(${feature} STREQUAL "fixedpoint")
56+
set(LIBC_COMPILER_HAS_FIXED_POINT TRUE)
5557
endif()
5658
endif()
5759
endforeach()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "include/llvm-libc-types/stdfix_types.h"
2+
3+
#ifndef LIBC_COMPILER_HAS_FIXED_POINT
4+
#error unsupported
5+
#endif

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,18 @@ if(LIBC_COMPILER_HAS_FLOAT128)
419419
)
420420
endif()
421421

422+
if(LIBC_COMPILER_HAS_FIXED_POINT)
423+
list(APPEND TARGET_LIBM_ENTRYPOINTS
424+
# stdfix.h N1169 _Fract and _Accum entrypoints
425+
libc.src.stdfix.abshk
426+
libc.src.stdfix.abshr
427+
libc.src.stdfix.absk
428+
libc.src.stdfix.absr
429+
libc.src.stdfix.abslk
430+
libc.src.stdfix.abslr
431+
)
432+
endif()
433+
422434
if(LLVM_LIBC_FULL_BUILD)
423435
list(APPEND TARGET_LIBC_ENTRYPOINTS
424436
# assert.h entrypoints

libc/include/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ add_gen_header(
104104
.llvm-libc-types.float128
105105
)
106106

107+
add_gen_header(
108+
stdfix
109+
DEF_FILE stdfix.h.def
110+
GEN_HDR stdfix.h
111+
DEPENDS
112+
.llvm-libc-macros.stdfix_macros
113+
.llvm-libc-types.stdfix_types
114+
)
115+
107116
# TODO: This should be conditional on POSIX networking being included.
108117
file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/arpa)
109118

libc/include/llvm-libc-macros/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,9 @@ add_macro_header(
227227
HDR
228228
inttypes-macros.h
229229
)
230+
231+
add_macro_header(
232+
stdfix_macros
233+
HDR
234+
stdfix-macros.h
235+
)

0 commit comments

Comments
 (0)