1 //===----------- JITSymbol.h - JIT symbol abstraction -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Abstraction for target process addresses.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_EXECUTIONENGINE_ORC_JITSYMBOL_H
15 #define LLVM_EXECUTIONENGINE_ORC_JITSYMBOL_H
21 /// @brief Represents an address in the target process's address space.
22 typedef uint64_t TargetAddress;
24 /// @brief Represents a symbol in the JIT.
27 typedef std::function<TargetAddress()> GetAddressFtor;
29 JITSymbol(std::nullptr_t) : CachedAddr(0) {}
31 JITSymbol(GetAddressFtor GetAddress)
32 : CachedAddr(0), GetAddress(std::move(GetAddress)) {}
34 /// @brief Returns true if the symbol exists, false otherwise.
35 explicit operator bool() const { return CachedAddr || GetAddress; }
37 /// @brief Get the address of the symbol in the target address space. Returns
38 /// '0' if the symbol does not exist.
39 TargetAddress getAddress() {
41 CachedAddr = GetAddress();
42 assert(CachedAddr && "Symbol could not be materialized.");
49 TargetAddress CachedAddr;
50 GetAddressFtor GetAddress;
55 #endif // LLVM_EXECUTIONENGINE_ORC_JITSYMBOL_H