Skip to content

Commit 0c1c37b

Browse files
authored
[TLI] Add support for the tgamma libcall. (#113791)
This patch adds the `tgamma` libcall.
1 parent 6128ff6 commit 0c1c37b

File tree

5 files changed

+46
-4
lines changed

5 files changed

+46
-4
lines changed

llvm/include/llvm/Analysis/TargetLibraryInfo.def

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,21 @@ TLI_DEFINE_ENUM_INTERNAL(erfl)
11401140
TLI_DEFINE_STRING_INTERNAL("erfl")
11411141
TLI_DEFINE_SIG_INTERNAL(LDbl, LDbl)
11421142

1143+
/// double tgamma(double x);
1144+
TLI_DEFINE_ENUM_INTERNAL(tgamma)
1145+
TLI_DEFINE_STRING_INTERNAL("tgamma")
1146+
TLI_DEFINE_SIG_INTERNAL(Dbl, Dbl)
1147+
1148+
/// float tgammaf(float x);
1149+
TLI_DEFINE_ENUM_INTERNAL(tgammaf)
1150+
TLI_DEFINE_STRING_INTERNAL("tgammaf")
1151+
TLI_DEFINE_SIG_INTERNAL(Flt, Flt)
1152+
1153+
/// long double tgammal(long double x);
1154+
TLI_DEFINE_ENUM_INTERNAL(tgammal)
1155+
TLI_DEFINE_STRING_INTERNAL("tgammal")
1156+
TLI_DEFINE_SIG_INTERNAL(LDbl, LDbl)
1157+
11431158
/// int execl(const char *path, const char *arg, ...);
11441159
TLI_DEFINE_ENUM_INTERNAL(execl)
11451160
TLI_DEFINE_STRING_INTERNAL("execl")

llvm/lib/Transforms/Utils/BuildLibCalls.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,9 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
11791179
case LibFunc_erf:
11801180
case LibFunc_erff:
11811181
case LibFunc_erfl:
1182+
case LibFunc_tgamma:
1183+
case LibFunc_tgammaf:
1184+
case LibFunc_tgammal:
11821185
case LibFunc_exp:
11831186
case LibFunc_expf:
11841187
case LibFunc_expl:

llvm/test/Transforms/InferFunctionAttrs/annotate.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,15 @@ declare float @logf(float)
667667
; CHECK: declare x86_fp80 @logl(x86_fp80) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
668668
declare x86_fp80 @logl(x86_fp80)
669669

670+
; CHECK: declare double @tgamma(double) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
671+
declare double @tgamma(double)
672+
673+
; CHECK: declare float @tgammaf(float) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
674+
declare float @tgammaf(float)
675+
676+
; CHECK: declare x86_fp80 @tgammal(x86_fp80) [[NOFREE_NOUNWIND_WILLRETURN_WRITEONLY]]
677+
declare x86_fp80 @tgammal(x86_fp80)
678+
670679
; CHECK: declare noundef i32 @lstat(ptr nocapture noundef readonly, ptr nocapture noundef) [[NOFREE_NOUNWIND]]
671680
declare i32 @lstat(ptr, ptr)
672681

llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#
3535
# CHECK: << Total TLI yes SDK no: 18
3636
# CHECK: >> Total TLI no SDK yes: 0
37-
# CHECK: == Total TLI yes SDK yes: 265
37+
# CHECK: == Total TLI yes SDK yes: 268
3838
#
3939
# WRONG_DETAIL: << TLI yes SDK no : '_ZdaPv' aka operator delete[](void*)
4040
# WRONG_DETAIL: >> TLI no SDK yes: '_ZdaPvj' aka operator delete[](void*, unsigned int)
@@ -48,14 +48,14 @@
4848
# WRONG_DETAIL: << TLI yes SDK no : 'fminimum_numl'
4949
# WRONG_SUMMARY: << Total TLI yes SDK no: 19{{$}}
5050
# WRONG_SUMMARY: >> Total TLI no SDK yes: 1{{$}}
51-
# WRONG_SUMMARY: == Total TLI yes SDK yes: 264
51+
# WRONG_SUMMARY: == Total TLI yes SDK yes: 267
5252
#
5353
## The -COUNT suffix doesn't care if there are too many matches, so check
5454
## the exact count first; the two directives should add up to that.
5555
## Yes, this means additions to TLI will fail this test, but the argument
5656
## to -COUNT can't be an expression.
57-
# AVAIL: TLI knows 516 symbols, 283 available
58-
# AVAIL-COUNT-283: {{^}} available
57+
# AVAIL: TLI knows 519 symbols, 286 available
58+
# AVAIL-COUNT-286: {{^}} available
5959
# AVAIL-NOT: {{^}} available
6060
# UNAVAIL-COUNT-233: not available
6161
# UNAVAIL-NOT: not available
@@ -390,6 +390,18 @@ DynamicSymbols:
390390
Type: STT_FUNC
391391
Section: .text
392392
Binding: STB_GLOBAL
393+
- Name: tgamma
394+
Type: STT_FUNC
395+
Section: .text
396+
Binding: STB_GLOBAL
397+
- Name: tgammaf
398+
Type: STT_FUNC
399+
Section: .text
400+
Binding: STB_GLOBAL
401+
- Name: tgammal
402+
Type: STT_FUNC
403+
Section: .text
404+
Binding: STB_GLOBAL
393405
- Name: exp
394406
Type: STT_FUNC
395407
Section: .text

llvm/unittests/Analysis/TargetLibraryInfoTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ TEST_F(TargetLibraryInfoTest, ValidProto) {
303303
"declare double @erf(double)\n"
304304
"declare float @erff(float)\n"
305305
"declare x86_fp80 @erfl(x86_fp80)\n"
306+
"declare double @tgamma(double)\n"
307+
"declare float @tgammaf(float)\n"
308+
"declare x86_fp80 @tgammal(x86_fp80)\n"
306309
"declare i32 @printf(i8*, ...)\n"
307310
"declare i32 @putc(i32, %struct*)\n"
308311
"declare i32 @putc_unlocked(i32, %struct*)\n"

0 commit comments

Comments
 (0)