1 /*-------------------------------------------------------------------------
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
19 * Copyright (c) 2016-2022, PostgreSQL Global Development Group
22 * src/backend/jit/llvm/llvmjit_types.c
24 *-------------------------------------------------------------------------
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"
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
;
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
);
78 AttributeTemplate(PG_FUNCTION_ARGS
)
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
90 extern bool FunctionReturningBool(void);
92 FunctionReturningBool(void)
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
[] =
105 ExecAggTransReparent
,
106 ExecEvalAggOrderedTransDatum
,
107 ExecEvalAggOrderedTransTuple
,
110 ExecEvalConstraintCheck
,
111 ExecEvalConstraintNotNull
,
112 ExecEvalConvertRowtype
,
113 ExecEvalCurrentOfExpr
,
115 ExecEvalFieldStoreDeForm
,
116 ExecEvalFieldStoreForm
,
117 ExecEvalFuncExprFusage
,
118 ExecEvalFuncExprStrictFusage
,
119 ExecEvalGroupingFunc
,
121 ExecEvalNextValueExpr
,
127 ExecEvalSQLValueFunction
,
128 ExecEvalScalarArrayOp
,
129 ExecEvalHashedScalarArrayOp
,
134 MakeExpandedObjectReadOnlyInternal
,
135 slot_getmissingattrs
,
136 slot_getsomeattrs_int
,