14 #ifndef LLVM_EXECUTIONENGINE_JITSYMBOL_H 15 #define LLVM_EXECUTIONENGINE_JITSYMBOL_H 45 static_assert(std::is_pointer<T>::value,
"T must be a pointer type");
46 uintptr_t IntPtr =
static_cast<uintptr_t
>(Addr);
47 assert(IntPtr == Addr &&
"JITTargetAddress value out of range for uintptr_t");
48 return reinterpret_cast<T>(IntPtr);
70 Materializing = 1U << 7,
75 return static_cast<FlagNames>(Orig.Flags & ~Lazy & ~Materializing);
87 : Flags(Flags), TargetFlags(TargetFlags) {}
94 return Flags == RHS.Flags &&
TargetFlags == RHS.TargetFlags;
111 return (Flags & HasError) == HasError;
117 bool isLazy()
const {
return Flags & Lazy; }
129 return (Flags & Weak) == Weak;
134 return (Flags & Common) == Common;
139 return !
isWeak() && !isCommon();
144 return (Flags & Exported) == Exported;
148 bool isCallable()
const {
return (Flags & Callable) == Callable; }
218 : Address(Address), Flags(Flags) {}
254 : CachedAddr(Addr), Flags(Flags) {}
258 : CachedAddr(Sym.getAddress()), Flags(Sym.getFlags()) {}
270 : GetAddress(
std::move(GetAddress)), CachedAddr(0), Flags(Flags) {}
277 if (Flags.hasError())
278 Err = std::move(
Other.Err);
280 CachedAddr = std::move(
Other.CachedAddr);
284 GetAddress = std::move(
Other.GetAddress);
285 Flags = std::move(
Other.Flags);
286 if (Flags.hasError())
287 Err = std::move(
Other.Err);
289 CachedAddr = std::move(
Other.CachedAddr);
294 if (Flags.hasError())
297 CachedAddr.~JITTargetAddress();
301 explicit operator bool()
const {
302 return !Flags.hasError() && (CachedAddr || GetAddress);
307 if (Flags.hasError())
308 return std::move(Err);
315 assert(!Flags.hasError() &&
"getAddress called on error value");
317 if (
auto CachedAddrOrErr = GetAddress()) {
318 GetAddress =
nullptr;
319 CachedAddr = *CachedAddrOrErr;
320 assert(CachedAddr &&
"Symbol could not be materialized.");
322 return CachedAddrOrErr.takeError();
364 getResponsibilitySet(
const LookupSet &Symbols) = 0;
367 virtual void anchor();
394 virtual JITSymbol findSymbolInLogicalDylib(
const std::string &
Name) = 0;
402 virtual JITSymbol findSymbol(
const std::string &Name) = 0;
405 virtual void anchor();
410 #endif // LLVM_EXECUTIONENGINE_JITSYMBOL_H bool isLazy() const
Returns true if this is a lazy symbol.
std::function< void(Expected< LookupResult >)> OnResolvedFunction
#define LLVM_MARK_AS_BITMASK_ENUM(LargestValue)
LLVM_MARK_AS_BITMASK_ENUM lets you opt in an individual enum type so you can perform bitwise operatio...
Represents a symbol in the JIT.
bool isCommon() const
Returns true if the Common flag is set.
This class represents lattice values for constants.
JITSymbolFlags getFlags() const
Return the flags for this symbol.
Legacy symbol resolution interface.
bool isStrong() const
Returns true if the symbol isn't weak or common.
APInt operator &(APInt a, const APInt &b)
bool operator==(const JITSymbolFlags &RHS) const
Compare for equality.
std::set< StringRef > LookupSet
T jitTargetAddressToPointer(JITTargetAddress Addr)
Convert a JITTargetAddress to a pointer.
JITSymbol & operator=(JITSymbol &&Other)
bool isWeak() const
Returns true if the Weak flag is set.
JITSymbolFlags getFlags() const
bool isMaterializing() const
Returns true if this symbol is in the process of being materialized.
void setFlags(JITSymbolFlags Flags)
Set the flags for this symbol.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Tagged union holding either a T or a Error.
static const uint16_t * lookup(unsigned opcode, unsigned domain, ArrayRef< uint16_t[3]> Table)
const TargetFlagsType & getTargetFlags() const
Return a reference to the target-specific flags.
JITSymbolFlags(FlagNames Flags, TargetFlagsType TargetFlags)
Construct a JITSymbolFlags instance from the given flags and target flags.
uint64_t JITTargetAddress
Represents an address in the target process's address space.
JITSymbol(Error Err)
Create a JITSymbol representing an error in the symbol lookup process (e.g.
bool isCallable() const
Returns true if the given symbol is known to be callable.
JITTargetAddress pointerToJITTargetAddress(T *Ptr)
JITEvaluatedSymbol(std::nullptr_t)
Create a 'null' symbol.
JITSymbolFlags(FlagNames Flags)
Construct a JITSymbolFlags instance from the given flags.
Flags for symbols in the JIT.
Symbol resolution interface.
JITSymbol(JITEvaluatedSymbol Sym)
Construct a JITSymbol from a JITEvaluatedSymbol.
JITEvaluatedSymbol(JITTargetAddress Address, JITSymbolFlags Flags)
Create a symbol for the given address and flags.
static ErrorSuccess success()
Create a success value.
bool isMaterialized() const
Returns true if this symbol is fully materialized.
JITSymbol(JITSymbol &&Other)
Expected< JITTargetAddress > getAddress()
Get the address of the symbol in the target address space.
bool hasError() const
Return true if there was an error retrieving this symbol.
UnderlyingType getRawFlagsValue() const
Get the underlying flags value as an integer.
static bool isWeak(const MCSymbolELF &Sym)
JITSymbol(std::nullptr_t)
Create a 'null' symbol, used to represent a "symbol not found" result from a successful (non-erroneou...
Represents a symbol that has been evaluated to an address already.
This is a value type class that represents a single symbol in the list of symbols in the object file...
std::function< Expected< JITTargetAddress >()> GetAddressFtor
bool isExported() const
Returns true if the Exported flag is set.
JITSymbol(JITTargetAddress Addr, JITSymbolFlags Flags)
Create a symbol for a definition with a known address.
TargetFlagsType & getTargetFlags()
Return a reference to the target-specific flags.
JITSymbolFlags & operator|=(const FlagNames &RHS)
Bitwise OR-assignment for FlagNames.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
E & operator &=(E &LHS, E RHS)
std::map< StringRef, JITEvaluatedSymbol > LookupResult
ARM-specific JIT symbol flags.
Lightweight error class with error context and mandatory checking.
static JITSymbolFlags stripTransientFlags(JITSymbolFlags Orig)
JITSymbol(GetAddressFtor GetAddress, JITSymbolFlags Flags)
Create a symbol for a definition that doesn't have a known address yet.
Error takeError()
Move the error field value out of this JITSymbol.
JITTargetAddress getAddress() const
Return the address of this symbol.
APInt operator|(APInt a, const APInt &b)
JITTargetAddress CachedAddr