1314564Sdim//===-- ObjectCache.h - Class definition for the ObjectCache ----*- C++ -*-===//
2251607Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6251607Sdim//
7251607Sdim//===----------------------------------------------------------------------===//
8251607Sdim
9261991Sdim#ifndef LLVM_EXECUTIONENGINE_OBJECTCACHE_H
10261991Sdim#define LLVM_EXECUTIONENGINE_OBJECTCACHE_H
11251607Sdim
12251607Sdim#include "llvm/Support/MemoryBuffer.h"
13314564Sdim#include <memory>
14251607Sdim
15251607Sdimnamespace llvm {
16251607Sdim
17251607Sdimclass Module;
18251607Sdim
19251607Sdim/// This is the base ObjectCache type which can be provided to an
20251607Sdim/// ExecutionEngine for the purpose of avoiding compilation for Modules that
21251607Sdim/// have already been compiled and an object file is available.
22251607Sdimclass ObjectCache {
23261991Sdim  virtual void anchor();
24314564Sdim
25251607Sdimpublic:
26314564Sdim  ObjectCache() = default;
27251607Sdim
28314564Sdim  virtual ~ObjectCache() = default;
29251607Sdim
30251607Sdim  /// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
31280031Sdim  virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) = 0;
32251607Sdim
33280031Sdim  /// Returns a pointer to a newly allocated MemoryBuffer that contains the
34280031Sdim  /// object which corresponds with Module M, or 0 if an object is not
35280031Sdim  /// available.
36280031Sdim  virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) = 0;
37251607Sdim};
38251607Sdim
39314564Sdim} // end namespace llvm
40251607Sdim
41314564Sdim#endif // LLVM_EXECUTIONENGINE_OBJECTCACHE_H
42