Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
CompilerInterfaceTypes.h
Go to the documentation of this file.
1//===-- CompilerInterfaceTypes.cpp -- JIT compiler interface types --===//
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_COMPILERINTERFACETYPES_H
12#define PROTEUS_COMPILERINTERFACETYPES_H
13
14#include <cstdint>
15#include <cstring>
16#include <memory>
17
18namespace proteus {
19
37
38// This struct holds the concrete array information, the number of elements and
39// element type, for the runtime library, constructed using the runtime constant
40// info provided by the compiler pass.
41struct ArrayInfo {
42 int32_t NumElts;
44 std::shared_ptr<unsigned char[]> Blob;
45};
46
47// This struct holds the information (the byte size) for an assumed trivially
48// copyable object constructed using the runtime constant info provided by the
49// compiler pass.
50struct ObjectInfo {
51 int32_t Size;
53 std::shared_ptr<unsigned char[]> Blob;
54};
55
56// This union stores all possible runtime constant values.
57// TODO: Try std::variant as better type-checked interface, check performance
58// implications.
60 bool BoolVal;
61 int8_t Int8Val;
62 int32_t Int32Val;
63 int64_t Int64Val;
64 float FloatVal;
65 double DoubleVal;
66 long double LongDoubleVal;
67 void *PtrVal;
68};
69
70// This struct holds all information used by the runtime library for a runtime
71// constant, be it a scalar or an array, for specialization.
75 int32_t Pos;
76 int32_t Offset;
77
79 ObjectInfo ObjInfo{0, false, nullptr};
80
82 : Type(Type), Pos(Pos) {
83 std::memset(&Value, 0, sizeof(RuntimeConstantValue));
84 }
85
87 int32_t Offset)
88 : Type(Type), Pos(Pos), Offset(Offset) {
89 std::memset(&Value, 0, sizeof(RuntimeConstantValue));
90 }
91
93 int32_t NumElts, RuntimeConstantType EltType)
94 : Type(Type), Pos(Pos), ArrInfo{ArrayInfo{NumElts, EltType, nullptr}} {
95 std::memset(&Value, 0, sizeof(RuntimeConstantValue));
96 }
97
98 explicit RuntimeConstant(RuntimeConstantType Type, int32_t Pos, int32_t Size,
99 bool PassByValue)
100 : Type(Type), Pos(Pos), ObjInfo{ObjectInfo{Size, PassByValue, nullptr}} {
101 std::memset(&Value, 0, sizeof(RuntimeConstantValue));
102 }
103
108};
109
110} // namespace proteus
111
112#endif
Definition CppJitModule.cpp:21
RuntimeConstantType
Definition CompilerInterfaceTypes.h:20
@ NONE
Definition CompilerInterfaceTypes.h:22
@ ARRAY
Definition CompilerInterfaceTypes.h:33
@ VECTOR
Definition CompilerInterfaceTypes.h:32
@ INT32
Definition CompilerInterfaceTypes.h:25
@ INT64
Definition CompilerInterfaceTypes.h:26
@ FLOAT
Definition CompilerInterfaceTypes.h:27
@ STATIC_ARRAY
Definition CompilerInterfaceTypes.h:31
@ LONG_DOUBLE
Definition CompilerInterfaceTypes.h:29
@ END
Definition CompilerInterfaceTypes.h:35
@ INT8
Definition CompilerInterfaceTypes.h:24
@ BOOL
Definition CompilerInterfaceTypes.h:23
@ OBJECT
Definition CompilerInterfaceTypes.h:34
@ PTR
Definition CompilerInterfaceTypes.h:30
@ BEGIN
Definition CompilerInterfaceTypes.h:21
@ DOUBLE
Definition CompilerInterfaceTypes.h:28
size_t NumElts
Definition JitInterface.hpp:43
Definition CompilerInterfaceTypes.h:41
int32_t NumElts
Definition CompilerInterfaceTypes.h:42
RuntimeConstantType EltType
Definition CompilerInterfaceTypes.h:43
std::shared_ptr< unsigned char[]> Blob
Definition CompilerInterfaceTypes.h:44
Definition CompilerInterfaceTypes.h:50
std::shared_ptr< unsigned char[]> Blob
Definition CompilerInterfaceTypes.h:53
bool PassByValue
Definition CompilerInterfaceTypes.h:52
int32_t Size
Definition CompilerInterfaceTypes.h:51
Definition CompilerInterfaceTypes.h:72
ArrayInfo ArrInfo
Definition CompilerInterfaceTypes.h:78
RuntimeConstantValue Value
Definition CompilerInterfaceTypes.h:73
RuntimeConstantType Type
Definition CompilerInterfaceTypes.h:74
RuntimeConstant(RuntimeConstantType Type, int32_t Pos, int32_t Size, bool PassByValue)
Definition CompilerInterfaceTypes.h:98
int32_t Offset
Definition CompilerInterfaceTypes.h:76
RuntimeConstant & operator=(RuntimeConstant &&)=default
ObjectInfo ObjInfo
Definition CompilerInterfaceTypes.h:79
RuntimeConstant(RuntimeConstantType Type, int32_t Pos, int32_t Offset)
Definition CompilerInterfaceTypes.h:86
RuntimeConstant(const RuntimeConstant &)=default
RuntimeConstant(RuntimeConstantType Type, int32_t Pos, int32_t NumElts, RuntimeConstantType EltType)
Definition CompilerInterfaceTypes.h:92
RuntimeConstant & operator=(const RuntimeConstant &)=default
RuntimeConstant(RuntimeConstantType Type, int32_t Pos)
Definition CompilerInterfaceTypes.h:81
int32_t Pos
Definition CompilerInterfaceTypes.h:75
RuntimeConstant(RuntimeConstant &&)=default
Definition CompilerInterfaceTypes.h:59
double DoubleVal
Definition CompilerInterfaceTypes.h:65
int64_t Int64Val
Definition CompilerInterfaceTypes.h:63
void * PtrVal
Definition CompilerInterfaceTypes.h:67
bool BoolVal
Definition CompilerInterfaceTypes.h:60
int8_t Int8Val
Definition CompilerInterfaceTypes.h:61
int32_t Int32Val
Definition CompilerInterfaceTypes.h:62
float FloatVal
Definition CompilerInterfaceTypes.h:64
long double LongDoubleVal
Definition CompilerInterfaceTypes.h:66