Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
ObjectCache.hpp
Go to the documentation of this file.
1//===-- ObjectCache.hpp -- Object cache interface --===//
2//
3// Part of the Proteus Project, under the Apache License v2.0 with LLVM
4// Exceptions. See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef PROTEUS_OBJECTCACHE_HPP
12#define PROTEUS_OBJECTCACHE_HPP
13
15#include "proteus/Hashing.hpp"
16
17#include <llvm/ADT/SmallString.h>
18#include <llvm/Support/MemoryBufferRef.h>
19
20#include <cstdint>
21#include <memory>
22#include <string>
23namespace proteus {
24
25using namespace llvm;
26
27struct CacheEntry {
28 MemoryBufferRef Buffer;
30
31 static CacheEntry staticObject(MemoryBufferRef Buf) { return {Buf, false}; }
32
33 static CacheEntry sharedObject(MemoryBufferRef Buf) { return {Buf, true}; }
34
35 bool isSharedObject() const { return IsDynLib; }
36 bool isStaticObject() const { return !IsDynLib; }
37};
38
40public:
41 virtual ~ObjectCache() = default;
42
43 virtual std::string getName() const = 0;
44 virtual std::unique_ptr<CompiledLibrary> lookup(const HashT &HashValue) = 0;
45 virtual void store(const HashT &HashValue, const CacheEntry &Entry) = 0;
46 virtual void printStats() = 0;
47 virtual uint64_t getHits() const = 0;
48 virtual uint64_t getAccesses() const = 0;
49
50protected:
51 ObjectCache() = default;
52};
53
54} // namespace proteus
55
56#endif
Definition Hashing.hpp:21
Definition ObjectCache.hpp:39
virtual std::string getName() const =0
virtual void printStats()=0
virtual void store(const HashT &HashValue, const CacheEntry &Entry)=0
virtual uint64_t getAccesses() const =0
virtual ~ObjectCache()=default
virtual std::unique_ptr< CompiledLibrary > lookup(const HashT &HashValue)=0
virtual uint64_t getHits() const =0
Definition Helpers.h:141
Definition ObjectCacheChain.cpp:26
Definition ObjectCache.hpp:27
bool IsDynLib
Definition ObjectCache.hpp:29
MemoryBufferRef Buffer
Definition ObjectCache.hpp:28
static CacheEntry staticObject(MemoryBufferRef Buf)
Definition ObjectCache.hpp:31
bool isSharedObject() const
Definition ObjectCache.hpp:35
static CacheEntry sharedObject(MemoryBufferRef Buf)
Definition ObjectCache.hpp:33
bool isStaticObject() const
Definition ObjectCache.hpp:36