Skip to content

Commit 5525a44

Browse files
committed
Add fxbits functions to be generated into stdfix.h: Add each function to
stdfix.yaml, and to entrypoints.txt for each target that supports stdfix. Also create files to be filled in.
1 parent 5545f76 commit 5525a44

30 files changed

+171
-1
lines changed

libc/config/baremetal/arm/entrypoints.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT)
455455
libc.src.stdfix.sqrtulr
456456
libc.src.stdfix.uhksqrtus
457457
libc.src.stdfix.uksqrtui
458+
libc.src.stdfix.hrbits
459+
libc.src.stdfix.uhrbits
460+
libc.src.stdfix.rbits
461+
libc.src.stdfix.urbits
462+
libc.src.stdfix.lrbits
463+
libc.src.stdfix.ulrbits
464+
libc.src.stdfix.hkbits
465+
libc.src.stdfix.uhkbits
466+
libc.src.stdfix.kbits
467+
libc.src.stdfix.ukbits
468+
libc.src.stdfix.lkbits
469+
libc.src.stdfix.ulkbits
458470
)
459471
endif()
460472

libc/config/baremetal/riscv/entrypoints.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT)
450450
libc.src.stdfix.sqrtulr
451451
libc.src.stdfix.uhksqrtus
452452
libc.src.stdfix.uksqrtui
453+
libc.src.stdfix.hrbits
454+
libc.src.stdfix.uhrbits
455+
libc.src.stdfix.rbits
456+
libc.src.stdfix.urbits
457+
libc.src.stdfix.lrbits
458+
libc.src.stdfix.ulrbits
459+
libc.src.stdfix.hkbits
460+
libc.src.stdfix.uhkbits
461+
libc.src.stdfix.kbits
462+
libc.src.stdfix.ukbits
463+
libc.src.stdfix.lkbits
464+
libc.src.stdfix.ulkbits
453465
)
454466
endif()
455467

libc/config/linux/riscv/entrypoints.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT)
704704
libc.src.stdfix.sqrtulr
705705
libc.src.stdfix.uhksqrtus
706706
libc.src.stdfix.uksqrtui
707+
libc.src.stdfix.hrbits
708+
libc.src.stdfix.uhrbits
709+
libc.src.stdfix.rbits
710+
libc.src.stdfix.urbits
711+
libc.src.stdfix.lrbits
712+
libc.src.stdfix.ulrbits
713+
libc.src.stdfix.hkbits
714+
libc.src.stdfix.uhkbits
715+
libc.src.stdfix.kbits
716+
libc.src.stdfix.ukbits
717+
libc.src.stdfix.lkbits
718+
libc.src.stdfix.ulkbits
707719
)
708720
endif()
709721

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,18 @@ if(LIBC_COMPILER_HAS_FIXED_POINT)
808808
libc.src.stdfix.sqrtulr
809809
libc.src.stdfix.uhksqrtus
810810
libc.src.stdfix.uksqrtui
811+
libc.src.stdfix.hrbits
812+
libc.src.stdfix.uhrbits
813+
libc.src.stdfix.rbits
814+
libc.src.stdfix.urbits
815+
libc.src.stdfix.lrbits
816+
libc.src.stdfix.ulrbits
817+
libc.src.stdfix.hkbits
818+
libc.src.stdfix.uhkbits
819+
libc.src.stdfix.kbits
820+
libc.src.stdfix.ukbits
821+
libc.src.stdfix.lkbits
822+
libc.src.stdfix.ulkbits
811823
)
812824
endif()
813825

