Skip to content

Commit c740e3f

Browse files
committed
Add new getLibFunc method to TargetLibraryInfo.
This just provides a way to look up a LibFunc::Func enum value for a function name. Alphabetize the enums and function names so we can use a binary search. llvm-svn: 161231
1 parent 4705da9 commit c740e3f

File tree

2 files changed

+127
-104
lines changed

2 files changed

+127
-104
lines changed

llvm/include/llvm/Target/TargetLibraryInfo.h

Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,47 @@ namespace llvm {
1818

1919
namespace LibFunc {
2020
enum Func {
21+
/// int __cxa_atexit(void (*f)(void *), void *p, void *d);
22+
cxa_atexit,
23+
/// void __cxa_guard_abort(guard_t *guard);
24+
/// guard_t is int64_t in Itanium ABI or int32_t on ARM eabi.
25+
cxa_guard_abort,
26+
/// int __cxa_guard_acquire(guard_t *guard);
27+
cxa_guard_acquire,
28+
/// void __cxa_guard_release(guard_t *guard);
29+
cxa_guard_release,
30+
/// void *__memcpy_chk(void *s1, const void *s2, size_t n, size_t s1size);
31+
memcpy_chk,
2132
/// double acos(double x);
2233
acos,
23-
/// long double acosl(long double x);
24-
acosl,
2534
/// float acosf(float x);
2635
acosf,
36+
/// long double acosl(long double x);
37+
acosl,
2738
/// double asin(double x);
2839
asin,
29-
/// long double asinl(long double x);
30-
asinl,
3140
/// float asinf(float x);
3241
asinf,
42+
/// long double asinl(long double x);
43+
asinl,
3344
/// double atan(double x);
3445
atan,
35-
/// long double atanl(long double x);
36-
atanl,
37-
/// float atanf(float x);
38-
atanf,
3946
/// double atan2(double y, double x);
4047
atan2,
41-
/// long double atan2l(long double y, long double x);
42-
atan2l,
4348
/// float atan2f(float y, float x);
4449
atan2f,
50+
/// long double atan2l(long double y, long double x);
51+
atan2l,
52+
/// float atanf(float x);
53+
atanf,
54+
/// long double atanl(long double x);
55+
atanl,
4556
/// double ceil(double x);
4657
ceil,
47-
/// long double ceill(long double x);
48-
ceill,
4958
/// float ceilf(float x);
5059
ceilf,
60+
/// long double ceill(long double x);
61+
ceill,
5162
/// double copysign(double x, double y);
5263
copysign,
5364
/// float copysignf(float x, float y);
@@ -56,54 +67,54 @@ namespace llvm {
5667
copysignl,
5768
/// double cos(double x);
5869
cos,
59-
/// long double cosl(long double x);
60-
cosl,
6170
/// float cosf(float x);
6271
cosf,
6372
/// double cosh(double x);
6473
cosh,
65-
/// long double coshl(long double x);
66-
coshl,
6774
/// float coshf(float x);
6875
coshf,
76+
/// long double coshl(long double x);
77+
coshl,
78+
/// long double cosl(long double x);
79+
cosl,
6980
/// double exp(double x);
7081
exp,
71-
/// long double expl(long double x);
72-
expl,
73-
/// float expf(float x);
74-
expf,
7582
/// double exp2(double x);
7683
exp2,
77-
/// long double exp2l(long double x);
78-
exp2l,
7984
/// float exp2f(float x);
8085
exp2f,
86+
/// long double exp2l(long double x);
87+
exp2l,
88+
/// float expf(float x);
89+
expf,
90+
/// long double expl(long double x);
91+
expl,
8192
/// double expm1(double x);
8293
expm1,
83-
/// long double expm1l(long double x);
84-
expm1l,
8594
/// float expm1f(float x);
8695
expm1f,
96+
/// long double expm1l(long double x);
97+
expm1l,
8798
/// double fabs(double x);
8899
fabs,
89-
/// long double fabsl(long double x);
90-
fabsl,
91100
/// float fabsf(float x);
92101
fabsf,
102+
/// long double fabsl(long double x);
103+
fabsl,
104+
/// int fiprintf(FILE *stream, const char *format, ...);
105+
fiprintf,
93106
/// double floor(double x);
94107
floor,
95-
/// long double floorl(long double x);
96-
floorl,
97108
/// float floorf(float x);
98109
floorf,
99-
/// int fiprintf(FILE *stream, const char *format, ...);
100-
fiprintf,
110+
/// long double floorl(long double x);
111+
floorl,
101112
/// double fmod(double x, double y);
102113
fmod,
103-
/// long double fmodl(long double x, long double y);
104-
fmodl,
105114
/// float fmodf(float x, float y);
106115
fmodf,
116+
/// long double fmodl(long double x, long double y);
117+
fmodl,
107118
/// int fputc(int c, FILE *stream);
108119
fputc,
109120
/// int fputs(const char *s, FILE *stream);
@@ -115,28 +126,28 @@ namespace llvm {
115126
iprintf,
116127
/// double log(double x);
117128
log,
118-
/// long double logl(long double x);
119-
logl,
120-
/// float logf(float x);
121-
logf,
122-
/// double log2(double x);
123-
log2,
124-
/// double long double log2l(long double x);
125-
log2l,
126-
/// float log2f(float x);
127-
log2f,
128129
/// double log10(double x);
129130
log10,
130-
/// long double log10l(long double x);
131-
log10l,
132131
/// float log10f(float x);
133132
log10f,
133+
/// long double log10l(long double x);
134+
log10l,
134135
/// double log1p(double x);
135136
log1p,
136-
/// long double log1pl(long double x);
137-
log1pl,
138137
/// float log1pf(float x);
139138
log1pf,
139+
/// long double log1pl(long double x);
140+
log1pl,
141+
/// double log2(double x);
142+
log2,
143+
/// float log2f(float x);
144+
log2f,
145+
/// double long double log2l(long double x);
146+
log2l,
147+
/// float logf(float x);
148+
logf,
149+
/// long double logl(long double x);
150+
logl,
140151
/// void *memchr(const void *s, int c, size_t n);
141152
memchr,
142153
/// int memcmp(const void *s1, const void *s2, size_t n);
@@ -179,24 +190,24 @@ namespace llvm {
179190
roundl,
180191
/// double sin(double x);
181192
sin,
182-
/// long double sinl(long double x);
183-
sinl,
184193
/// float sinf(float x);
185194
sinf,
186195
/// double sinh(double x);
187196
sinh,
188-
/// long double sinhl(long double x);
189-
sinhl,
190197
/// float sinhf(float x);
191198
sinhf,
199+
/// long double sinhl(long double x);
200+
sinhl,
201+
/// long double sinl(long double x);
202+
sinl,
192203
/// int siprintf(char *str, const char *format, ...);
193204
siprintf,
194205
/// double sqrt(double x);
195206
sqrt,
196-
/// long double sqrtl(long double x);
197-
sqrtl,
198207
/// float sqrtf(float x);
199208
sqrtf,
209+
/// long double sqrtl(long double x);
210+
sqrtl,
200211
/// char *strcat(char *s1, const char *s2);
201212
strcat,
202213
/// char *strchr(const char *s, int c);
@@ -215,33 +226,22 @@ namespace llvm {
215226
strnlen,
216227
/// double tan(double x);
217228
tan,
218-
/// long double tanl(long double x);
219-
tanl,
220229
/// float tanf(float x);
221230
tanf,
222231
/// double tanh(double x);
223232
tanh,
224-
/// long double tanhl(long double x);
225-
tanhl,
226233
/// float tanhf(float x);
227234
tanhf,
235+
/// long double tanhl(long double x);
236+
tanhl,
237+
/// long double tanl(long double x);
238+
tanl,
228239
/// double trunc(double x);
229240
trunc,
230241
/// float truncf(float x);
231242
truncf,
232243
/// long double truncl(long double x);
233244
truncl,
234-
/// int __cxa_atexit(void (*f)(void *), void *p, void *d);
235-
cxa_atexit,
236-
/// void __cxa_guard_abort(guard_t *guard);
237-
/// guard_t is int64_t in Itanium ABI or int32_t on ARM eabi.
238-
cxa_guard_abort,
239-
/// int __cxa_guard_acquire(guard_t *guard);
240-
cxa_guard_acquire,
241-
/// void __cxa_guard_release(guard_t *guard);
242-
cxa_guard_release,
243-
/// void *__memcpy_chk(void *s1, const void *s2, size_t n, size_t s1size);
244-
memcpy_chk,
245245

246246
NumLibFuncs
247247
};
@@ -275,6 +275,10 @@ class TargetLibraryInfo : public ImmutablePass {
275275
TargetLibraryInfo(const Triple &T);
276276
explicit TargetLibraryInfo(const TargetLibraryInfo &TLI);
277277

278+
/// getLibFunc - Search for a particular function name. If it is one of the
279+
/// known library functions, return true and set F to the corresponding value.
280+
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const;
281+
278282
/// has - This function is used by optimizations that want to match on or form
279283
/// a given library function.
280284
bool has(LibFunc::Func F) const {

0 commit comments

Comments
 (0)