ObjectCache.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //===-- ObjectCache.h - Class definition for the ObjectCache ----*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_EXECUTIONENGINE_OBJECTCACHE_H
  9. #define LLVM_EXECUTIONENGINE_OBJECTCACHE_H
  10. #include <memory>
  11. namespace llvm {
  12. class MemoryBuffer;
  13. class MemoryBufferRef;
  14. class Module;
  15. /// This is the base ObjectCache type which can be provided to an
  16. /// ExecutionEngine for the purpose of avoiding compilation for Modules that
  17. /// have already been compiled and an object file is available.
  18. class ObjectCache {
  19. virtual void anchor();
  20. public:
  21. ObjectCache() = default;
  22. virtual ~ObjectCache() = default;
  23. /// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
  24. virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) = 0;
  25. /// Returns a pointer to a newly allocated MemoryBuffer that contains the
  26. /// object which corresponds with Module M, or 0 if an object is not
  27. /// available.
  28. virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) = 0;
  29. };
  30. } // end namespace llvm
  31. #endif // LLVM_EXECUTIONENGINE_OBJECTCACHE_H