PostgreSQL Source Code  git master
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * llvmjit_types.c
4  * List of types needed by JIT emitting code.
5  *
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.
10  *
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.
14  *
15  * NB: This file will not be linked into the server, it's just converted to
16  * bitcode.
17  *
18  *
19  * Copyright (c) 2016-2024, PostgreSQL Global Development Group
20  *
22  * src/backend/jit/llvm/llvmjit_types.c
23  *
24  *-------------------------------------------------------------------------
25  */
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"
43 /*
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.
47  */
49 size_t TypeSizeT;
74 /*
75  * To determine which attributes functions need to have (depends e.g. on
76  * compiler version and settings) to be compatible for inlining, we simply
77  * copy the attributes of this function.
78  */
80 Datum
82 {
86 }
88 /*
89  * And some more "templates" to give us examples of function types
90  * corresponding to function pointer types.
91  */
94  struct ExprEvalStep *op,
95  ExprContext *econtext);
96 void
98  struct ExprEvalStep *op,
99  ExprContext *econtext)
100 {
103 }
106  struct ExprEvalStep *op,
107  ExprContext *econtext);
108 bool
110  struct ExprEvalStep *op,
111  ExprContext *econtext)
112 {
116  return false;
117 }
119 /*
120  * Clang represents stdbool.h style booleans that are returned by functions
121  * differently (as i1) than stored ones (as i8). Therefore we do not just need
122  * TypeBool (above), but also a way to determine the width of a returned
123  * integer. This allows us to keep compatible with non-stdbool using
124  * architectures.
125  */
126 extern bool FunctionReturningBool(void);
127 bool
129 {
130  return false;
131 }
133 /*
134  * To force signatures of functions used during JITing to be present,
135  * reference the functions required. This again has to be non-static, to avoid
136  * being removed as unnecessary.
137  */
139 {
163  ExecEvalRow,
182  strlen,
183  varsize_any,
185 };
#define AssertVariableIsOfType(varname, typename)
Definition: c.h:981
void ExecEvalParamExtern(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalFieldStoreForm(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalGroupingFunc(ExprState *state, ExprEvalStep *op)
void ExecEvalRow(ExprState *state, ExprEvalStep *op)
void ExecEvalFieldStoreDeForm(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalCurrentOfExpr(ExprState *state, ExprEvalStep *op)
void ExecEvalSQLValueFunction(ExprState *state, ExprEvalStep *op)
void ExecEvalRowNull(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalArrayExpr(ExprState *state, ExprEvalStep *op)
void ExecEvalCoerceViaIOSafe(ExprState *state, ExprEvalStep *op)
Datum ExecInterpExprStillValid(ExprState *state, ExprContext *econtext, bool *isNull)
void ExecEvalConvertRowtype(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
bool ExecEvalPreOrderedDistinctMulti(AggState *aggstate, AggStatePerTrans pertrans)
void ExecEvalFieldSelect(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
int ExecEvalJsonExprPath(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalConstraintNotNull(ExprState *state, ExprEvalStep *op)
void ExecEvalScalarArrayOp(ExprState *state, ExprEvalStep *op)
void ExecEvalAggOrderedTransDatum(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalParamExec(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalJsonCoercion(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecAggInitGroup(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroup, ExprContext *aggcontext)
void ExecEvalNextValueExpr(ExprState *state, ExprEvalStep *op)
void ExecEvalSysVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext, TupleTableSlot *slot)
void ExecEvalMinMax(ExprState *state, ExprEvalStep *op)
void ExecEvalSubPlan(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalJsonIsPredicate(ExprState *state, ExprEvalStep *op)
Datum ExecAggCopyTransValue(AggState *aggstate, AggStatePerTrans pertrans, Datum newValue, bool newValueIsNull, Datum oldValue, bool oldValueIsNull)
void ExecEvalMergeSupportFunc(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalHashedScalarArrayOp(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalJsonCoercionFinish(ExprState *state, ExprEvalStep *op)
void ExecEvalRowNotNull(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalConstraintCheck(ExprState *state, ExprEvalStep *op)
void ExecEvalArrayCoerce(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalFuncExprStrictFusage(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalFuncExprFusage(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op)
bool ExecEvalPreOrderedDistinctSingle(AggState *aggstate, AggStatePerTrans pertrans)
void ExecEvalAggOrderedTransTuple(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
bool(* ExecEvalBoolSubroutine)(ExprState *state, struct ExprEvalStep *op, ExprContext *econtext)
Definition: execExpr.h:39
void(* ExecEvalSubroutine)(ExprState *state, struct ExprEvalStep *op, ExprContext *econtext)
Definition: execExpr.h:34
void slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum)
Definition: execTuples.c:1955
void slot_getsomeattrs_int(TupleTableSlot *slot, int attnum)
Definition: execTuples.c:1989
Datum MakeExpandedObjectReadOnlyInternal(Datum d)
Definition: expandeddatum.c:95
#define PG_RETURN_NULL()
Definition: fmgr.h:345
Datum(* PGFunction)(FunctionCallInfo fcinfo)
Definition: fmgr.h:40
Definition: fmgr.h:193
size_t varsize_any(void *p)
Definition: heaptuple.c:1594
HeapTupleHeaderData StructHeapTupleHeaderData
Definition: llvmjit_types.c:64
HeapTupleData StructHeapTupleData
Definition: llvmjit_types.c:63
ExprContext StructExprContext
Definition: llvmjit_types.c:59
MemoryContextData StructMemoryContextData
Definition: llvmjit_types.c:65
bool ExecEvalBoolSubroutineTemplate(ExprState *state, struct ExprEvalStep *op, ExprContext *econtext)
TupleTableSlot StructTupleTableSlot
Definition: llvmjit_types.c:66
PGFunction TypePGFunction
Definition: llvmjit_types.c:48
ExecEvalBoolSubroutine TypeExecEvalBoolSubroutine
Definition: llvmjit_types.c:53
bool TypeStorageBool
Definition: llvmjit_types.c:50
AggState StructAggState
Definition: llvmjit_types.c:56
NullableDatum StructNullableDatum
Definition: llvmjit_types.c:55
MinimalTupleData StructMinimalTupleData
Definition: llvmjit_types.c:71
FunctionCallInfoBaseData StructFunctionCallInfoData
Definition: llvmjit_types.c:62
ExprEvalStep StructExprEvalStep
Definition: llvmjit_types.c:60
void ExecEvalSubroutineTemplate(ExprState *state, struct ExprEvalStep *op, ExprContext *econtext)
Definition: llvmjit_types.c:97
TupleDescData StructTupleDescData
Definition: llvmjit_types.c:69
AggStatePerTransData StructAggStatePerTransData
Definition: llvmjit_types.c:58
MinimalTupleTableSlot StructMinimalTupleTableSlot
Definition: llvmjit_types.c:68
Datum AttributeTemplate(PG_FUNCTION_ARGS)
Definition: llvmjit_types.c:81
void * referenced_functions[]
HeapTupleTableSlot StructHeapTupleTableSlot
Definition: llvmjit_types.c:67
ExecEvalSubroutine TypeExecEvalSubroutine
Definition: llvmjit_types.c:52
bool FunctionReturningBool(void)
ExprState StructExprState
Definition: llvmjit_types.c:61
PlanState StructPlanState
Definition: llvmjit_types.c:70
AggStatePerGroupData StructAggStatePerGroupData
Definition: llvmjit_types.c:57
size_t TypeSizeT
Definition: llvmjit_types.c:49
uintptr_t Datum
Definition: postgres.h:64
Definition: regguts.h:323