Skip to content

Commit 2c080a3

Browse files
author
Siva Chandra Reddy
committed
[libc] Generate math.h instead of the static file it is currently.
Just enough to help a follow up patch adding cosf and sinf has been added. Reviewers: abrachet Differential Revision: https://reviews.llvm.org/D76723
1 parent 8786cdb commit 2c080a3

File tree

5 files changed

+80
-368
lines changed

5 files changed

+80
-368
lines changed

libc/config/linux/api.td

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,53 @@ def AssertAPI : PublicAPI<"assert.h"> {
7171
];
7272
}
7373

74+
def MathErrHandlingMacro : MacroDef<"math_errhandling"> {
75+
let Defn = [{
76+
#ifndef math_errhandling
77+
#ifdef __FAST_MATH__
78+
#define math_errhandling 0
79+
#elif defined __NO_MATH_ERRNO__
80+
#define math_errhandling (MATH_ERREXCEPT)
81+
#else
82+
#define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
83+
#endif
84+
#endif // math_errhandling not defined
85+
}];
86+
}
87+
88+
def IsFiniteMacro : MacroDef<"isfinite"> {
89+
let Defn = [{
90+
#define isfinite(x) __builtin_isfinite(x)
91+
}];
92+
}
93+
94+
def IsInfMacro : MacroDef<"isinf"> {
95+
let Defn = [{
96+
#define isinf(x) __builtin_isinf(x)
97+
}];
98+
}
99+
100+
def IsNanMacro : MacroDef<"isnan"> {
101+
let Defn = [{
102+
#define isnan(x) __builtin_isnan(x)
103+
}];
104+
}
105+
74106
def MathAPI : PublicAPI<"math.h"> {
107+
let Macros = [
108+
SimpleMacroDef<"MATH_ERRNO", "1">,
109+
SimpleMacroDef<"MATH_ERREXCEPT", "2">,
110+
MathErrHandlingMacro,
111+
112+
SimpleMacroDef<"INFINITY", "__builtin_inff()">,
113+
SimpleMacroDef<"NAN", "__builtin_nanf(\"\")">,
114+
115+
IsFiniteMacro,
116+
IsInfMacro,
117+
IsNanMacro,
118+
];
75119
let Functions = [
76-
"acos",
77-
"acosl",
120+
"round",
78121
];
79122
}
80123

libc/include/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ add_header(
1919
llvm_libc_common_h
2020
)
2121

22-
add_header(
22+
add_gen_header(
2323
math_h
24-
HDR
25-
math.h
24+
DEF_FILE math.h.def
25+
GEN_HDR math.h
2626
DEPENDS
2727
llvm_libc_common_h
2828
)

0 commit comments

Comments
 (0)