diff options
Diffstat (limited to 'llvm/utils/TableGen')
-rw-r--r-- | llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp | 52 | ||||
-rw-r--r-- | llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp | 35 |
2 files changed, 35 insertions, 52 deletions
diff --git a/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp b/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp index ac5c455..49f7194 100644 --- a/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp +++ b/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp @@ -652,6 +652,16 @@ static constexpr uint16_t IntrinsicsToAttributesMap[] = {)"; AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id, FunctionType *FT) {)"; + // Find the max number of attributes to create the local array. + unsigned MaxNumAttrs = 0; + for (const auto [IntPtr, UniqueID] : UniqAttributes) { + const CodeGenIntrinsic &Int = *IntPtr; + unsigned NumAttrs = + llvm::count_if(Int.ArgumentAttributes, + [](const auto &Attrs) { return !Attrs.empty(); }); + NumAttrs += hasFnAttributes(Int); + MaxNumAttrs = std::max(MaxNumAttrs, NumAttrs); + } OS << formatv(R"( if (id == 0) @@ -659,46 +669,44 @@ AttributeList Intrinsic::getAttributes(LLVMContext &C, ID id, uint16_t PackedID = IntrinsicsToAttributesMap[id - 1]; uint8_t FnAttrID = PackedID >> 8; + std::pair<unsigned, AttributeSet> AS[{}]; + unsigned NumAttrs = 0; + bool HasFnAttr = false; switch(PackedID & 0xFF) {{ default: llvm_unreachable("Invalid attribute number"); -)"); +)", + MaxNumAttrs); for (const auto [IntPtr, UniqueID] : UniqAttributes) { OS << formatv(" case {}:\n", UniqueID); const CodeGenIntrinsic &Int = *IntPtr; - // Keep track of the number of attributes we're writing out. - unsigned NumAttrs = - llvm::count_if(Int.ArgumentAttributes, - [](const auto &Attrs) { return !Attrs.empty(); }); - NumAttrs += hasFnAttributes(Int); - if (NumAttrs == 0) { - OS << " return AttributeList();\n"; - continue; - } + unsigned NumAttrs = 0; - OS << " return AttributeList::get(C, {\n"; - ListSeparator LS(",\n"); for (const auto &[AttrIdx, Attrs] : enumerate(Int.ArgumentAttributes)) { if (Attrs.empty()) continue; unsigned ArgAttrID = UniqArgAttributes.find(Attrs)->second; - OS << LS - << formatv(" {{{}, getIntrinsicArgAttributeSet(C, {}, " - "FT->getContainedType({}))}", - AttrIdx, ArgAttrID, AttrIdx); + OS << formatv(" AS[{}] = {{{}, getIntrinsicArgAttributeSet(C, {}, " + "FT->getContainedType({}))};\n", + NumAttrs++, AttrIdx, ArgAttrID, AttrIdx); } - if (hasFnAttributes(Int)) { - OS << LS - << " {AttributeList::FunctionIndex, " - "getIntrinsicFnAttributeSet(C, FnAttrID)}"; - } - OS << "\n });\n"; + if (hasFnAttributes(Int)) + OS << " HasFnAttr = true;\n"; + + if (NumAttrs) + OS << formatv(" NumAttrs = {};\n", NumAttrs); + OS << " break;\n"; } OS << R"( } + if (HasFnAttr) { + AS[NumAttrs++] = {AttributeList::FunctionIndex, + getIntrinsicFnAttributeSet(C, FnAttrID)}; + } + return AttributeList::get(C, ArrayRef(AS, NumAttrs)); } #endif // GET_INTRINSIC_ATTRIBUTES diff --git a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp index a280604..412431b 100644 --- a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp +++ b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp @@ -317,29 +317,6 @@ void RuntimeLibcallEmitter::emitGetRuntimeLibcallEnum(raw_ostream &OS) const { void RuntimeLibcallEmitter::emitGetInitRuntimeLibcallNames( raw_ostream &OS) const { - OS << "const RTLIB::LibcallImpl " - "llvm::RTLIB::RuntimeLibcallsInfo::" - "DefaultLibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {\n"; - - for (const RuntimeLibcall &LibCall : RuntimeLibcallDefList) { - auto I = LibCallToDefaultImpl.find(&LibCall); - if (I == LibCallToDefaultImpl.end()) { - OS << " RTLIB::Unsupported,"; - } else { - const RuntimeLibcallImpl *LibCallImpl = I->second; - OS << " "; - LibCallImpl->emitEnumEntry(OS); - OS << ','; - } - - OS << " // "; - LibCall.emitEnumEntry(OS); - OS << '\n'; - } - - OS << " RTLIB::Unsupported\n" - "};\n\n"; - // Emit the implementation names StringToOffsetTable Table(/*AppendZero=*/true, "RTLIB::RuntimeLibcallsInfo::"); @@ -545,13 +522,11 @@ void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls( TopLevelPredicate.emitEndIf(OS); } - // Fallback to the old default set for manual table entries. - // - // TODO: Remove this when targets have switched to using generated tables by - // default. - OS << " initDefaultLibCallImpls();\n"; - - OS << "}\n\n"; + // FIXME: This should be a fatal error. A few contexts are improperly relying + // on RuntimeLibcalls constructed with fully unknown triples. + OS << " LLVM_DEBUG(dbgs() << \"no system runtime library applied to target " + "\\'\" << TT.str() << \"\\'\\n\");\n" + "}\n\n"; } void RuntimeLibcallEmitter::run(raw_ostream &OS) { |