xref: /freebsd/contrib/llvm-project/llvm/include/llvm/ExecutionEngine/ObjectCache.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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 
9 #ifndef LLVM_EXECUTIONENGINE_OBJECTCACHE_H
10 #define LLVM_EXECUTIONENGINE_OBJECTCACHE_H
11 
12 #include "llvm/Support/Compiler.h"
13 #include <memory>
14 
15 namespace llvm {
16 
17 class MemoryBuffer;
18 class MemoryBufferRef;
19 class Module;
20 
21 /// This is the base ObjectCache type which can be provided to an
22 /// ExecutionEngine for the purpose of avoiding compilation for Modules that
23 /// have already been compiled and an object file is available.
24 class LLVM_ABI ObjectCache {
25   virtual void anchor();
26 
27 public:
28   ObjectCache() = default;
29 
30   virtual ~ObjectCache() = default;
31 
32   /// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
33   virtual void notifyObjectCompiled(const Module *M, MemoryBufferRef Obj) = 0;
34 
35   /// Returns a pointer to a newly allocated MemoryBuffer that contains the
36   /// object which corresponds with Module M, or 0 if an object is not
37   /// available.
38   virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) = 0;
39 };
40 
41 } // end namespace llvm
42 
43 #endif // LLVM_EXECUTIONENGINE_OBJECTCACHE_H
44