[llvm] Analysis: Move LibcallLoweringInfo from CodeGen to Analysis (PR #210322)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 06:48:38 PDT 2026
================
@@ -0,0 +1,160 @@
+//===- LibcallLoweringInfo.h ------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Tracks which library function implementations to use for depending on a
+// calling context (e.g., which library function a particular subtarget should
+// use).
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_ANALYSIS_LIBCALLLOWERINGINFO_H
+#define LLVM_ANALYSIS_LIBCALLLOWERINGINFO_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/Analysis/RuntimeLibcallInfo.h"
+#include "llvm/IR/RuntimeLibcalls.h"
+#include "llvm/Pass.h"
+
+namespace llvm {
+
+/// Tracks which library functions to use for a particular subtarget or
+/// function.
+class LibcallLoweringInfo {
+private:
+ const RTLIB::RuntimeLibcallsInfo &RTLCI;
+ /// Stores the implementation choice for each libcall.
+ RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
+ RTLIB::Unsupported};
+
+public:
+ /// Callback applying the caller's context-specific (e.g. subtarget) libcall
+ /// rules on top of the module-level defaults.
+ using ApplyContextRulesFn = function_ref<void(LibcallLoweringInfo &)>;
+
+ /// Construct the lowering info from the module-level \p RTLCI, seeding the
+ /// default implementation for every available libcall, then applying the
+ /// optional \p ApplyContextRules callback for the caller's context-specific
+ /// libcall rules.
+ LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI,
+ ApplyContextRulesFn ApplyContextRules = {});
+
+ const RTLIB::RuntimeLibcallsInfo &getRuntimeLibcallsInfo() const {
+ return RTLCI;
+ }
+
+ /// Get the libcall routine name for the specified libcall.
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
+ const char *getLibcallName(RTLIB::Libcall Call) const {
+ // FIXME: Return StringRef
+ return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
+ .data();
+ }
+
+ /// Return the lowering's selection of implementation call for \p Call
+ RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
+ return LibcallImpls[Call];
+ }
+
+ /// Rename the default libcall routine name for the specified libcall.
----------------
MacDue wrote:
Rename -> Remap?
https://github.com/llvm/llvm-project/pull/210322
More information about the llvm-commits
mailing list