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,42 +98,24 @@ 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
135- // / Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
136- // / unsupported.
137- StringRef getMemcpyName () const {
138- RTLIB::LibcallImpl Memcpy = getLibcallImpl (RTLIB::MEMCPY);
139- if (Memcpy != RTLIB::Unsupported)
140- return getLibcallImplName (Memcpy);
141-
142- // Fallback to memmove if memcpy isn't available.
143- return getLibcallName (RTLIB::MEMMOVE);
117+ unsigned getNumAvailableLibcallImpls () const {
118+ return AvailableLibcallImpls.count ();
144119 }
145120
146121 bool isAvailable (RTLIB::LibcallImpl Impl) const {
@@ -151,11 +126,6 @@ struct RuntimeLibcallsInfo {
151126 AvailableLibcallImpls.set (Impl);
152127 }
153128
154- // / Return the libcall provided by \p Impl
155- static RTLIB::Libcall getLibcallFromImpl (RTLIB::LibcallImpl Impl) {
156- return ImplToLibcall[Impl];
157- }
158-
159129 // / Check if a function name is a recognized runtime call of any kind. This
160130 // / does not consider if this call is available for any current compilation,
161131 // / just that it is a known call somewhere. This returns the set of all
@@ -176,11 +146,8 @@ struct RuntimeLibcallsInfo {
176146 LLVM_ABI RTLIB::LibcallImpl
177147 getSupportedLibcallImpl (StringRef FuncName) const {
178148 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;
149+ if (isAvailable (Impl))
150+ return Impl;
184151 }
185152
186153 return RTLIB::Unsupported;
@@ -190,10 +157,6 @@ struct RuntimeLibcallsInfo {
190157 LLVM_ABI static iota_range<RTLIB::LibcallImpl>
191158 lookupLibcallImplNameImpl (StringRef Name);
192159
193- // / Stores the implementation choice for each each libcall.
194- RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1 ] = {
195- RTLIB::Unsupported};
196-
197160 static_assert (static_cast <int >(CallingConv::C) == 0 ,
198161 " default calling conv should be encoded as 0" );
199162
0 commit comments