13#ifndef LLVM_EXECUTIONENGINE_JITSYMBOL_H
14#define LLVM_EXECUTIONENGINE_JITSYMBOL_H
33class GlobalValueSummary;
51 static_assert(std::is_pointer<T>::value,
"T must be a pointer type");
52 uintptr_t IntPtr =
static_cast<uintptr_t
>(
Addr);
53 assert(IntPtr ==
Addr &&
"JITTargetAddress value out of range for uintptr_t");
54 return reinterpret_cast<T>(IntPtr);
62 static_assert(std::is_pointer<T>::value &&
63 std::is_function<std::remove_pointer_t<T>>
::value,
64 "T must be a function pointer type");
65 return jitTargetAddressToPointer<T>(
Addr);
101 : TargetFlags(TargetFlags), Flags(Flags) {}
104 explicit operator bool()
const {
return Flags !=
None || TargetFlags != 0; }
108 return Flags ==
RHS.Flags && TargetFlags ==
RHS.TargetFlags;
238 : Address(Address), Flags(Flags) {}
241 template <
typename T>
248 explicit operator bool()
const {
return Address != 0; }
311 GetAddress = std::move(
Other.GetAddress);
312 Flags = std::move(
Other.Flags);
328 explicit operator bool()
const {
335 return std::move(
Err);
344 if (
auto CachedAddrOrErr = GetAddress()) {
345 GetAddress =
nullptr;
349 return CachedAddrOrErr.takeError();
397 virtual void anchor();
435 void anchor()
override;
Given that RA is a live value
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ARM-specific JIT symbol flags.
static ARMJITSymbolFlags fromObjectSymbol(const object::SymbolRef &Symbol)
ARMJITSymbolFlags()=default
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Function and variable summary information to aid decisions and implementation of importing.
Represents a symbol that has been evaluated to an address already.
JITSymbolFlags getFlags() const
Return the flags for this symbol.
JITTargetAddress getAddress() const
Return the address of this symbol.
JITEvaluatedSymbol(JITTargetAddress Address, JITSymbolFlags Flags)
Create a symbol for the given address and flags.
JITEvaluatedSymbol()=default
void setFlags(JITSymbolFlags Flags)
Set the flags for this symbol.
static JITEvaluatedSymbol fromPointer(T *P, JITSymbolFlags Flags=JITSymbolFlags::Exported)
Create a symbol from the given pointer with the given flags.
JITEvaluatedSymbol(std::nullptr_t)
Create a 'null' symbol.
Flags for symbols in the JIT.
JITSymbolFlags(FlagNames Flags)
Construct a JITSymbolFlags instance from the given flags.
bool hasError() const
Return true if there was an error retrieving this symbol.
TargetFlagsType & getTargetFlags()
Return a reference to the target-specific flags.
const TargetFlagsType & getTargetFlags() const
Return a reference to the target-specific flags.
UnderlyingType getRawFlagsValue() const
Get the underlying flags value as an integer.
JITSymbolFlags & operator|=(const FlagNames &RHS)
Bitwise OR-assignment for FlagNames.
JITSymbolFlags & operator&=(const FlagNames &RHS)
Bitwise AND-assignment for FlagNames.
bool isStrong() const
Returns true if the symbol isn't weak or common.
bool isExported() const
Returns true if the Exported flag is set.
bool hasMaterializationSideEffectsOnly() const
Returns true if this symbol is a materialization-side-effects-only symbol.
bool isCallable() const
Returns true if the given symbol is known to be callable.
static Expected< JITSymbolFlags > fromObjectSymbol(const object::SymbolRef &Symbol)
Construct a JITSymbolFlags value based on the flags of the given libobject symbol.
JITSymbolFlags()=default
Default-construct a JITSymbolFlags instance.
static JITSymbolFlags fromSummary(GlobalValueSummary *S)
Construct a JITSymbolFlags value based on the flags of the given global value summary.
bool isCommon() const
Returns true if the Common flag is set.
static JITSymbolFlags fromGlobalValue(const GlobalValue &GV)
Construct a JITSymbolFlags value based on the flags of the given global value.
bool operator==(const JITSymbolFlags &RHS) const
Compare for equality.
@ MaterializationSideEffectsOnly
@ LLVM_MARK_AS_BITMASK_ENUM
bool isWeak() const
Returns true if the Weak flag is set.
JITSymbolFlags(FlagNames Flags, TargetFlagsType TargetFlags)
Construct a JITSymbolFlags instance from the given flags and target flags.
Symbol resolution interface.
virtual void lookup(const LookupSet &Symbols, OnResolvedFunction OnResolved)=0
Returns the fully resolved address and flags for each of the given symbols.
virtual ~JITSymbolResolver()=default
virtual bool allowsZeroSymbols()
Specify if this resolver can return valid symbols with zero value.
std::map< StringRef, JITEvaluatedSymbol > LookupResult
std::set< StringRef > LookupSet
virtual Expected< LookupSet > getResponsibilitySet(const LookupSet &Symbols)=0
Returns the subset of the given symbols that should be materialized by the caller.
Represents a symbol in the JIT.
JITSymbol(JITTargetAddress Addr, JITSymbolFlags Flags)
Create a symbol for a definition with a known address.
JITSymbol & operator=(JITSymbol &&Other)
JITTargetAddress CachedAddr
Error takeError()
Move the error field value out of this JITSymbol.
JITSymbol(GetAddressFtor GetAddress, JITSymbolFlags Flags)
Create a symbol for a definition that doesn't have a known address yet.
Expected< JITTargetAddress > getAddress()
Get the address of the symbol in the target address space.
JITSymbol(JITSymbol &&Other)
JITSymbol & operator=(const JITSymbol &)=delete
JITSymbol(Error Err)
Create a JITSymbol representing an error in the symbol lookup process (e.g.
JITSymbol(const JITSymbol &)=delete
JITSymbol(JITEvaluatedSymbol Sym)
Construct a JITSymbol from a JITEvaluatedSymbol.
unique_function< Expected< JITTargetAddress >()> GetAddressFtor
JITSymbolFlags getFlags() const
JITSymbol(std::nullptr_t)
Create a 'null' symbol, used to represent a "symbol not found" result from a successful (non-erroneou...
Legacy symbol resolution interface.
virtual JITSymbol findSymbol(const std::string &Name)=0
This method returns the address of the specified function or variable.
Expected< LookupSet > getResponsibilitySet(const LookupSet &Symbols) final
Performs flags lookup by calling findSymbolInLogicalDylib and returning the flags value for that symb...
virtual JITSymbol findSymbolInLogicalDylib(const std::string &Name)=0
This method returns the address of the specified symbol if it exists within the logical dynamic libra...
void lookup(const LookupSet &Symbols, OnResolvedFunction OnResolved) final
Performs lookup by, for each symbol, first calling findSymbolInLogicalDylib and if that fails calling...
This is a value type class that represents a single symbol in the list of symbols in the object file.
This is an optimization pass for GlobalISel generic memory operations.
APInt operator&(APInt a, const APInt &b)
T jitTargetAddressToFunction(JITTargetAddress Addr)
Convert a JITTargetAddress to a callable function pointer.
T jitTargetAddressToPointer(JITTargetAddress Addr)
Convert a JITTargetAddress to a pointer.
uint8_t TargetFlagsType
Holds target-specific properties for a symbol.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
JITTargetAddress pointerToJITTargetAddress(T *Ptr)
Convert a pointer to a JITTargetAddress.
APInt operator|(APInt a, const APInt &b)
Implement std::hash so that hash_code can be used in STL containers.