//===- JITSymbol.h - JIT symbol abstraction ---------------------*- 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 // //===----------------------------------------------------------------------===// // // Abstraction for target process addresses. // //===----------------------------------------------------------------------===// #ifndef LLVM_EXECUTIONENGINE_JITSYMBOL_H #define LLVM_EXECUTIONENGINE_JITSYMBOL_H #include <algorithm> #include <cassert> #include <cstddef> #include <cstdint> #include <functional> #include <map> #include <set> #include <string> #include "llvm/ADT/BitmaskEnum.h" #include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" namespace llvm { class GlobalValue; class GlobalValueSummary; namespace object { class SymbolRef; } // end namespace object /// Represents an address in the target process's address space. JITTargetAddress; /// Convert a JITTargetAddress to a pointer. /// /// Note: This is a raw cast of the address bit pattern to the given pointer /// type. When casting to a function pointer in order to execute JIT'd code /// jitTargetAddressToFunction should be preferred, as it will also perform /// pointer signing on targets that require it. template <typename T> T jitTargetAddressToPointer(JITTargetAddress Addr) { … } /// Convert a JITTargetAddress to a callable function pointer. /// /// Casts the given address to a callable function pointer. This operation /// will perform pointer signing for platforms that require it (e.g. arm64e). template <typename T> T jitTargetAddressToFunction(JITTargetAddress Addr) { … } /// Convert a pointer to a JITTargetAddress. template <typename T> JITTargetAddress pointerToJITTargetAddress(T *Ptr) { … } /// Flags for symbols in the JIT. class JITSymbolFlags { … }; inline JITSymbolFlags operator&(const JITSymbolFlags &LHS, const JITSymbolFlags::FlagNames &RHS) { … } inline JITSymbolFlags operator|(const JITSymbolFlags &LHS, const JITSymbolFlags::FlagNames &RHS) { … } /// ARM-specific JIT symbol flags. /// FIXME: This should be moved into a target-specific header. class ARMJITSymbolFlags { … }; /// Represents a symbol that has been evaluated to an address already. class JITEvaluatedSymbol { … }; /// Represents a symbol in the JIT. class JITSymbol { … }; /// Symbol resolution interface. /// /// Allows symbol flags and addresses to be looked up by name. /// Symbol queries are done in bulk (i.e. you request resolution of a set of /// symbols, rather than a single one) to reduce IPC overhead in the case of /// remote JITing, and expose opportunities for parallel compilation. class JITSymbolResolver { … }; /// Legacy symbol resolution interface. class LegacyJITSymbolResolver : public JITSymbolResolver { … }; } // end namespace llvm #endif // LLVM_EXECUTIONENGINE_JITSYMBOL_H