Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
AnnotationHandler.h
Go to the documentation of this file.
1#ifndef PROTEUS_PASS_ANNOTATIONS_PARSER_H
2#define PROTEUS_PASS_ANNOTATIONS_PARSER_H
3
4#include <llvm/ADT/SetVector.h>
5#include <llvm/Demangle/Demangle.h>
6#include <llvm/IR/Constants.h>
7#include <llvm/IR/IRBuilder.h>
8#include <llvm/IR/Instructions.h>
9#include <llvm/IR/Module.h>
10#include <llvm/IR/Verifier.h>
11#include <llvm/Support/Debug.h>
12#include <llvm/Support/JSON.h>
13#include <llvm/Support/MemoryBuffer.h>
14
15#include "Helpers.h"
16#include "Types.h"
17
18// The annotation handler supports two types of attribute-based annotations:
19// Short form, which uses an annotate attribute to specify an 1-indexed,
20// comma-separated list of scalar arguments as integers to specialize for:
21//
22// __attibute__((annotate("jit", [<argument list>])))
23//
24// Long form, which uses the annotate attributes in a JSON dict format to
25// specify arguments to specialize for. Although it is technically possible for
26// users to directly provide the long form notation, the expected usage is that
27// they call proteus::jit_arg or proteus::jit_array instrumentation functions,
28// esp. since reconstructing the expected JSON form and providing explicit
29// runtime type enum values is not ideal.
30//
31// Both annotations forms populate the global variable llvm.global.annotations
32// in the LLVM IR. For split device compilation, the handler also emits a
33// JSON manifest file for the host compilation to parse, since there is no other
34// direct channel between the split device and host compilation.
35//
36// The source of truth is the device manifest file, which the host compilation
37// pass parses to reconstruct the runtime constant info for instrumentation.
38
39namespace proteus {
40
41using namespace llvm;
42
44public:
46
47 void
51
52private:
53 Module &M;
54 ProteusTypes Types;
55
56 SmallString<64> getUniqueManifestFilename();
57
58 void appendToGlobalAnnotations(SmallVector<Constant *> &NewAnnotations);
59
60 Constant *createJitAnnotation(
62
63 void createDeviceManifestFile(
65 &RCInfoMap);
66
67 void parseJitArgAnnotations(
70 &RCInfoMap);
71
72 void parseJitArrayAnnotations(
75 &RCInfoMap);
76
77 void parseJitObjectAnnotations(
80 &RCInfoMap);
81
82 void parseJitGlobalAnnotations(
85 &RCInfoMap);
86
87 void parseManifestFileAnnotations(
90 &RCInfoMap);
91
92 void removeJitGlobalAnnotations();
93};
94
95} // namespace proteus
96
97#endif
Definition AnnotationHandler.h:43
void parseAnnotations(MapVector< Function *, JitFunctionInfo > &JitFunctionInfoMap, const DenseMap< Value *, GlobalVariable * > &StubToKernelMap, bool ForceJitAnnotateAll)
Definition AnnotationHandler.cpp:312
Definition Helpers.h:141
Definition ObjectCacheChain.cpp:26
T getRuntimeConstantValue(void *Arg)
Definition CompilerInterfaceRuntimeConstantInfo.h:113
Definition Types.h:14