[llvm] TableGen: Allow defining sets of runtime libraries (PR #144978)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 07:53:47 PDT 2025
================
@@ -915,58 +922,108 @@ def _Unwind_SjLj_Resume : RuntimeLibcallImpl<UNWIND_RESUME>;
// F128 libm Runtime Libcalls
//===----------------------------------------------------------------------===//
-def logf128 : RuntimeLibcallImpl<LOG_F128>;
-def log2f128 : RuntimeLibcallImpl<LOG2_F128>;
-def log10f128 : RuntimeLibcallImpl<LOG10_F128>;
-def expf128 : RuntimeLibcallImpl<EXP_F128>;
-def exp2f128 : RuntimeLibcallImpl<EXP2_F128>;
-def exp10f128 : RuntimeLibcallImpl<EXP10_F128>;
-def sinf128 : RuntimeLibcallImpl<SIN_F128>;
-def cosf128 : RuntimeLibcallImpl<COS_F128>;
-def tanf128 : RuntimeLibcallImpl<TAN_F128>;
-def tanhf128 : RuntimeLibcallImpl<TANH_F128>;
-def sincosf128 : RuntimeLibcallImpl<SINCOS_F128>;
-def powf128 : RuntimeLibcallImpl<POW_F128>;
-def fminf128 : RuntimeLibcallImpl<FMIN_F128>;
-def fmaxf128 : RuntimeLibcallImpl<FMAX_F128>;
-def fmodf128 : RuntimeLibcallImpl<REM_F128>;
-def sqrtf128 : RuntimeLibcallImpl<SQRT_F128>;
-def ceilf128 : RuntimeLibcallImpl<CEIL_F128>;
-def floorf128 : RuntimeLibcallImpl<FLOOR_F128>;
-def truncf128 : RuntimeLibcallImpl<TRUNC_F128>;
-def roundf128 : RuntimeLibcallImpl<ROUND_F128>;
-def lroundf128 : RuntimeLibcallImpl<LROUND_F128>;
-def llroundf128 : RuntimeLibcallImpl<LLROUND_F128>;
-def rintf128 : RuntimeLibcallImpl<RINT_F128>;
-def lrintf128 : RuntimeLibcallImpl<LRINT_F128>;
-def llrintf128 : RuntimeLibcallImpl<LLRINT_F128>;
-def nearbyintf128 : RuntimeLibcallImpl<NEARBYINT_F128>;
-def fmaf128 : RuntimeLibcallImpl<FMA_F128>;
-def frexpf128 : RuntimeLibcallImpl<FREXP_F128>;
-
-def cbrtf128 : RuntimeLibcallImpl<CBRT_F128>;
-def fminimumf128 : RuntimeLibcallImpl<FMINIMUM_F128>;
-def fmaximumf128 : RuntimeLibcallImpl<FMAXIMUM_F128>;
-def fminimum_numf128 : RuntimeLibcallImpl<FMINIMUM_NUM_F128>;
-def fmaximum_numf128 : RuntimeLibcallImpl<FMAXIMUM_NUM_F128>;
-def asinf128 : RuntimeLibcallImpl<ASIN_F128>;
-def acosf128 : RuntimeLibcallImpl<ACOS_F128>;
-def atanf128 : RuntimeLibcallImpl<ATAN_F128>;
-def atan2f128 : RuntimeLibcallImpl<ATAN2_F128>;
-def ldexpf128 : RuntimeLibcallImpl<LDEXP_F128>;
-def roundevenf128 : RuntimeLibcallImpl<ROUNDEVEN_F128>;
-def modff128 : RuntimeLibcallImpl<MODF_F128>;
-def sinhf128 : RuntimeLibcallImpl<SINH_F128>;
-def coshf128 : RuntimeLibcallImpl<COSH_F128>;
-def copysignf128 : RuntimeLibcallImpl<COPYSIGN_F128>;
-
-def __logf128_finite : RuntimeLibcallImpl<LOG_FINITE_F128>;
-def __log2f128_finite : RuntimeLibcallImpl<LOG2_FINITE_F128>;
-def __log10f128_finite : RuntimeLibcallImpl<LOG10_FINITE_F128>;
-def __expf128_finite : RuntimeLibcallImpl<EXP_FINITE_F128>;
-def __exp2f128_finite : RuntimeLibcallImpl<EXP2_FINITE_F128>;
-def __exp10f128_finite : RuntimeLibcallImpl<EXP10_FINITE_F128>;
-def __powf128_finite : RuntimeLibcallImpl<POW_FINITE_F128>;
+defset list<RuntimeLibcallImpl> LibmF128Libcalls = {
+ def logf128 : RuntimeLibcallImpl<LOG_F128>;
+ def log2f128 : RuntimeLibcallImpl<LOG2_F128>;
+ def log10f128 : RuntimeLibcallImpl<LOG10_F128>;
+ def expf128 : RuntimeLibcallImpl<EXP_F128>;
+ def exp2f128 : RuntimeLibcallImpl<EXP2_F128>;
+ def exp10f128 : RuntimeLibcallImpl<EXP10_F128>;
+ def sinf128 : RuntimeLibcallImpl<SIN_F128>;
+ def cosf128 : RuntimeLibcallImpl<COS_F128>;
+ def tanf128 : RuntimeLibcallImpl<TAN_F128>;
+ def tanhf128 : RuntimeLibcallImpl<TANH_F128>;
+ def sincosf128 : RuntimeLibcallImpl<SINCOS_F128>;
+ def powf128 : RuntimeLibcallImpl<POW_F128>;
+ def fminf128 : RuntimeLibcallImpl<FMIN_F128>;
+ def fmaxf128 : RuntimeLibcallImpl<FMAX_F128>;
+ def fmodf128 : RuntimeLibcallImpl<REM_F128>;
+ def sqrtf128 : RuntimeLibcallImpl<SQRT_F128>;
+ def ceilf128 : RuntimeLibcallImpl<CEIL_F128>;
+ def floorf128 : RuntimeLibcallImpl<FLOOR_F128>;
+ def truncf128 : RuntimeLibcallImpl<TRUNC_F128>;
+ def roundf128 : RuntimeLibcallImpl<ROUND_F128>;
+ def lroundf128 : RuntimeLibcallImpl<LROUND_F128>;
+ def llroundf128 : RuntimeLibcallImpl<LLROUND_F128>;
+ def rintf128 : RuntimeLibcallImpl<RINT_F128>;
+ def lrintf128 : RuntimeLibcallImpl<LRINT_F128>;
+ def llrintf128 : RuntimeLibcallImpl<LLRINT_F128>;
+ def nearbyintf128 : RuntimeLibcallImpl<NEARBYINT_F128>;
+ def fmaf128 : RuntimeLibcallImpl<FMA_F128>;
+ def frexpf128 : RuntimeLibcallImpl<FREXP_F128>;
+ def cbrtf128 : RuntimeLibcallImpl<CBRT_F128>;
+ def fminimumf128 : RuntimeLibcallImpl<FMINIMUM_F128>;
+ def fmaximumf128 : RuntimeLibcallImpl<FMAXIMUM_F128>;
+ def fminimum_numf128 : RuntimeLibcallImpl<FMINIMUM_NUM_F128>;
+ def fmaximum_numf128 : RuntimeLibcallImpl<FMAXIMUM_NUM_F128>;
+ def asinf128 : RuntimeLibcallImpl<ASIN_F128>;
+ def acosf128 : RuntimeLibcallImpl<ACOS_F128>;
+ def atanf128 : RuntimeLibcallImpl<ATAN_F128>;
+ def atan2f128 : RuntimeLibcallImpl<ATAN2_F128>;
+ def ldexpf128 : RuntimeLibcallImpl<LDEXP_F128>;
+ def roundevenf128 : RuntimeLibcallImpl<ROUNDEVEN_F128>;
+ def modff128 : RuntimeLibcallImpl<MODF_F128>;
+ def sinhf128 : RuntimeLibcallImpl<SINH_F128>;
+ def coshf128 : RuntimeLibcallImpl<COSH_F128>;
+ def copysignf128 : RuntimeLibcallImpl<COPYSIGN_F128>;
+}
+
+defset list<RuntimeLibcallImpl> LibmF128FiniteLibcalls = {
+ def __logf128_finite : RuntimeLibcallImpl<LOG_FINITE_F128>;
+ def __log2f128_finite : RuntimeLibcallImpl<LOG2_FINITE_F128>;
+ def __log10f128_finite : RuntimeLibcallImpl<LOG10_FINITE_F128>;
+ def __expf128_finite : RuntimeLibcallImpl<EXP_FINITE_F128>;
+ def __exp2f128_finite : RuntimeLibcallImpl<EXP2_FINITE_F128>;
+ def __exp10f128_finite : RuntimeLibcallImpl<EXP10_FINITE_F128>;
+ def __powf128_finite : RuntimeLibcallImpl<POW_FINITE_F128>;
+}
+
+//===----------------------------------------------------------------------===//
+// Common Libcall Sets
+//===----------------------------------------------------------------------===//
+
+// FIXME: Should move to explicit opt-in to different sets of libcalls
+// instead of trying to remove from a default set. We have
+// unreasonable defaults like reporting f80 calls on most targets when
+// they are relevant to only one.
+
+defvar AllDefaultLibCalls =
+ !foreach(entry, AllDefaultRuntimeLibcallImpls, entry.Provides);
+
+// These libcalls are only available in compiler-rt, not libgcc for
+// 32-bit arch. They are available on both for 64-bit.
+defvar LibCallsCompilerRT64OrLibGCC = [
----------------
nikic wrote:
Okay, here is how it actually works:
* `__mulodi4` is a compiler-rt only libcall. It does not exist in libgcc at all, even on 64-bit. This should not be handled the same as the others.
* The other four libcalls exist in libgcc for 64-bit targets and compiler-rt for 64-bit targets, wasm, or if COMPILER_RT_ENABLE_SOFTWARE_INT128 is enabled.
So I think it would be most accurate to say that these four are just generally 64-bit only libcalls, without talking about libgcc vs compiler-rt, with wasm being a special case.
It looks like you didn't delete the corresponding code in RuntimeLibcalls.cpp yet, which is why you're probably getting away with the incorrect __mulodi4 classification?
https://github.com/llvm/llvm-project/pull/144978
More information about the llvm-commits
mailing list