libc/newhdrgen/yaml/stdfix.yaml

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
header: stdfix.h
22
macros: []
3-
types: []
3+
types:
4+
- type_name: stdfix_t
45
enums: []
56
objects: []
67
functions:
@@ -62,6 +63,90 @@ functions:
6263
arguments:
6364
- type: accum
6465
guard: LIBC_COMPILER_HAS_FIXED_POINT
66+
- name: hrbits
67+
standards:
68+
- stdc_ext
69+
return_type: short fract
70+
arguments:
71+
- type: int_hr_t
72+
guard: LIBC_COMPILER_HAS_FIXED_POINT
73+
- name: uhrbits
74+
standards:
75+
- stdc_ext
76+
return_type: unsigned short fract
77+
arguments:
78+
- type: uint_uhr_t
79+
guard: LIBC_COMPILER_HAS_FIXED_POINT
80+
- name: rbits
81+
standards:
82+
- stdc_ext
83+
return_type: fract
84+
arguments:
85+
- type: int_r_t
86+
guard: LIBC_COMPILER_HAS_FIXED_POINT
87+
- name: urbits
88+
standards:
89+
- stdc_ext
90+
return_type: unsigned fract
91+
arguments:
92+
- type: uint_ur_t
93+
guard: LIBC_COMPILER_HAS_FIXED_POINT
94+
- name: lrbits
95+
standards:
96+
- stdc_ext
97+
return_type: long fract
98+
arguments:
99+
- type: int_lr_t
100+
guard: LIBC_COMPILER_HAS_FIXED_POINT
101+
- name: ulrbits
102+
standards:
103+
- stdc_ext
104+
return_type: unsigned long fract
105+
arguments:
106+
- type: uint_ulr_t
107+
guard: LIBC_COMPILER_HAS_FIXED_POINT
108+
- name: hkbits
109+
standards:
110+
- stdc_ext
111+
return_type: short accum
112+
arguments:
113+
- type: int_hk_t
114+
guard: LIBC_COMPILER_HAS_FIXED_POINT
115+
- name: uhkbits
116+
standards:
117+
- stdc_ext
118+
return_type: unsigned short accum
119+
arguments:
120+
- type: uint_uhk_t
121+
guard: LIBC_COMPILER_HAS_FIXED_POINT
122+
- name: kbits
123+
standards:
124+
- stdc_ext
125+
return_type: accum
126+
arguments:
127+
- type: int_k_t
128+
guard: LIBC_COMPILER_HAS_FIXED_POINT
129+
- name: ukbits
130+
standards:
131+
- stdc_ext
132+
return_type: unsigned accum
133+
arguments:
134+
- type: uint_uk_t
135+
guard: LIBC_COMPILER_HAS_FIXED_POINT
136+
- name: lkbits
137+
standards:
138+
- stdc_ext
139+
return_type: long accum
140+
arguments:
141+
- type: uint_ulr_t
142+
guard: LIBC_COMPILER_HAS_FIXED_POINT
143+
- name: ulkbits
144+
standards:
145+
- stdc_ext
146+
return_type: unsigned long accum
147+
arguments:
148+
- type: uint_ulk_t
149+
guard: LIBC_COMPILER_HAS_FIXED_POINT
65150
- name: roundhk
66151
standards:
67152
- stdc_ext

libc/src/stdfix/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk)
4444
)
4545
endforeach()
4646

47+
foreach(prefix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk)
48+
add_entrypoint_object(
49+
${prefix}bits
50+
HDRS
51+
${prefix}bits.h
52+
SRCS
53+
${prefix}bits.cpp
54+
COMPILE_OPTIONS
55+
-O3
56+
DEPENDS
57+
libc.src.__support.fixed_point.fx_bits
58+
)
59+
endforeach()
60+
4761
add_entrypoint_object(
4862
uhksqrtus
4963
HDRS

libc/src/stdfix/hkbits.cpp

Whitespace-only changes.

libc/src/stdfix/hkbits.h

Whitespace-only changes.

libc/src/stdfix/hrbits.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "hrbits.h"
2+
#include "src/__support/common.h"
3+
#include "src/__support/fixed_point/fx_bits.h"
4+
#include "src/__support/macros/config.h"
5+
6+
namespace LIBC_NAMESPACE_DECL {
7+
8+
LLVM_LIBC_FUNCTION(short fract, hrbits, (int_hr_t x)) {
9+
return fixed_point::bits(x);
10+
}
11+
12+
}

libc/src/stdfix/hrbits.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef LLVM_LIBC_SRC_STDFIX_HRBITS_H
2+
#define LLVM_LIBC_SRC_STDFIX_HRBITS_H
3+
4+
#include "include/llvm-libc-macros/stdfix-macros.h"
5+
#include "src/__support/macros/config.h"
6+
namespace LIBC_NAMESPACE_DECL {
7+
8+
short fract hrbits(int_hr_t x);
9+
10+
}
11+
#endif

0 commit comments

Comments
 (0)