3434
3535namespace llvm {
3636
37+ class LibcallLoweringInfo ;
38+
3739template <> struct enum_iteration_traits <RTLIB::Libcall> {
3840 static constexpr bool is_iterable = true ;
3941};
@@ -70,6 +72,8 @@ struct RuntimeLibcallsInfo {
7072 LibcallImplBitset AvailableLibcallImpls;
7173
7274public:
75+ friend class llvm ::LibcallLoweringInfo;
76+
7377 explicit RuntimeLibcallsInfo (
7478 const Triple &TT,
7579 ExceptionHandling ExceptionModel = ExceptionHandling::None,
@@ -85,17 +89,6 @@ struct RuntimeLibcallsInfo {
8589 initLibcalls (TT, ExceptionModel, FloatABI, EABIVersion, ABIName);
8690 }
8791
88- // / Rename the default libcall routine name for the specified libcall.
89- void setLibcallImpl (RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
90- LibcallImpls[Call] = Impl;
91- }
92-
93- // / Get the libcall routine name for the specified libcall.
94- // FIXME: This should be removed. Only LibcallImpl should have a name.
95- StringRef getLibcallName (RTLIB::Libcall Call) const {
96- return getLibcallImplName (LibcallImpls[Call]);
97- }
98-
9992 // / Get the libcall routine name for the specified libcall implementation.
10093 static StringRef getLibcallImplName (RTLIB::LibcallImpl CallImpl) {
10194 if (CallImpl == RTLIB::Unsupported)
@@ -105,31 +98,20 @@ struct RuntimeLibcallsInfo {
10598 RuntimeLibcallNameSizeTable[CallImpl]);
10699 }
107100
108- // / Return the lowering's selection of implementation call for \p Call
109- RTLIB::LibcallImpl getLibcallImpl (RTLIB::Libcall Call) const {
110- return LibcallImpls[Call];
111- }
112-
113101 // / Set the CallingConv that should be used for the specified libcall
114102 // / implementation
115103 void setLibcallImplCallingConv (RTLIB::LibcallImpl Call, CallingConv::ID CC) {
116104 LibcallImplCallingConvs[Call] = CC;
117105 }
118106
119- // FIXME: Remove this wrapper in favor of directly using
120- // getLibcallImplCallingConv
121- CallingConv::ID getLibcallCallingConv (RTLIB::Libcall Call) const {
122- return LibcallImplCallingConvs[LibcallImpls[Call]];
123- }
124-
125107 // / Get the CallingConv that should be used for the specified libcall.
126108 CallingConv::ID getLibcallImplCallingConv (RTLIB::LibcallImpl Call) const {
127109 return LibcallImplCallingConvs[Call];
128110 }
129111
130- ArrayRef<RTLIB::LibcallImpl> getLibcallImpls () const {
131- // Trim UNKNOWN_LIBCALL from the back
132- return ArrayRef (LibcallImpls). drop_back () ;
112+ // / Return the libcall provided by \p Impl
113+ static RTLIB::Libcall getLibcallFromImpl (RTLIB::LibcallImpl Impl) {
114+ return ImplToLibcall[Impl] ;
133115 }
134116
135117 // / Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
@@ -143,6 +125,10 @@ struct RuntimeLibcallsInfo {
143125 return getLibcallImpl (RTLIB::MEMMOVE);
144126 }
145127
128+ unsigned getNumAvailableLibcallImpls () const {
129+ return AvailableLibcallImpls.count ();
130+ }
131+
146132 bool isAvailable (RTLIB::LibcallImpl Impl) const {
147133 return AvailableLibcallImpls.test (Impl);
148134 }
@@ -151,11 +137,6 @@ struct RuntimeLibcallsInfo {
151137 AvailableLibcallImpls.set (Impl);
152138 }
153139
154- // / Return the libcall provided by \p Impl
155- static RTLIB::Libcall getLibcallFromImpl (RTLIB::LibcallImpl Impl) {
156- return ImplToLibcall[Impl];
157- }
158-
159140 // / Check if a function name is a recognized runtime call of any kind. This
160141 // / does not consider if this call is available for any current compilation,
161142 // / just that it is a known call somewhere. This returns the set of all
@@ -176,11 +157,8 @@ struct RuntimeLibcallsInfo {
176157 LLVM_ABI RTLIB::LibcallImpl
177158 getSupportedLibcallImpl (StringRef FuncName) const {
178159 for (RTLIB::LibcallImpl Impl : lookupLibcallImplName (FuncName)) {
179- // FIXME: This should not depend on looking up ImplToLibcall, only the
180- // list of libcalls for the module.
181- RTLIB::LibcallImpl Recognized = LibcallImpls[ImplToLibcall[Impl]];
182- if (Recognized != RTLIB::Unsupported)
183- return Recognized;
160+ if (isAvailable (Impl))
161+ return Impl;
184162 }
185163
186164 return RTLIB::Unsupported;
@@ -197,10 +175,6 @@ struct RuntimeLibcallsInfo {
197175 LLVM_ABI static iota_range<RTLIB::LibcallImpl>
198176 lookupLibcallImplNameImpl (StringRef Name);
199177
200- // / Stores the implementation choice for each each libcall.
201- RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1 ] = {
202- RTLIB::Unsupported};
203-
204178 static_assert (static_cast <int >(CallingConv::C) == 0 ,
205179 " default calling conv should be encoded as 0" );
206180
0 commit comments