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-2023, 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"
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"
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  */
49 size_t TypeSizeT;
54 
69 
70 
71 /*
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.
75  */
77 Datum
79 {
81 }
82 
83 /*
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.
89  */
90 extern bool FunctionReturningBool(void);
91 bool
93 {
94  return false;
95 }
96 
97 /*
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.
101  */
103 {
126  ExecEvalRow,
141  strlen,
142  varsize_any,
143 };
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 ExecEvalConvertRowtype(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
bool ExecEvalPreOrderedDistinctMulti(AggState *aggstate, AggStatePerTrans pertrans)
void ExecEvalFieldSelect(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 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 ExecEvalJsonConstructor(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
void ExecEvalHashedScalarArrayOp(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
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:38
void(* ExecEvalSubroutine)(ExprState *state, struct ExprEvalStep *op, ExprContext *econtext)
Definition: execExpr.h:33
void slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum)
Definition: execTuples.c:1869
void slot_getsomeattrs_int(TupleTableSlot *slot, int attnum)
Definition: execTuples.c:1903
Datum(* ExprStateEvalFunc)(struct ExprState *expression, struct ExprContext *econtext, bool *isNull)
Definition: execnodes.h:69
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:1498
HeapTupleData StructHeapTupleData
Definition: llvmjit_types.c:63
ExprContext StructExprContext
Definition: llvmjit_types.c:59
MemoryContextData StructMemoryContextData
Definition: llvmjit_types.c:64
TupleTableSlot StructTupleTableSlot
Definition: llvmjit_types.c:65
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
ExprStateEvalFunc TypeExprStateEvalFunc
Definition: llvmjit_types.c:51
FunctionCallInfoBaseData StructFunctionCallInfoData
Definition: llvmjit_types.c:62
ExprEvalStep StructExprEvalStep
Definition: llvmjit_types.c:60
TupleDescData StructTupleDescData
Definition: llvmjit_types.c:68
AggStatePerTransData StructAggStatePerTransData
Definition: llvmjit_types.c:58
MinimalTupleTableSlot StructMinimalTupleTableSlot
Definition: llvmjit_types.c:67
Datum AttributeTemplate(PG_FUNCTION_ARGS)
Definition: llvmjit_types.c:78
void * referenced_functions[]
HeapTupleTableSlot StructHeapTupleTableSlot
Definition: llvmjit_types.c:66
ExecEvalSubroutine TypeExecEvalSubroutine
Definition: llvmjit_types.c:52
bool FunctionReturningBool(void)
Definition: llvmjit_types.c:92
ExprState StructExprState
Definition: llvmjit_types.c:61
AggStatePerGroupData StructAggStatePerGroupData
Definition: llvmjit_types.c:57
size_t TypeSizeT
Definition: llvmjit_types.c:49
uintptr_t Datum
Definition: postgres.h:64