98 lines · plain
1// RUN: llvm-tblgen -gen-runtime-libcalls -I %p/../../include %s 2> %t.err | FileCheck %s2// RUN: FileCheck -check-prefix=ERR %s < %t.err3 4// Check behavior of libcall emission when multiple RuntimeLibcallImpl5// implementations provide the same RuntimeLibcall6 7include "llvm/IR/RuntimeLibcallsImpl.td"8 9def SOME_FUNC : RuntimeLibcall;10def OTHER_FUNC : RuntimeLibcall;11def ANOTHER_DUP : RuntimeLibcall;12 13def isTargetArchA : RuntimeLibcallPredicate<[{isTargetArchA()}]>;14def isTargetArchB : RuntimeLibcallPredicate<[{isTargetArchB()}]>;15def isTargetArchC : RuntimeLibcallPredicate<[{isTargetArchC()}]>;16 17def func_a : RuntimeLibcallImpl<SOME_FUNC>;18def func_b : RuntimeLibcallImpl<SOME_FUNC>;19def func_c : RuntimeLibcallImpl<SOME_FUNC>;20def other_func : RuntimeLibcallImpl<OTHER_FUNC>;21 22def dup0 : RuntimeLibcallImpl<ANOTHER_DUP>;23def dup1 : RuntimeLibcallImpl<ANOTHER_DUP>;24 25// func_a and func_b both provide SOME_FUNC.26 27// CHECK: if (isTargetArchA()) {28// CHECK-NEXT: static constexpr LibcallImplBitset SystemAvailableImpls({29// CHECK-NEXT: 0x0000000000001830// CHECK-NEXT: });31// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;32// CHECK-EMPTY:33 34// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {35// CHECK-NEXT: RTLIB::impl_func_b, // func_b36// CHECK-NEXT: };37// CHECK-EMPTY:38// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {39// CHECK-NEXT: setAvailable(Impl);40// CHECK-NEXT: }41// CHECK-EMPTY:42// CHECK-NEXT: return;43// CHECK-NEXT: }44 45// ERR: :[[@LINE+1]]:5: warning: conflicting implementations for libcall SOME_FUNC: func_b, func_a46def TheSystemLibraryA : SystemRuntimeLibrary<isTargetArchA,47 (add func_b, func_a)48>;49 50// CHECK: if (isTargetArchB()) {51// CHECK-NEXT: static constexpr LibcallImplBitset SystemAvailableImpls({52// CHECK-NEXT: 0x0000000000005853// CHECK-NEXT: });54// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;55// CHECK-EMPTY:56// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {57// CHECK-NEXT: RTLIB::impl_other_func, // other_func58// CHECK-NEXT: RTLIB::impl_func_a, // func_a59// CHECK-NEXT: };60// CHECK-EMPTY:61// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {62// CHECK-NEXT: setAvailable(Impl);63// CHECK-NEXT: }64// CHECK-EMPTY:65// CHECK-NEXT: return;66// CHECK-NEXT: }67 68// ERR: :[[@LINE+1]]:5: warning: conflicting implementations for libcall SOME_FUNC: func_a, func_b69def TheSystemLibraryB : SystemRuntimeLibrary<isTargetArchB,70 (add func_a, other_func, func_b)71>;72 73// CHECK: if (isTargetArchC()) {74// CHECK-NEXT: static constexpr LibcallImplBitset SystemAvailableImpls({75// CHECK-NEXT: 0x0000000000007e76// CHECK-NEXT: });77// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;78// CHECK-EMPTY:79// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {80// CHECK-NEXT: RTLIB::impl_dup1, // dup181// CHECK-NEXT: RTLIB::impl_other_func, // other_func82// CHECK-NEXT: RTLIB::impl_func_a, // func_a83// CHECK-NEXT: };84// CHECK-EMPTY:85// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {86// CHECK-NEXT: setAvailable(Impl);87// CHECK-NEXT: }88// CHECK-EMPTY:89// CHECK-NEXT: return;90// CHECK-NEXT: }91 92// ERR: :[[@LINE+3]]:5: warning: conflicting implementations for libcall ANOTHER_DUP: dup1, dup093// ERR: :[[@LINE+2]]:5: warning: conflicting implementations for libcall SOME_FUNC: func_a, func_b94// ERR: :[[@LINE+1]]:5: warning: conflicting implementations for libcall SOME_FUNC: func_a, func_c95def TheSystemLibraryC : SystemRuntimeLibrary<isTargetArchC,96 (add func_a, dup1, other_func, func_b, func_c, dup0)97>;98