blob: 47e94f18a1c7aee1d8e0a3f50c4f0bb961b890a2 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- ObjectCache.h - Class definition for the ObjectCache ----*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_EXECUTIONENGINE_OBJECTCACHE_H
10#define LLVM_EXECUTIONENGINE_OBJECTCACHE_H
11
12#include "llvm/Support/MemoryBuffer.h"
13#include <memory>
14
15namespace llvm {
16
17class Module;
18
19/// This is the base ObjectCache type which can be provided to an
20/// ExecutionEngine for the purpose of avoiding compilation for Modules that
21/// have already been compiled and an object file is available.
22class ObjectCache {
23 virtual void anchor();
24
25public:
26 ObjectCache() = default;
27
28 virtual ~ObjectCache() = default;
29
30 /// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
31 virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) = 0;
32
33 /// Returns a pointer to a newly allocated MemoryBuffer that contains the
34 /// object which corresponds with Module M, or 0 if an object is not
35 /// available.
36 virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) = 0;
37};
38
39} // end namespace llvm
40
41#endif // LLVM_EXECUTIONENGINE_OBJECTCACHE_H