PostgreSQL Source Code git master
llvmjit_types.c
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-2025, PostgreSQL Global Development Group
20 *
21 * IDENTIFICATION
22 * src/backend/jit/llvm/llvmjit_types.c
23 *
24 *-------------------------------------------------------------------------
25 */
26
27#include "postgres.h"
28
29#include "access/htup.h"
30#include "access/htup_details.h"
31#include "access/tupdesc.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"
41
42
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 */
49size_t TypeSizeT;
52
55
73
74
75/*
76 * To determine which attributes functions need to have (depends e.g. on
77 * compiler version and settings) to be compatible for inlining, we simply
78 * copy the attributes of this function.
79 */
83{
85
87}
88
89/*
90 * And some more "templates" to give us examples of function types
91 * corresponding to function pointer types.
92 */
93
95 struct ExprEvalStep *op,
96 ExprContext *econtext);
97void
99 struct ExprEvalStep *op,
100 ExprContext *econtext)
101{
104}
105
107 struct ExprEvalStep *op,
108 ExprContext *econtext);
109bool
111 struct ExprEvalStep *op,
112 ExprContext *econtext)
113{
116
117 return false;
118}
119
120/*
121 * Clang represents bool returned by functions differently (as i1) than stored
122 * ones (as i8). Therefore we do not just need TypeStorageBool (above), but
123 * also a way to determine the width of a returned integer.
124 */
125extern bool FunctionReturningBool(void);
126bool
128{
129 return false;
130}
131
132/*
133 * To force signatures of functions used during JITing to be present,
134 * reference the functions required. This again has to be non-static, to avoid
135 * being removed as unnecessary.
136 */
138{
182 strlen,
185};
#define AssertVariableIsOfType(varname, typename)
Definition: c.h:983
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 ExecEvalParamSet(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
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:2057
void slot_getsomeattrs_int(TupleTableSlot *slot, int attnum)
Definition: execTuples.c:2091
Datum MakeExpandedObjectReadOnlyInternal(Datum d)
Definition: expandeddatum.c:95
#define PG_RETURN_NULL()
Definition: fmgr.h:345
Datum(* PGFunction)(FunctionCallInfo fcinfo)
Definition: fmgr.h:40
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
size_t varsize_any(void *p)
Definition: heaptuple.c:1609
HeapTupleHeaderData StructHeapTupleHeaderData
Definition: llvmjit_types.c:65
HeapTupleData StructHeapTupleData
Definition: llvmjit_types.c:64
ExprContext StructExprContext
Definition: llvmjit_types.c:60
MemoryContextData StructMemoryContextData
Definition: llvmjit_types.c:66
bool ExecEvalBoolSubroutineTemplate(ExprState *state, struct ExprEvalStep *op, ExprContext *econtext)
TupleTableSlot StructTupleTableSlot
Definition: llvmjit_types.c:67
PGFunction TypePGFunction
Definition: llvmjit_types.c:48
ExecEvalBoolSubroutine TypeExecEvalBoolSubroutine
Definition: llvmjit_types.c:54
bool TypeStorageBool
Definition: llvmjit_types.c:51
AggState StructAggState
Definition: llvmjit_types.c:57
NullableDatum StructNullableDatum
Definition: llvmjit_types.c:56
MinimalTupleData StructMinimalTupleData
Definition: llvmjit_types.c:72
FunctionCallInfoBaseData StructFunctionCallInfoData
Definition: llvmjit_types.c:63
ExprEvalStep StructExprEvalStep
Definition: llvmjit_types.c:61
void ExecEvalSubroutineTemplate(ExprState *state, struct ExprEvalStep *op, ExprContext *econtext)
Definition: llvmjit_types.c:98
TupleDescData StructTupleDescData
Definition: llvmjit_types.c:70
Datum TypeDatum
Definition: llvmjit_types.c:50
AggStatePerTransData StructAggStatePerTransData
Definition: llvmjit_types.c:59
MinimalTupleTableSlot StructMinimalTupleTableSlot
Definition: llvmjit_types.c:69
Datum AttributeTemplate(PG_FUNCTION_ARGS)
Definition: llvmjit_types.c:82
void * referenced_functions[]
HeapTupleTableSlot StructHeapTupleTableSlot
Definition: llvmjit_types.c:68
ExecEvalSubroutine TypeExecEvalSubroutine
Definition: llvmjit_types.c:53
bool FunctionReturningBool(void)
ExprState StructExprState
Definition: llvmjit_types.c:62
PlanState StructPlanState
Definition: llvmjit_types.c:71
AggStatePerGroupData StructAggStatePerGroupData
Definition: llvmjit_types.c:58
size_t TypeSizeT
Definition: llvmjit_types.c:49
uint64_t Datum
Definition: postgres.h:70
Definition: regguts.h:323