@@ -135,6 +135,51 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
135135 }
136136}
137137
138+ RTLIB::LibcallImpl
139+ RuntimeLibcallsInfo::getSupportedLibcallImpl (StringRef FuncName) const {
140+ const ArrayRef<uint16_t > RuntimeLibcallNameOffsets (
141+ RuntimeLibcallNameOffsetTable);
142+
143+ iterator_range<ArrayRef<uint16_t >::const_iterator> Range =
144+ getRecognizedLibcallImpls (FuncName);
145+
146+ for (auto I = Range.begin (); I != Range.end (); ++I) {
147+ RTLIB::LibcallImpl Impl =
148+ static_cast <RTLIB::LibcallImpl>(I - RuntimeLibcallNameOffsets.begin ());
149+
150+ // FIXME: This should not depend on looking up ImplToLibcall, only the list
151+ // of libcalls for the module.
152+ RTLIB::LibcallImpl Recognized = LibcallImpls[ImplToLibcall[Impl]];
153+ if (Recognized != RTLIB::Unsupported)
154+ return Recognized;
155+ }
156+
157+ return RTLIB::Unsupported;
158+ }
159+
160+ iterator_range<ArrayRef<uint16_t >::const_iterator>
161+ RuntimeLibcallsInfo::getRecognizedLibcallImpls (StringRef FuncName) {
162+ StringTable::Iterator It = lower_bound (RuntimeLibcallImplNameTable, FuncName);
163+ if (It == RuntimeLibcallImplNameTable.end () || *It != FuncName)
164+ return iterator_range (ArrayRef<uint16_t >());
165+
166+ uint16_t IndexVal = It.offset ().value ();
167+ const ArrayRef<uint16_t > TableRef (RuntimeLibcallNameOffsetTable);
168+
169+ ArrayRef<uint16_t >::const_iterator E = TableRef.end ();
170+ ArrayRef<uint16_t >::const_iterator EntriesBegin =
171+ std::lower_bound (TableRef.begin (), E, IndexVal);
172+ ArrayRef<uint16_t >::const_iterator EntriesEnd = EntriesBegin;
173+
174+ while (EntriesEnd != E && *EntriesEnd == IndexVal)
175+ ++EntriesEnd;
176+
177+ assert (EntriesBegin != E &&
178+ " libcall found in name table but not offset table" );
179+
180+ return make_range (EntriesBegin, EntriesEnd);
181+ }
182+
138183bool RuntimeLibcallsInfo::darwinHasExp10 (const Triple &TT) {
139184 switch (TT.getOS ()) {
140185 case Triple::MacOSX:
0 commit comments