[llvm-branch-commits] [llvm] RuntimeLibcalls: Migrate to dag libcall predicates (PR #210674)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jul 20 03:14:30 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tablegen

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

Switch to using dag predicates instead of free-form code predicates.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply@<!-- -->anthropic.com>

---

Patch is 43.54 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/210674.diff


13 Files Affected:

- (modified) llvm/include/llvm/IR/RuntimeLibcalls.h (-26) 
- (modified) llvm/include/llvm/IR/RuntimeLibcalls.td (+237-112) 
- (modified) llvm/include/llvm/IR/RuntimeLibcallsImpl.td (+8-20) 
- (modified) llvm/lib/IR/RuntimeLibcalls.cpp (-17) 
- (modified) llvm/test/TableGen/RuntimeLibcallEmitter-bad-system-library-entry-error.td (+2-1) 
- (modified) llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td (+11-6) 
- (modified) llvm/test/TableGen/RuntimeLibcallEmitter-conflict-warning.td (+7-3) 
- (modified) llvm/test/TableGen/RuntimeLibcallEmitter-nested-predicates-error.td (+7-3) 
- (modified) llvm/test/TableGen/RuntimeLibcallEmitter-predicate-cc-sort.td (+2-1) 
- (modified) llvm/test/TableGen/RuntimeLibcallEmitter-predicate-dag-errors.td (+6-5) 
- (modified) llvm/test/TableGen/RuntimeLibcallEmitter-predicate-dag.td (+8-7) 
- (modified) llvm/test/TableGen/RuntimeLibcallEmitter.td (+21-10) 
- (modified) llvm/utils/TableGen/Basic/RuntimeLibcalls.h (+5-4) 


``````````diff
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index f43e09ada394e..78b75f3e81c3b 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -210,35 +210,9 @@ struct RuntimeLibcallsInfo {
     return true;
   }
 
-  static bool darwinHasMemsetPattern(const Triple &TT) {
-    // memset_pattern{4,8,16} is only available on iOS 3.0 and Mac OS X 10.5 and
-    // later. All versions of watchOS support it.
-    if (TT.isMacOSX())
-      return !TT.isMacOSXVersionLT(10, 5);
-    if (TT.isiOS())
-      return !TT.isOSVersionLT(3, 0);
-    return TT.isWatchOS();
-  }
-
-  static bool hasAEABILibcalls(const Triple &TT) {
-    return TT.isTargetAEABI() || TT.isTargetGNUAEABI() ||
-           TT.isTargetMuslAEABI() || TT.isOSFuchsia() || TT.isAndroid();
-  }
-
   LLVM_READONLY
   static bool isAAPCS_ABI(const Triple &TT, StringRef ABIName);
 
-  static bool darwinHasExp10(const Triple &TT);
-
-  /// Return true if the target has sincosf/sincos/sincosl functions
-  static bool hasSinCos(const Triple &TT) {
-    return TT.isGNUEnvironment() || TT.isOSFuchsia() || TT.isAndroid();
-  }
-
-  static bool hasSinCos_f32_f64(const Triple &TT) {
-    return hasSinCos(TT) || TT.isPS();
-  }
-
   /// Generated by tablegen.
   void setTargetRuntimeLibcallSets(const Triple &TT,
                                    ExceptionHandling ExceptionModel,
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 802188be31d09..9d07a15fd9e4e 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -15,66 +15,168 @@ include "llvm/IR/RuntimeLibcallsImpl.td"
 class DuplicateLibcallImplWithPrefix<RuntimeLibcallImpl Impl, string prefix>
     : RuntimeLibcallImpl<Impl.Provides, prefix#Impl.LibCallFuncName>;
 
+def IsOSDarwin : LibcallPredicate<[{TT.isOSDarwin()}]>;
+def IsOSOpenBSD : LibcallPredicate<[{TT.isOSOpenBSD()}]>;
+def IsOSWindows : LibcallPredicate<[{TT.isOSWindows()}]>;
+def IsOSLinux : LibcallPredicate<[{TT.isOSLinux()}]>;
+def IsOSMSVCRT : LibcallPredicate<[{TT.isOSMSVCRT()}]>;
+def IsPS : LibcallPredicate<[{TT.isPS()}]>;
+def IsMacOSX : LibcallPredicate<[{TT.isMacOSX()}]>;
+
+def IsWindowsMSVCEnv : LibcallPredicate<[{TT.isWindowsMSVCEnvironment()}]>;
+def IsWindowsItaniumEnv
+  : LibcallPredicate<[{TT.isWindowsItaniumEnvironment()}]>;
+def IsWindowsArm64EC : LibcallPredicate<[{TT.isWindowsArm64EC()}]>;
+
+def IsAndroid : LibcallPredicate<[{TT.isAndroid()}]>;
+def IsGNUEnv : LibcallPredicate<[{TT.isGNUEnvironment()}]>;
+def IsOSFuchsia : LibcallPredicate<[{TT.isOSFuchsia()}]>;
+
+def IsTargetAEABI : LibcallPredicate<[{TT.isTargetAEABI()}]>;
+def IsTargetGNUAEABI : LibcallPredicate<[{TT.isTargetGNUAEABI()}]>;
+def IsTargetMuslAEABI : LibcallPredicate<[{TT.isTargetMuslAEABI()}]>;
+
+def IsOSBinFormatMachO : LibcallPredicate<[{TT.isOSBinFormatMachO()}]>;
+
+def IsAArch64 : LibcallPredicate<[{TT.isAArch64()}]>;
+def IsAArch64_ILP64 : LibcallPredicate<[{TT.isAArch64(64)}]>;
+def IsIsiOS : LibcallPredicate<[{TT.isiOS()}]>;
+def IsIOS : LibcallPredicate<[{TT.getOS() == Triple::IOS}]>;
+def IsTvOS : LibcallPredicate<[{TT.isTvOS()}]>;
+def IsWatchOS : LibcallPredicate<[{TT.isWatchOS()}]>;
+def IsDriverKit : LibcallPredicate<[{TT.isDriverKit()}]>;
+def IsXROS : LibcallPredicate<[{TT.isXROS()}]>;
+def IsBridgeOS : LibcallPredicate<[{TT.getOS() == Triple::BridgeOS}]>;
+
+class MacOSXVersionAtLeast<int major, int minor>
+  : LibcallPredicate<[{!TT.isMacOSXVersionLT(}] # !cast<string>(major)
+                     # [{, }] # !cast<string>(minor) # [{)}]>;
+class OSVersionAtLeast<int major, int minor>
+  : LibcallPredicate<[{!TT.isOSVersionLT(}] # !cast<string>(major)
+                     # [{, }] # !cast<string>(minor) # [{)}]>;
+
+def IsAAPCS_ABI : LibcallPredicate<[{isAAPCS_ABI(TT, ABIName)}]>;
+def IsEABI4 : LibcallPredicate<[{EABIVersion == EABI::EABI4}]>;
+def IsEABI5 : LibcallPredicate<[{EABIVersion == EABI::EABI5}]>;
+
+def IsAMDGPU : LibcallPredicate<[{TT.isAMDGPU()}]>;
+def IsARM : LibcallPredicate<[{TT.isARM()}]>;
+def IsThumb : LibcallPredicate<[{TT.isThumb()}]>;
+def IsAVR : LibcallPredicate<[{TT.getArch() == Triple::avr}]>;
+def IsDXIL : LibcallPredicate<[{TT.isDXIL()}]>;
+def IsHexagon : LibcallPredicate<[{TT.getArch() == Triple::hexagon}]>;
+def IsLanai : LibcallPredicate<[{TT.getArch() == Triple::lanai}]>;
+def IsMSP430 : LibcallPredicate<[{TT.getArch() == Triple::msp430}]>;
+def IsNVPTX : LibcallPredicate<[{TT.isNVPTX()}]>;
+
+def IsPPC : LibcallPredicate<[{TT.isPPC()}]>;
+def IsPPC32 : LibcallPredicate<[{TT.isPPC32()}]>;
+def IsPPC64 : LibcallPredicate<[{TT.isPPC64()}]>;
+def IsOSAIX : LibcallPredicate<[{TT.isOSAIX()}]>;
+
+def IsRISCV : LibcallPredicate<[{TT.isRISCV()}]>;
+def IsRISCV64 : LibcallPredicate<[{TT.isRISCV64()}]>;
+def IsSPARC : LibcallPredicate<[{TT.isSPARC()}]>;
+def IsSPARC32 : LibcallPredicate<[{TT.isSPARC32()}]>;
+def IsSPARC64 : LibcallPredicate<[{TT.isSPARC64()}]>;
+def IsSPIRV : LibcallPredicate<[{TT.isSPIRV()}]>;
+
+def IsX86_32 : LibcallPredicate<[{TT.getArch() == Triple::x86}]>;
+def IsX86_64 : LibcallPredicate<[{TT.getArch() == Triple::x86_64}]>;
+def IsX86 : LibcallPredicate<[{TT.isX86()}]>;
+def IsXCore : LibcallPredicate<[{TT.getArch() == Triple::xcore}]>;
+
+def IsOSzOS : LibcallPredicate<[{TT.isOSzOS()}]>;
+def IsSystemZ : LibcallPredicate<[{TT.isSystemZ()}]>;
+def IsWasm : LibcallPredicate<[{TT.isWasm()}]>;
+def IsOSEmscripten : LibcallPredicate<[{TT.isOSEmscripten()}]>;
+def IsArch64Bit : LibcallPredicate<[{TT.isArch64Bit()}]>;
+
+def IsOSCygMing : LibcallPredicate<[{TT.isOSCygMing()}]>;
+def IsOSWindowsOrUEFI : LibcallPredicate<[{TT.isOSWindowsOrUEFI()}]>;
+
+def IsMIPS : LibcallPredicate<[{TT.isMIPS()}]>;
+def IsLoongArch : LibcallPredicate<[{TT.isLoongArch()}]>;
+def IsVE : LibcallPredicate<[{TT.isVE()}]>;
+def IsBPF : LibcallPredicate<[{TT.isBPF()}]>;
+def IsArchCSKY : LibcallPredicate<[{TT.getArch() == Triple::csky}]>;
+def IsArchArc : LibcallPredicate<[{TT.getArch() == Triple::arc}]>;
+def IsArchM68k : LibcallPredicate<[{TT.getArch() == Triple::m68k}]>;
+def IsArchXtensa : LibcallPredicate<[{TT.getArch() == Triple::xtensa}]>;
+
 /// Libcall Predicates
-def isOSDarwin : RuntimeLibcallAvailability<"TT.isOSDarwin()">;
-def isOSOpenBSD : RuntimeLibcallAvailability<"TT.isOSOpenBSD()">;
-def isNotOSOpenBSD : RuntimeLibcallAvailability<"!TT.isOSOpenBSD()">;
-def isOSWindows : RuntimeLibcallAvailability<"TT.isOSWindows()">;
-def isNotOSWindows : RuntimeLibcallAvailability<"!TT.isOSWindows()">;
-def isNotOSLinux : RuntimeLibcallAvailability<[{!TT.isOSLinux()}]>;
-def isNotOSMSVCRT : RuntimeLibcallAvailability<"!TT.isOSMSVCRT()">;
-def isPS : RuntimeLibcallAvailability<"TT.isPS()">;
-def isMacOSX : RuntimeLibcallAvailability<[{TT.isMacOSX()}]>;
+def isOSDarwin : RuntimeLibcallAvailability<(all_of IsOSDarwin)>;
+def isOSOpenBSD : RuntimeLibcallAvailability<(all_of IsOSOpenBSD)>;
+def isNotOSOpenBSD : RuntimeLibcallAvailability<(not IsOSOpenBSD)>;
+def isOSWindows : RuntimeLibcallAvailability<(all_of IsOSWindows)>;
+def isNotOSWindows : RuntimeLibcallAvailability<(not IsOSWindows)>;
+def isNotOSLinux : RuntimeLibcallAvailability<(not IsOSLinux)>;
+def isNotOSMSVCRT : RuntimeLibcallAvailability<(not IsOSMSVCRT)>;
+def isPS : RuntimeLibcallAvailability<(all_of IsPS)>;
+def isMacOSX : RuntimeLibcallAvailability<(all_of IsMacOSX)>;
 def isNotOSWindowsOrIsCygwinMinGW
-  : RuntimeLibcallAvailability<"!TT.isOSWindows() || TT.isOSCygMing()">;
+  : RuntimeLibcallAvailability<(any_of (not IsOSWindows), IsOSCygMing)>;
 
-def isWindowsMSVCEnvironment : RuntimeLibcallAvailability<
-  [{TT.isWindowsMSVCEnvironment()}]>;
+def isWindowsMSVCEnvironment
+  : RuntimeLibcallAvailability<(all_of IsWindowsMSVCEnv)>;
 
-def isNotOSLinuxAndNotOSOpenBSD : RuntimeLibcallAvailability<
-  [{!TT.isOSLinux() && !TT.isOSOpenBSD()}]>;
+def isNotOSLinuxAndNotOSOpenBSD
+  : RuntimeLibcallAvailability<(all_of (not IsOSLinux), (not IsOSOpenBSD))>;
 
-def isNotOSAIXAndNotOSOpenBSD : RuntimeLibcallAvailability<
-  [{!TT.isOSAIX() && !TT.isOSOpenBSD()}]>;
+def isNotOSAIXAndNotOSOpenBSD
+  : RuntimeLibcallAvailability<(all_of (not IsOSAIX), (not IsOSOpenBSD))>;
 
-def isNotPS : RuntimeLibcallAvailability<
-  [{!TT.isPS()}]>;
+def isNotPS : RuntimeLibcallAvailability<(not IsPS)>;
 
 // OpenBSD uses __guard_local. AIX uses __ssp_canary_word, MSVC/Windows
 // Itanium uses __security_cookie
 def hasStackChkFail : RuntimeLibcallAvailability<
-  [{ !TT.isOSOpenBSD() && !TT.isWindowsMSVCEnvironment() &&
-     !TT.isWindowsItaniumEnvironment()}]>;
+  (all_of (not IsOSOpenBSD), (not IsWindowsMSVCEnv),
+          (not IsWindowsItaniumEnv))>;
 
-def isWindowsMSVCOrItaniumEnvironment : RuntimeLibcallAvailability<
-  [{TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()}]>;
+def isWindowsMSVCOrItaniumEnvironment
+  : RuntimeLibcallAvailability<(any_of IsWindowsMSVCEnv, IsWindowsItaniumEnv)>;
 
-def isAndroid : RuntimeLibcallAvailability<"TT.isAndroid()">;
+def isAndroid : RuntimeLibcallAvailability<(all_of IsAndroid)>;
 
-def isGNUEnvironment : RuntimeLibcallAvailability<"TT.isGNUEnvironment()">;
-def darwinHasSinCosStret : RuntimeLibcallAvailability<"darwinHasSinCosStret(TT)">;
-def darwinHasExp10 : RuntimeLibcallAvailability<"darwinHasExp10(TT)">;
-def darwinHasMemsetPattern : RuntimeLibcallAvailability<[{darwinHasMemsetPattern(TT)}]>;
+def isGNUEnvironment : RuntimeLibcallAvailability<(all_of IsGNUEnv)>;
+def darwinHasSinCosStret : RuntimeLibcallAvailability<
+  (all_of IsOSDarwin, (not IsX86_32),
+          (any_of (all_of IsMacOSX, MacOSXVersionAtLeast<10, 9>, IsArch64Bit),
+                  (all_of IsIsiOS, OSVersionAtLeast<7, 0>),
+                  (all_of (not IsMacOSX), (not IsIsiOS))))>;
 
-def hasExp10 : RuntimeLibcallAvailability<[{!TT.isOSDarwin()}]>;
+def darwinHasExp10 : RuntimeLibcallAvailability<
+  (any_of (all_of IsMacOSX, MacOSXVersionAtLeast<10, 9>),
+          (all_of IsIOS, OSVersionAtLeast<7, 0>),
+          IsDriverKit, IsTvOS, IsWatchOS, IsXROS, IsBridgeOS)>;
 
-def hasSinCos : RuntimeLibcallAvailability<"hasSinCos(TT)">;
+def darwinHasMemsetPattern : RuntimeLibcallAvailability<
+  (any_of (all_of IsMacOSX, MacOSXVersionAtLeast<10, 5>),
+          (all_of IsIsiOS, OSVersionAtLeast<3, 0>),
+          IsWatchOS)>;
 
-// FIXME: Way to combine predicates
-def hasSinCos_f32_f64 : RuntimeLibcallAvailability<"hasSinCos_f32_f64(TT)">;
+def hasExp10 : RuntimeLibcallAvailability<(not IsOSDarwin)>;
 
-def ExceptionModelIsNotNone : RuntimeLibcallAvailability<
-  [{ExceptionModel != ExceptionHandling::None}]
->;
+def hasSinCos
+  : RuntimeLibcallAvailability<(any_of IsGNUEnv, IsOSFuchsia, IsAndroid)>;
+
+def hasSinCos_f32_f64
+  : RuntimeLibcallAvailability<(any_of IsGNUEnv, IsOSFuchsia, IsAndroid, IsPS)>;
+
+def IsExceptionModelNone
+  : LibcallPredicate<[{ExceptionModel == ExceptionHandling::None}]>;
+def IsExceptionModelSjLj
+  : LibcallPredicate<[{ExceptionModel == ExceptionHandling::SjLj}]>;
+
+def ExceptionModelIsNotNone
+  : RuntimeLibcallAvailability<(not IsExceptionModelNone)>;
 
 def ExceptionModelHasUnwindResume : RuntimeLibcallAvailability<
-  [{ExceptionModel != ExceptionHandling::None &&
-    ExceptionModel != ExceptionHandling::SjLj}]
->;
+  (all_of (not IsExceptionModelNone), (not IsExceptionModelSjLj))>;
 
-def ExceptionModelIsSjLj : RuntimeLibcallAvailability<
-  [{ExceptionModel == ExceptionHandling::SjLj}]
->;
+def ExceptionModelIsSjLj
+  : RuntimeLibcallAvailability<(all_of IsExceptionModelSjLj)>;
 
 //--------------------------------------------------------------------
 // Declare all kinds of used libcalls
@@ -1998,9 +2100,10 @@ def SMEABI_LibCalls_PreserveMost_From_X2 : LibcallsWithCC<(add
   SMEABI_PreserveMost_From_X2>;
 
 def isAArch64_ExceptArm64EC
-    : RuntimeLibcallAvailability<"(TT.isAArch64() && !TT.isWindowsArm64EC())">;
-def isWindowsArm64EC : RuntimeLibcallAvailability<"TT.isWindowsArm64EC()">;
-def isAArch64_ILP64  : RuntimeLibcallAvailability<"TT.isAArch64(64)">;
+    : RuntimeLibcallAvailability<(all_of IsAArch64, (not IsWindowsArm64EC))>;
+def isWindowsArm64EC : RuntimeLibcallAvailability<(all_of IsWindowsArm64EC)>;
+def isAArch64_ILP64
+    : RuntimeLibcallAvailability<(all_of IsAArch64_ILP64)>;
 
 
 def AArch64SystemLibrary : SystemRuntimeLibrary<
@@ -2075,7 +2178,7 @@ def WindowsARM64ECSystemLibrary
 // AMDGPU Runtime Libcalls
 //===----------------------------------------------------------------------===//
 
-def isAMDGPU : RuntimeLibcallAvailability<"TT.isAMDGPU()">;
+def isAMDGPU : RuntimeLibcallAvailability<(all_of IsAMDGPU)>;
 
 def __llvm_profile_instrument_gpu : RuntimeLibcallImpl<PROFILE_INSTRUMENT_GPU>;
 def __llvm_profile_sampling_gpu : RuntimeLibcallImpl<PROFILE_SAMPLING_GPU>;
@@ -2088,8 +2191,19 @@ def AMDGPUSystemLibrary
 // ARM Runtime Libcalls
 //===----------------------------------------------------------------------===//
 
-def isTargetAEABIAndAAPCS_ABI : RuntimeLibcallAvailability<
-  [{TT.isTargetAEABI() && isAAPCS_ABI(TT, ABIName)}]>;
+def isTargetAEABIAndAAPCS_ABI
+    : RuntimeLibcallAvailability<(all_of IsTargetAEABI, IsAAPCS_ABI)>;
+
+defvar HasAEABILibcallsDag =
+  (any_of IsTargetAEABI, IsTargetGNUAEABI, IsTargetMuslAEABI,
+          IsOSFuchsia, IsAndroid);
+
+def hasAEABILibcalls : RuntimeLibcallAvailability<HasAEABILibcallsDag>;
+
+def hasAEABILibcallsAndAAPCS_ABI : RuntimeLibcallAvailability<
+  (all_of (any_of IsTargetAEABI, IsTargetGNUAEABI, IsTargetMuslAEABI,
+                  IsOSFuchsia, IsAndroid),
+          IsAAPCS_ABI)>;
 
 // if (isTargetMachO()) {
 // if (Subtarget->isThumb() && Subtarget->hasVFP2Base() &&
@@ -2340,17 +2454,20 @@ def ARMHalfConvertLibcallCallingConv : LibcallCallingConv<
     static_cast<CallingConv::ID>(isAAPCS_ABI(TT, ABIName) ? CallingConv::ARM_AAPCS : CallingConv::ARM_APCS)}]
 >;
 
+def isNotTargetAEABIAndMachO
+    : RuntimeLibcallAvailability<(all_of (not IsTargetAEABI),
+                                            IsOSBinFormatMachO)>;
+def isNotTargetAEABI : RuntimeLibcallAvailability<(not IsTargetAEABI)>;
+
 def ARMLibgccHalfConvertCalls :
-  LibcallImpls<(add __truncsfhf2, __extendhfsf2),
-    RuntimeLibcallAvailability<[{!TT.isTargetAEABI() && TT.isOSBinFormatMachO()}]>> {
+  LibcallImpls<(add __truncsfhf2, __extendhfsf2), isNotTargetAEABIAndMachO> {
   let CallingConv = ARMHalfConvertLibcallCallingConv;
 }
 
 // FIXME: These conditions are probably bugged. We're using the
 // default libgcc call when the other cases are replaced.
 def ARMDoubleToHalfCalls :
-  LibcallImpls<(add __truncdfhf2),
-    RuntimeLibcallAvailability<[{!TT.isTargetAEABI()}]>> {
+  LibcallImpls<(add __truncdfhf2), isNotTargetAEABI> {
   let CallingConv = ARMHalfConvertLibcallCallingConv;
 }
 
@@ -2361,10 +2478,13 @@ def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
   let CallingConv = ARM_AAPCS;
 }
 
+def isNotMachOAndNotTargetAEABI
+    : RuntimeLibcallAvailability<(all_of (not IsOSBinFormatMachO),
+                                            (not IsTargetAEABI))>;
+
 def GNUEABIHalfConvertCalls :
   LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee),
-    RuntimeLibcallAvailability<[{!TT.isOSBinFormatMachO() &&
-                              !TT.isTargetAEABI()}]>> {
+    isNotMachOAndNotTargetAEABI> {
   let CallingConv = ARMHalfConvertLibcallCallingConv;
 }
 
@@ -2385,7 +2505,7 @@ def WindowARMFPIntCasts : LibcallImpls<
 def AEABIDivRemCalls : LibcallImpls<
   (add __aeabi_idivmod, __aeabi_ldivmod,
        __aeabi_uidivmod, __aeabi_uldivmod),
-  RuntimeLibcallAvailability<[{hasAEABILibcalls(TT)}]>> {
+  hasAEABILibcalls> {
   let CallingConv = ARM_AAPCS;
 }
 
@@ -2466,7 +2586,7 @@ def AEABICalls : LibcallImpls<
       // RTABI chapter 4.3.1
       __aeabi_idiv,
       __aeabi_uidiv),
-  RuntimeLibcallAvailability<[{hasAEABILibcalls(TT) && isAAPCS_ABI(TT, ABIName)}]>> {
+  hasAEABILibcallsAndAAPCS_ABI> {
   let CallingConv = ARM_AAPCS;
 }
 
@@ -2477,9 +2597,11 @@ def AEABI45MemCalls : LibcallImpls<
        __aeabi_memmove, __aeabi_memmove4, __aeabi_memmove8,
        __aeabi_memset, __aeabi_memset4, __aeabi_memset8,
        __aeabi_memclr, __aeabi_memclr4, __aeabi_memclr8),
-  RuntimeLibcallAvailability<[{(EABIVersion == EABI::EABI4 ||
-                             EABIVersion == EABI::EABI5) &&
-                             hasAEABILibcalls(TT) && isAAPCS_ABI(TT, ABIName)}]>> {
+  RuntimeLibcallAvailability<
+    (all_of (any_of IsEABI4, IsEABI5),
+            (any_of IsTargetAEABI, IsTargetGNUAEABI, IsTargetMuslAEABI,
+                    IsOSFuchsia, IsAndroid),
+            IsAAPCS_ABI)>> {
   let CallingConv = ARM_AAPCS;
 }
 
@@ -2488,11 +2610,11 @@ def AEABI45MemCalls : LibcallImpls<
 def AEABIUnalignedMemCalls : LibcallImpls<
   (add __aeabi_uread4,  __aeabi_uread8,
        __aeabi_uwrite4, __aeabi_uwrite8),
-  RuntimeLibcallAvailability<[{hasAEABILibcalls(TT) && isAAPCS_ABI(TT, ABIName)}]>> {
+  hasAEABILibcallsAndAAPCS_ABI> {
   let CallingConv = ARM_AAPCS;
 }
 
-def isARMOrThumb : RuntimeLibcallAvailability<"TT.isARM() || TT.isThumb()">;
+def isARMOrThumb : RuntimeLibcallAvailability<(any_of IsARM, IsThumb)>;
 
 def ARMSystemLibrary
     : SystemRuntimeLibrary<isARMOrThumb,
@@ -2522,14 +2644,17 @@ def ARMSystemLibrary
            ARMDoubleToHalfCalls,
 
            LibcallImpls<(add AEABIOverrides),
-             RuntimeLibcallAvailability<[{
-               (!hasAEABILibcalls(TT) || !isAAPCS_ABI(TT, ABIName)) &&
-               !TT.isOSWindows()
-            }]>>,
+             RuntimeLibcallAvailability<
+               (all_of (any_of (not (any_of IsTargetAEABI, IsTargetGNUAEABI,
+                                            IsTargetMuslAEABI, IsOSFuchsia, IsAndroid)),
+                               (not IsAAPCS_ABI)),
+                       (not IsOSWindows))>>,
            // Use divmod compiler-rt calls for iOS 5.0 and later.
            LibcallImpls<(add __divmodsi4, __udivmodsi4),
-                        RuntimeLibcallAvailability<[{TT.isOSBinFormatMachO() &&
-                                                  (!TT.isiOS() || !TT.isOSVersionLT(5, 0))}]>>,
+                        RuntimeLibcallAvailability<
+                          (all_of IsOSBinFormatMachO,
+                                  (any_of (not IsIsiOS),
+                                          OSVersionAtLeast<5, 0>))>>,
            DefaultStackProtector,
            DefaultSafeStackGlobals)> {
   let DefaultLibcallCallingConv = LibcallCallingConv<[{
@@ -2557,7 +2682,7 @@ def __udivmodhi4 : RuntimeLibcallImpl<UDIVREM_I16>;
 def avr_sin : RuntimeLibcallImpl<SIN_F32, "sin">;
 def avr_cos : RuntimeLibcallImpl<COS_F32, "cos">;
 
-def isAVR : RuntimeLibcallAvailability<"TT.getArch() == Triple::avr">;
+def isAVR : RuntimeLibcallAvailability<(all_of IsAVR)>;
 
 def AVRSystemLibrary
     : SystemRuntimeLibrary<
@@ -2588,7 +2713,7 @@ def AVRSystemLibrary
 // DXIL Runtime Libcalls
 //===----------------------------------------------------------------------===//
 
-def isDXIL : RuntimeLibcallAvailability<"TT.isDXIL()">;
+def isDXIL : RuntimeLibcallAvailability<(all_of IsDXIL)>;
 
 // No calls
 def DXILSystemLibrary : SystemRuntimeLibrary<isDXIL, (add)>;
@@ -2634,7 +2759,7 @@ def __hexagon_memcpy_likely_aligned_min32bytes_mult8bytes
 def hexagon_memcpy_forward_vp4cp4n2 : RuntimeLibcallImpl<HEXAGON_VOLATILE_MEMCPY>;
 }
 
-def isHexagon : RuntimeLibcallAvailability<"TT.getArch() == Triple::hexagon">;
+def isHexagon : RuntimeLibcallAvailability<(all_of IsHexagon)>;
 
 def HexagonSystemLibrary
     : SystemRuntimeLibrary<isHexagon,
@@ -2650,7 +2775,7 @@ def HexagonSystemLibrary
 // Lanai Runtime Libcalls
 //===----------------------------------------------------------------------===//
 
-def isLanai : RuntimeLibcallAvailability<"TT.getArch() == Triple::lanai">;
+def isLanai : RuntimeLibcallAvailability<(all_of IsLanai)>;
 
 // Use fast calling convention for library functions.
 def LanaiSystemLibrary
@@ -2840,7 +2965,7 @@ def __mspabi_mpyll : RuntimeLibcallImpl<MUL_I64>;
 
 // setLibcallCallingConv(MUL_I64, CallingConv::MSP430_BUILTIN);
 
-def isMSP430 : RuntimeLibcallAvailability<"TT.getArch() == Triple::msp430">;
+def isMSP430 : RuntimeLibcallAvailability<(all_of IsMSP430)>;
 
 defvar MSP430DefaultOptOut = [
   __addsf3, __divsf3, __extendsfdf2, __truncdfsf2, __fixsfsi,
@@ -2964,7 +3089,7 @@ def MSP430SystemLibrary
 // NVPTX Runtime Libcalls
 //===-----...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/210674


More information about the llvm-branch-commits mailing list