Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
KernelName.h
Go to the documentation of this file.
1#ifndef PROTEUS_FRONTEND_KERNEL_NAME_H
2#define PROTEUS_FRONTEND_KERNEL_NAME_H
3
4#include <optional>
5#include <string>
6#include <utility>
7
8namespace llvm {
9class StringRef;
10} // namespace llvm
11
12namespace proteus {
13
14class HashT;
15
16// KernelName pairs the base symbol of a function with an optional suffix
17// derived from its hash.
19private:
20 std::string Base;
21 // By storing the mangled suffix, HashT can remain incomplete.
22 std::optional<std::string> HashSuffix;
23
24public:
25 KernelName(std::string Base) : Base(std::move(Base)) {}
26 KernelName(const char *Base) : Base(Base) {}
27 KernelName(const llvm::StringRef &Base);
28 KernelName(std::string Base, const HashT &Hash);
29
30 const std::string &base() const { return Base; }
31
32 std::string suffix() const {
33 return HashSuffix ? *HashSuffix : std::string{};
34 }
35
36 std::string mangled() const { return Base + suffix(); }
37
38 bool hasSuffix() const { return HashSuffix.has_value(); }
39};
40
41} // namespace proteus
42
43#endif
Definition Hashing.h:27
Definition KernelName.h:18
std::string suffix() const
Definition KernelName.h:32
bool hasSuffix() const
Definition KernelName.h:38
const std::string & base() const
Definition KernelName.h:30
KernelName(const llvm::StringRef &Base)
std::string mangled() const
Definition KernelName.h:36
KernelName(std::string Base)
Definition KernelName.h:25
KernelName(const char *Base)
Definition KernelName.h:26
Definition CompiledLibrary.h:8
Definition MemoryCache.h:27
Definition Hashing.h:284