@@ -39,6 +39,14 @@ def hasSinCos : RuntimeLibcallPredicate<"hasSinCos(TT)">;
3939// FIXME: Way to combine predicates
4040def hasSinCos_f32_f64 : RuntimeLibcallPredicate<"hasSinCos_f32_f64(TT)">;
4141
42+ def ExceptionModelIsNotNone : RuntimeLibcallPredicate<
43+ [{ExceptionModel != ExceptionHandling::None}]
44+ >;
45+
46+ def ExceptionModelIsSjLj : RuntimeLibcallPredicate<
47+ [{ExceptionModel == ExceptionHandling::SjLj}]
48+ >;
49+
4250//--------------------------------------------------------------------
4351// Declare all kinds of used libcalls
4452//--------------------------------------------------------------------
@@ -707,10 +715,6 @@ foreach MemSize = [ 1, 2, 4, 8, 16 ] in {
707715 !cast<RuntimeLibcall>("MEMSET_ELEMENT_UNORDERED_ATOMIC_"#MemSize)>;
708716}
709717
710- // Exception handling
711- def _Unwind_Resume : RuntimeLibcallImpl<UNWIND_RESUME>;
712- def __cxa_end_cleanup : RuntimeLibcallImpl<CXA_END_CLEANUP>;
713-
714718// Atomic '__sync_*' libcalls.
715719foreach lc = LibCalls__sync in {
716720 def __#!tolower(!cast<string>(lc)) : RuntimeLibcallImpl<lc>;
@@ -1014,9 +1018,20 @@ defm sincos : LibmLongDoubleLibCall;
10141018
10151019def bzero : RuntimeLibcallImpl<BZERO>;
10161020def __bzero : RuntimeLibcallImpl<BZERO>;
1017- def _Unwind_SjLj_Resume : RuntimeLibcallImpl<UNWIND_RESUME>;
1018- def _Unwind_SjLj_Register : RuntimeLibcallImpl<UNWIND_REGISTER>;
1019- def _Unwind_SjLj_Unregister : RuntimeLibcallImpl<UNWIND_UNREGISTER>;
1021+
1022+ // Exception handling
1023+ defset list<RuntimeLibcallImpl> DefaultExceptionHandlingLibcalls = {
1024+ def _Unwind_Resume : RuntimeLibcallImpl<UNWIND_RESUME>;
1025+ def __cxa_end_cleanup : RuntimeLibcallImpl<CXA_END_CLEANUP>;
1026+ }
1027+
1028+ defset list<RuntimeLibcallImpl> SjLjExceptionHandlingLibcalls = {
1029+ def _Unwind_SjLj_Resume : RuntimeLibcallImpl<UNWIND_RESUME>;
1030+ def _Unwind_SjLj_Register : RuntimeLibcallImpl<UNWIND_REGISTER>;
1031+ def _Unwind_SjLj_Unregister : RuntimeLibcallImpl<UNWIND_UNREGISTER>;
1032+ }
1033+
1034+ // Only used on wasm?
10201035def _Unwind_CallPersonality : RuntimeLibcallImpl<UNWIND_CALL_PERSONALITY>;
10211036
10221037// Used on OpenBSD
@@ -1092,6 +1107,13 @@ defset list<RuntimeLibcallImpl> LibmF128FiniteLibcalls = {
10921107// Common Libcall Sets
10931108//===----------------------------------------------------------------------===//
10941109
1110+ defvar ExceptionModelCalls = (add
1111+ LibcallImpls<(add DefaultExceptionHandlingLibcalls),
1112+ ExceptionModelIsNotNone>,
1113+ LibcallImpls<(add SjLjExceptionHandlingLibcalls),
1114+ ExceptionModelIsSjLj>
1115+ );
1116+
10951117// FIXME: Should move to explicit opt-in to different sets of libcalls
10961118// instead of trying to remove from a default set. We have
10971119// unreasonable defaults like reporting f80 calls on most targets when
@@ -1112,19 +1134,25 @@ defvar DefaultRuntimeLibcallImpls_f128 =
11121134 !filter(entry, AllDefaultRuntimeLibcallImpls,
11131135 !match(!cast<string>(entry.Provides), "_F128"));
11141136
1115- defvar DefaultRuntimeLibcallImpls =
1137+ // FIXME: Ideally we would just use dags everywhere, but for the
1138+ // arm64ec case we need iterable lists so we can add the # prefix
1139+ defvar DefaultRuntimeLibcallImplsBaseList =
11161140!listremove(
11171141 !listremove(
11181142 !listremove(AllDefaultRuntimeLibcallImpls, Int128RTLibcalls),
11191143 DefaultRuntimeLibcallImpls_f80),
11201144 DefaultRuntimeLibcallImpls_ppcf128);
11211145
1146+ defvar DefaultRuntimeLibcallImpls =
1147+ (add DefaultRuntimeLibcallImplsBaseList,
1148+ ExceptionModelCalls);
1149+
11221150/// Default set of libcall impls for 32-bit architectures.
1123- defvar DefaultLibcallImpls32 = DefaultRuntimeLibcallImpls;
1151+ defvar DefaultLibcallImpls32 = (add DefaultRuntimeLibcallImpls) ;
11241152
11251153/// Default set of libcall impls for 64-bit architectures.
1126- defvar DefaultLibcallImpls64 = !listconcat( DefaultRuntimeLibcallImpls,
1127- Int128RTLibcalls);
1154+ defvar DefaultLibcallImpls64 = (add DefaultRuntimeLibcallImpls,
1155+ Int128RTLibcalls);
11281156
11291157defvar DarwinSinCosStret = LibcallImpls<(add __sincosf_stret, __sincos_stret),
11301158 darwinHasSinCosStret>;
@@ -1160,7 +1188,12 @@ defvar WindowsExclusions = !listconcat(WindowsMathRemovals, MostPowI);
11601188
11611189// Targets which support windows should start with these as a base and
11621190// add in calls for other OSes
1163- defvar WinDefaultLibcallImpls = !listremove(DefaultRuntimeLibcallImpls, WindowsExclusions);
1191+ defvar WinDefaultLibcallImplsBaseList =
1192+ !listremove(DefaultRuntimeLibcallImplsBaseList,
1193+ WindowsExclusions);
1194+
1195+ defvar WinDefaultLibcallImpls = (add WinDefaultLibcallImplsBaseList,
1196+ ExceptionModelCalls);
11641197
11651198defvar LibmHasFrexpF32 = LibcallImpls<(add frexpf), isNotOSWindowsOrIsCygwinMinGW>;
11661199defvar LibmHasLdexpF32 = LibcallImpls<(add ldexpf), isNotOSWindowsOrIsCygwinMinGW>;
@@ -1290,7 +1323,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
12901323
12911324// Prepend a # to every name
12921325defset list<RuntimeLibcallImpl> WinArm64ECDefaultRuntimeLibcallImpls = {
1293- foreach libcall = WinDefaultLibcallImpls in {
1326+ foreach libcall = WinDefaultLibcallImplsBaseList in {
12941327 def arm64ec_#libcall : DuplicateLibcallImplWithPrefix<libcall, "#">;
12951328 }
12961329
@@ -1301,12 +1334,32 @@ defset list<RuntimeLibcallImpl> WinArm64ECDefaultRuntimeLibcallImpls = {
13011334
13021335def arm64ec___stack_chk_fail : DuplicateLibcallImplWithPrefix<__stack_chk_fail, "#">;
13031336
1337+ defset list<RuntimeLibcallImpl> WinArm64ECDefaultExceptionHandlingLibcalls = {
1338+ foreach libcall = DefaultExceptionHandlingLibcalls in {
1339+ def arm64ec_#libcall : DuplicateLibcallImplWithPrefix<libcall, "#">;
1340+ }
1341+ }
1342+
1343+ defset list<RuntimeLibcallImpl> WinArm64ECSjLjExceptionHandlingLibcalls = {
1344+ foreach libcall = SjLjExceptionHandlingLibcalls in {
1345+ def arm64ec_#libcall : DuplicateLibcallImplWithPrefix<libcall, "#">;
1346+ }
1347+ }
1348+
1349+ defvar ExceptionModelCallsArm64EC = (add
1350+ LibcallImpls<(add WinArm64ECDefaultExceptionHandlingLibcalls),
1351+ ExceptionModelIsNotNone>,
1352+ LibcallImpls<(add WinArm64ECSjLjExceptionHandlingLibcalls),
1353+ ExceptionModelIsSjLj>
1354+ );
1355+
13041356def WindowsARM64ECSystemLibrary
13051357 : SystemRuntimeLibrary<isWindowsArm64EC,
13061358 (add WinArm64ECDefaultRuntimeLibcallImpls,
13071359 arm64ec___stack_chk_fail,
13081360 LibcallImpls<(add __security_check_cookie_arm64ec),
1309- isWindowsMSVCEnvironment>)>;
1361+ isWindowsMSVCEnvironment>,
1362+ ExceptionModelCallsArm64EC)>;
13101363
13111364//===----------------------------------------------------------------------===//
13121365// AMDGPU Runtime Libcalls
@@ -2345,7 +2398,7 @@ defvar X86CommonLibcalls =
23452398 // hack for one test relying on it.
23462399 __powitf2_f128,
23472400 DefaultStackProtector
2348- );
2401+ );
23492402
23502403defvar Windows32DivRemMulCalls =
23512404 LibcallsWithCC<(add WindowsDivRemMulLibcalls), X86_STDCALL,
@@ -2489,6 +2542,7 @@ def WasmSystemLibrary
24892542 (add DefaultRuntimeLibcallImpls, Int128RTLibcalls,
24902543 CompilerRTOnlyInt64Libcalls, CompilerRTOnlyInt128Libcalls,
24912544 exp10f, exp10,
2545+ _Unwind_CallPersonality,
24922546 emscripten_return_address,
24932547 __stack_chk_fail)>;
24942548
0 commit comments