Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Main Page
Namespaces
Classes
Files
File List
File Members
Loading...
Searching...
No Matches
src
pass
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
39
namespace
proteus
{
40
41
using namespace
llvm
;
42
43
class
AnnotationHandler
{
44
public
:
45
AnnotationHandler
(
Module
&M);
46
47
void
48
parseAnnotations
(
MapVector<Function *, JitFunctionInfo>
&JitFunctionInfoMap,
49
const
DenseMap<Value *, GlobalVariable *>
&
StubToKernelMap
,
50
bool
ForceJitAnnotateAll
);
51
52
private
:
53
Module
&M;
54
ProteusTypes
Types;
55
56
SmallString<64>
getUniqueManifestFilename();
57
58
void
appendToGlobalAnnotations(
SmallVector<Constant *>
&
NewAnnotations
);
59
60
Constant
*createJitAnnotation(
61
Function
*F,
const
SmallSetVector<RuntimeConstantInfo, 16>
&ConstantArgs);
62
63
void
createDeviceManifestFile(
64
MapVector
<
Function
*,
SmallSetVector<RuntimeConstantInfo, 16>
>
65
&
RCInfoMap
);
66
67
void
parseJitArgAnnotations(
68
SmallPtrSetImpl<Function *>
&
JitArgAnnotations
,
69
MapVector
<
Function
*,
SmallSetVector<RuntimeConstantInfo, 16>
>
70
&
RCInfoMap
);
71
72
void
parseJitArrayAnnotations(
73
SmallPtrSetImpl<Function *>
&
JitArrayAnnotations
,
74
MapVector
<
Function
*,
SmallSetVector<RuntimeConstantInfo, 16>
>
75
&
RCInfoMap
);
76
77
void
parseJitObjectAnnotations(
78
SmallPtrSetImpl<Function *>
&
JitObjectAnnotations
,
79
MapVector
<
Function
*,
SmallSetVector<RuntimeConstantInfo, 16>
>
80
&
RCInfoMap
);
81
82
void
parseJitGlobalAnnotations(
83
const
DenseMap<Value *, GlobalVariable *>
&
StubToKernelMap
,
84
MapVector
<
Function
*,
SmallSetVector<RuntimeConstantInfo, 16>
>
85
&
RCInfoMap
);
86
87
void
parseManifestFileAnnotations(
88
const
DenseMap<Value *, GlobalVariable *>
&
StubToKernelMap
,
89
MapVector
<
Function
*,
SmallSetVector<RuntimeConstantInfo, 16>
>
90
&
RCInfoMap
);
91
92
void
removeJitGlobalAnnotations();
93
};
94
95
}
// namespace proteus
96
97
#endif
Helpers.h
Types.h
proteus::AnnotationHandler
Definition
AnnotationHandler.h:43
proteus::AnnotationHandler::parseAnnotations
void parseAnnotations(MapVector< Function *, JitFunctionInfo > &JitFunctionInfoMap, const DenseMap< Value *, GlobalVariable * > &StubToKernelMap, bool ForceJitAnnotateAll)
Definition
AnnotationHandler.cpp:312
llvm
Definition
Helpers.h:141
proteus
Definition
ObjectCacheChain.cpp:26
proteus::getRuntimeConstantValue
T getRuntimeConstantValue(void *Arg)
Definition
CompilerInterfaceRuntimeConstantInfo.h:113
proteus::ProteusTypes
Definition
Types.h:14
Generated by
1.9.8