Update copyright for 2022
[pgsql.git] / src / backend / jit / llvm / llvmjit_types.c
blobd5191cf02b3c912b4b260ab904b5988d20e0a258
1 /*-------------------------------------------------------------------------
3 * llvmjit_types.c
4 * List of types needed by JIT emitting code.
6 * JIT emitting code often needs to access struct elements, create functions
7 * with the correct signature etc. To allow synchronizing these types with a
8 * low chance of definitions getting out of sync, this file lists types and
9 * functions that directly need to be accessed from LLVM.
11 * When LLVM is first used in a backend, a bitcode version of this file will
12 * be loaded. The needed types and signatures will be stored into Struct*,
13 * Type*, Func* variables.
15 * NB: This file will not be linked into the server, it's just converted to
16 * bitcode.
19 * Copyright (c) 2016-2022, PostgreSQL Global Development Group
21 * IDENTIFICATION
22 * src/backend/jit/llvm/llvmjit_types.c
24 *-------------------------------------------------------------------------
27 #include "postgres.h"
29 #include "access/htup.h"
30 #include "access/htup_details.h"
31 #include "access/tupdesc.h"
32 #include "catalog/pg_attribute.h"
33 #include "executor/execExpr.h"
34 #include "executor/nodeAgg.h"
35 #include "executor/tuptable.h"
36 #include "fmgr.h"
37 #include "nodes/execnodes.h"
38 #include "nodes/memnodes.h"
39 #include "utils/expandeddatum.h"
40 #include "utils/palloc.h"
44 * List of types needed for JITing. These have to be non-static, otherwise
45 * clang/LLVM will omit them. As this file will never be linked into
46 * anything, that's harmless.
48 PGFunction TypePGFunction;
49 size_t TypeSizeT;
50 bool TypeStorageBool;
51 ExprStateEvalFunc TypeExprStateEvalFunc;
52 ExecEvalSubroutine TypeExecEvalSubroutine;
53 ExecEvalBoolSubroutine TypeExecEvalBoolSubroutine;
55 NullableDatum StructNullableDatum;
56 AggState StructAggState;
57 AggStatePerGroupData StructAggStatePerGroupData;
58 AggStatePerTransData StructAggStatePerTransData;
59 ExprContext StructExprContext;
60 ExprEvalStep StructExprEvalStep;
61 ExprState StructExprState;
62 FunctionCallInfoBaseData StructFunctionCallInfoData;
63 HeapTupleData StructHeapTupleData;
64 MemoryContextData StructMemoryContextData;
65 TupleTableSlot StructTupleTableSlot;
66 HeapTupleTableSlot StructHeapTupleTableSlot;
67 MinimalTupleTableSlot StructMinimalTupleTableSlot;
68 TupleDescData StructTupleDescData;
72 * To determine which attributes functions need to have (depends e.g. on
73 * compiler version and settings) to be compatible for inlining, we simply
74 * copy the attributes of this function.
76 extern Datum AttributeTemplate(PG_FUNCTION_ARGS);
77 Datum
78 AttributeTemplate(PG_FUNCTION_ARGS)
80 PG_RETURN_NULL();
84 * Clang represents stdbool.h style booleans that are returned by functions
85 * differently (as i1) than stored ones (as i8). Therefore we do not just need
86 * TypeBool (above), but also a way to determine the width of a returned
87 * integer. This allows us to keep compatible with non-stdbool using
88 * architectures.
90 extern bool FunctionReturningBool(void);
91 bool
92 FunctionReturningBool(void)
94 return false;
98 * To force signatures of functions used during JITing to be present,
99 * reference the functions required. This again has to be non-static, to avoid
100 * being removed as unnecessary.
102 void *referenced_functions[] =
104 ExecAggInitGroup,
105 ExecAggTransReparent,
106 ExecEvalAggOrderedTransDatum,
107 ExecEvalAggOrderedTransTuple,
108 ExecEvalArrayCoerce,
109 ExecEvalArrayExpr,
110 ExecEvalConstraintCheck,
111 ExecEvalConstraintNotNull,
112 ExecEvalConvertRowtype,
113 ExecEvalCurrentOfExpr,
114 ExecEvalFieldSelect,
115 ExecEvalFieldStoreDeForm,
116 ExecEvalFieldStoreForm,
117 ExecEvalFuncExprFusage,
118 ExecEvalFuncExprStrictFusage,
119 ExecEvalGroupingFunc,
120 ExecEvalMinMax,
121 ExecEvalNextValueExpr,
122 ExecEvalParamExec,
123 ExecEvalParamExtern,
124 ExecEvalRow,
125 ExecEvalRowNotNull,
126 ExecEvalRowNull,
127 ExecEvalSQLValueFunction,
128 ExecEvalScalarArrayOp,
129 ExecEvalHashedScalarArrayOp,
130 ExecEvalSubPlan,
131 ExecEvalSysVar,
132 ExecEvalWholeRowVar,
133 ExecEvalXmlExpr,
134 MakeExpandedObjectReadOnlyInternal,
135 slot_getmissingattrs,
136 slot_getsomeattrs_int,
137 strlen,
138 varsize_any,