aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp')
-rw-r--r--llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
index 10f0213..fd8ddb1 100644
--- a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
+++ b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
@@ -588,7 +588,12 @@ void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls(
PredicateSorter.insert(
PredicateWithCC()); // No predicate or CC override first.
+ constexpr unsigned BitsPerStorageElt = 64;
DenseMap<PredicateWithCC, LibcallsWithCC> Pred2Funcs;
+
+ SmallVector<uint64_t, 32> BitsetValues(
+ divideCeil(RuntimeLibcallImplDefList.size(), BitsPerStorageElt));
+
for (const Record *Elt : *Elements) {
const RuntimeLibcallImpl *LibCallImpl = getRuntimeLibcallImpl(Elt);
if (!LibCallImpl) {
@@ -597,16 +602,24 @@ void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls(
continue;
}
+ size_t BitIdx = LibCallImpl->getEnumVal();
+ uint64_t BitmaskVal = uint64_t(1) << (BitIdx % BitsPerStorageElt);
+ size_t BitsetIdx = BitIdx / BitsPerStorageElt;
+
auto It = Func2Preds.find(LibCallImpl);
if (It == Func2Preds.end()) {
+ BitsetValues[BitsetIdx] |= BitmaskVal;
Pred2Funcs[PredicateWithCC()].LibcallImpls.push_back(LibCallImpl);
continue;
}
for (const Record *Pred : It->second.first) {
const Record *CC = It->second.second;
- PredicateWithCC Key(Pred, CC);
+ AvailabilityPredicate SubsetPredicate(Pred);
+ if (SubsetPredicate.isAlwaysAvailable())
+ BitsetValues[BitsetIdx] |= BitmaskVal;
+ PredicateWithCC Key(Pred, CC);
auto &Entry = Pred2Funcs[Key];
Entry.LibcallImpls.push_back(LibCallImpl);
Entry.CallingConv = It->second.second;
@@ -614,6 +627,22 @@ void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls(
}
}
+ OS << " static constexpr LibcallImplBitset SystemAvailableImpls({\n"
+ << indent(6);
+
+ ListSeparator LS;
+ unsigned EntryCount = 0;
+ for (uint64_t Bits : BitsetValues) {
+ if (EntryCount++ == 4) {
+ EntryCount = 1;
+ OS << ",\n" << indent(6);
+ } else
+ OS << LS;
+ OS << format_hex(Bits, 16);
+ }
+ OS << "\n });\n"
+ " AvailableLibcallImpls = SystemAvailableImpls;\n\n";
+
SmallVector<PredicateWithCC, 0> SortedPredicates =
PredicateSorter.takeVector();