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
17 #include "llvm/Support/Compiler.h"
22 /// @brief Represents an address in the target process's address space.
23 typedef uint64_t TargetAddress;
25 /// @brief Represents a symbol in the JIT.
28 typedef std::function<TargetAddress()> GetAddressFtor;
30 JITSymbol(std::nullptr_t) : CachedAddr(0) {}
32 JITSymbol(GetAddressFtor GetAddress)
33 : CachedAddr(0), GetAddress(std::move(GetAddress)) {}
35 /// @brief Returns true if the symbol exists, false otherwise.
36 LLVM_EXPLICIT operator bool() const { return CachedAddr || GetAddress; }
38 /// @brief Get the address of the symbol in the target address space. Returns
39 /// '0' if the symbol does not exist.
40 TargetAddress getAddress() {
42 CachedAddr = GetAddress();
43 assert(CachedAddr && "Symbol could not be materialized.");
50 TargetAddress CachedAddr;
51 GetAddressFtor GetAddress;
56 #endif // LLVM_EXECUTIONENGINE_ORC_JITSYMBOL_H