89 LLVMBasicBlockRef entry;
90 LLVMBasicBlockRef *opblocks;
94 LLVMValueRef v_econtext;
95 LLVMValueRef v_parent;
98 LLVMValueRef v_isnullp;
101 LLVMValueRef v_tmpvaluep;
102 LLVMValueRef v_tmpisnullp;
105 LLVMValueRef v_innerslot;
106 LLVMValueRef v_outerslot;
107 LLVMValueRef v_scanslot;
108 LLVMValueRef v_resultslot;
111 LLVMValueRef v_innervalues;
112 LLVMValueRef v_innernulls;
113 LLVMValueRef v_outervalues;
114 LLVMValueRef v_outernulls;
115 LLVMValueRef v_scanvalues;
116 LLVMValueRef v_scannulls;
117 LLVMValueRef v_resultvalues;
118 LLVMValueRef v_resultnulls;
121 LLVMValueRef v_aggvalues;
122 LLVMValueRef v_aggnulls;
149 lc = LLVMGetModuleContext(mod);
151 b = LLVMCreateBuilderInContext(lc);
156 eval_fn = LLVMAddFunction(mod,
funcname,
158 LLVMSetLinkage(eval_fn, LLVMExternalLinkage);
159 LLVMSetVisibility(eval_fn, LLVMDefaultVisibility);
162 entry = LLVMAppendBasicBlockInContext(lc, eval_fn,
"entry");
165 v_state = LLVMGetParam(eval_fn, 0);
166 v_econtext = LLVMGetParam(eval_fn, 1);
167 v_isnullp = LLVMGetParam(eval_fn, 2);
169 LLVMPositionBuilderAtEnd(
b, entry);
171 v_tmpvaluep = l_struct_gep(
b,
176 v_tmpisnullp = l_struct_gep(
b,
181 v_parent = l_load_struct_gep(
b,
188 v_scanslot = l_load_struct_gep(
b,
193 v_innerslot = l_load_struct_gep(
b,
198 v_outerslot = l_load_struct_gep(
b,
203 v_resultslot = l_load_struct_gep(
b,
210 v_scanvalues = l_load_struct_gep(
b,
215 v_scannulls = l_load_struct_gep(
b,
220 v_innervalues = l_load_struct_gep(
b,
225 v_innernulls = l_load_struct_gep(
b,
230 v_outervalues = l_load_struct_gep(
b,
235 v_outernulls = l_load_struct_gep(
b,
240 v_resultvalues = l_load_struct_gep(
b,
245 v_resultnulls = l_load_struct_gep(
b,
252 v_aggvalues = l_load_struct_gep(
b,
256 "v.econtext.aggvalues");
257 v_aggnulls = l_load_struct_gep(
b,
261 "v.econtext.aggnulls");
264 opblocks =
palloc(
sizeof(LLVMBasicBlockRef) *
state->steps_len);
265 for (
int opno = 0; opno <
state->steps_len; opno++)
266 opblocks[opno] = l_bb_append_v(eval_fn,
"b.op.%d.start", opno);
269 LLVMBuildBr(
b, opblocks[0]);
271 for (
int opno = 0; opno <
state->steps_len; opno++)
275 LLVMValueRef v_resvaluep;
276 LLVMValueRef v_resnullp;
278 LLVMPositionBuilderAtEnd(
b, opblocks[opno]);
280 op = &
state->steps[opno];
290 LLVMValueRef v_tmpisnull;
291 LLVMValueRef v_tmpvalue;
293 v_tmpvalue = l_load(
b,
TypeSizeT, v_tmpvaluep,
"");
296 LLVMBuildStore(
b, v_tmpisnull, v_isnullp);
298 LLVMBuildRet(
b, v_tmpvalue);
308 LLVMBasicBlockRef b_fetch;
309 LLVMValueRef v_nvalid;
310 LLVMValueRef l_jit_deform = NULL;
313 b_fetch = l_bb_before_v(opblocks[opno + 1],
314 "op.%d.fetch", opno);
316 if (op->
d.
fetch.known_desc)
317 desc = op->
d.
fetch.known_desc;
320 tts_ops = op->
d.
fetch.kind;
326 v_slot = v_innerslot;
328 v_slot = v_outerslot;
343 LLVMBuildICmp(
b, LLVMIntUGE, v_nvalid,
344 l_int16_const(lc, op->
d.
fetch.last_var),
346 opblocks[opno + 1], b_fetch);
348 LLVMPositionBuilderAtEnd(
b, b_fetch);
365 deform_endtime, deform_starttime);
370 LLVMValueRef params[1];
381 LLVMValueRef params[2];
384 params[1] = l_int32_const(lc, op->
d.
fetch.last_var);
392 LLVMBuildBr(
b, opblocks[opno + 1]);
402 LLVMValueRef v_attnum;
403 LLVMValueRef v_values;
404 LLVMValueRef v_nulls;
408 v_values = v_innervalues;
409 v_nulls = v_innernulls;
413 v_values = v_outervalues;
414 v_nulls = v_outernulls;
418 v_values = v_scanvalues;
419 v_nulls = v_scannulls;
422 v_attnum = l_int32_const(lc, op->
d.
var.attnum);
425 LLVMBuildStore(
b,
value, v_resvaluep);
426 LLVMBuildStore(
b, isnull, v_resnullp);
428 LLVMBuildBr(
b, opblocks[opno + 1]);
439 v_slot = v_innerslot;
441 v_slot = v_outerslot;
446 v_state, op, v_econtext, v_slot);
448 LLVMBuildBr(
b, opblocks[opno + 1]);
454 v_state, op, v_econtext);
455 LLVMBuildBr(
b, opblocks[opno + 1]);
462 LLVMValueRef v_value;
463 LLVMValueRef v_isnull;
464 LLVMValueRef v_rvaluep;
465 LLVMValueRef v_risnullp;
466 LLVMValueRef v_attnum;
467 LLVMValueRef v_resultnum;
468 LLVMValueRef v_values;
469 LLVMValueRef v_nulls;
473 v_values = v_innervalues;
474 v_nulls = v_innernulls;
478 v_values = v_outervalues;
479 v_nulls = v_outernulls;
483 v_values = v_scanvalues;
484 v_nulls = v_scannulls;
488 v_attnum = l_int32_const(lc, op->
d.
assign_var.attnum);
489 v_value = l_load_gep1(
b,
TypeSizeT, v_values, v_attnum,
"");
493 v_resultnum = l_int32_const(lc, op->
d.
assign_var.resultnum);
497 &v_resultnum, 1,
"");
498 v_risnullp = l_gep(
b,
501 &v_resultnum, 1,
"");
504 LLVMBuildStore(
b, v_value, v_rvaluep);
505 LLVMBuildStore(
b, v_isnull, v_risnullp);
507 LLVMBuildBr(
b, opblocks[opno + 1]);
514 LLVMValueRef v_value,
516 LLVMValueRef v_rvaluep,
518 LLVMValueRef v_resultnum;
522 v_value = l_load(
b,
TypeSizeT, v_tmpvaluep,
"");
526 v_resultnum = l_int32_const(lc, resultnum);
528 l_gep(
b,
TypeSizeT, v_resultvalues, &v_resultnum, 1,
"");
533 LLVMBuildStore(
b, v_isnull, v_risnullp);
538 LLVMBasicBlockRef b_notnull;
539 LLVMValueRef v_params[1];
541 b_notnull = l_bb_before_v(opblocks[opno + 1],
542 "op.%d.assign_tmp.notnull", opno);
546 LLVMBuildICmp(
b, LLVMIntEQ, v_isnull,
547 l_sbool_const(0),
""),
548 b_notnull, opblocks[opno + 1]);
551 LLVMPositionBuilderAtEnd(
b, b_notnull);
552 v_params[0] = v_value;
556 llvm_pg_func(mod,
"MakeExpandedObjectReadOnlyInternal"),
566 LLVMBuildStore(
b, v_value, v_rvaluep);
568 LLVMBuildBr(
b, opblocks[opno + 1]);
574 LLVMValueRef v_constvalue,
577 v_constvalue = l_sizet_const(op->
d.
constval.value);
578 v_constnull = l_sbool_const(op->
d.
constval.isnull);
580 LLVMBuildStore(
b, v_constvalue, v_resvaluep);
581 LLVMBuildStore(
b, v_constnull, v_resnullp);
583 LLVMBuildBr(
b, opblocks[opno + 1]);
591 LLVMValueRef v_fcinfo_isnull;
592 LLVMValueRef v_retval;
596 LLVMBasicBlockRef b_nonull;
597 LLVMBasicBlockRef *b_checkargnulls;
598 LLVMValueRef v_fcinfo;
604 b_nonull = l_bb_before_v(opblocks[opno + 1],
605 "b.%d.no-null-args", opno);
608 if (op->
d.
func.nargs == 0)
609 elog(
ERROR,
"argumentless strict functions are pointless");
618 LLVMBuildStore(
b, l_sbool_const(1), v_resnullp);
622 palloc(
sizeof(LLVMBasicBlockRef *) * op->
d.
func.nargs);
623 for (
int argno = 0; argno < op->
d.
func.nargs; argno++)
624 b_checkargnulls[argno] =
625 l_bb_before_v(b_nonull,
"b.%d.isnull.%d", opno,
629 LLVMBuildBr(
b, b_checkargnulls[0]);
632 for (
int argno = 0; argno < op->
d.
func.nargs; argno++)
634 LLVMValueRef v_argisnull;
635 LLVMBasicBlockRef b_argnotnull;
637 LLVMPositionBuilderAtEnd(
b, b_checkargnulls[argno]);
643 if (argno + 1 == op->
d.
func.nargs)
644 b_argnotnull = b_nonull;
646 b_argnotnull = b_checkargnulls[argno + 1];
649 v_argisnull = l_funcnull(
b, v_fcinfo, argno);
651 LLVMBuildICmp(
b, LLVMIntEQ,
659 LLVMPositionBuilderAtEnd(
b, b_nonull);
664 LLVMBuildStore(
b, v_retval, v_resvaluep);
665 LLVMBuildStore(
b, v_fcinfo_isnull, v_resnullp);
667 LLVMBuildBr(
b, opblocks[opno + 1]);
673 v_state, op, v_econtext);
674 LLVMBuildBr(
b, opblocks[opno + 1]);
680 v_state, op, v_econtext);
681 LLVMBuildBr(
b, opblocks[opno + 1]);
693 LLVMValueRef v_boolvalue;
694 LLVMValueRef v_boolnull;
695 LLVMValueRef v_boolanynullp,
697 LLVMBasicBlockRef b_boolisnull;
698 LLVMBasicBlockRef b_boolcheckfalse;
699 LLVMBasicBlockRef b_boolisfalse;
700 LLVMBasicBlockRef b_boolcont;
701 LLVMBasicBlockRef b_boolisanynull;
703 b_boolisnull = l_bb_before_v(opblocks[opno + 1],
704 "b.%d.boolisnull", opno);
705 b_boolcheckfalse = l_bb_before_v(opblocks[opno + 1],
706 "b.%d.boolcheckfalse", opno);
707 b_boolisfalse = l_bb_before_v(opblocks[opno + 1],
708 "b.%d.boolisfalse", opno);
709 b_boolisanynull = l_bb_before_v(opblocks[opno + 1],
710 "b.%d.boolisanynull", opno);
711 b_boolcont = l_bb_before_v(opblocks[opno + 1],
712 "b.%d.boolcont", opno);
714 v_boolanynullp = l_ptr_const(op->
d.
boolexpr.anynull,
718 LLVMBuildStore(
b, l_sbool_const(0), v_boolanynullp);
721 v_boolvalue = l_load(
b,
TypeSizeT, v_resvaluep,
"");
725 LLVMBuildICmp(
b, LLVMIntEQ, v_boolnull,
726 l_sbool_const(1),
""),
731 LLVMPositionBuilderAtEnd(
b, b_boolisnull);
733 LLVMBuildStore(
b, l_sbool_const(1), v_boolanynullp);
735 LLVMBuildBr(
b, b_boolcont);
738 LLVMPositionBuilderAtEnd(
b, b_boolcheckfalse);
740 LLVMBuildICmp(
b, LLVMIntEQ, v_boolvalue,
741 l_sizet_const(0),
""),
749 LLVMPositionBuilderAtEnd(
b, b_boolisfalse);
752 LLVMBuildBr(
b, opblocks[op->
d.
boolexpr.jumpdone]);
755 LLVMPositionBuilderAtEnd(
b, b_boolcont);
761 LLVMBuildICmp(
b, LLVMIntEQ, v_boolanynull,
762 l_sbool_const(0),
""),
763 opblocks[opno + 1], b_boolisanynull);
765 LLVMPositionBuilderAtEnd(
b, b_boolisanynull);
767 LLVMBuildStore(
b, l_sbool_const(1), v_resnullp);
769 LLVMBuildStore(
b, l_sizet_const(0), v_resvaluep);
771 LLVMBuildBr(
b, opblocks[opno + 1]);
784 LLVMValueRef v_boolvalue;
785 LLVMValueRef v_boolnull;
786 LLVMValueRef v_boolanynullp,
789 LLVMBasicBlockRef b_boolisnull;
790 LLVMBasicBlockRef b_boolchecktrue;
791 LLVMBasicBlockRef b_boolistrue;
792 LLVMBasicBlockRef b_boolcont;
793 LLVMBasicBlockRef b_boolisanynull;
795 b_boolisnull = l_bb_before_v(opblocks[opno + 1],
796 "b.%d.boolisnull", opno);
797 b_boolchecktrue = l_bb_before_v(opblocks[opno + 1],
798 "b.%d.boolchecktrue", opno);
799 b_boolistrue = l_bb_before_v(opblocks[opno + 1],
800 "b.%d.boolistrue", opno);
801 b_boolisanynull = l_bb_before_v(opblocks[opno + 1],
802 "b.%d.boolisanynull", opno);
803 b_boolcont = l_bb_before_v(opblocks[opno + 1],
804 "b.%d.boolcont", opno);
806 v_boolanynullp = l_ptr_const(op->
d.
boolexpr.anynull,
810 LLVMBuildStore(
b, l_sbool_const(0), v_boolanynullp);
812 v_boolvalue = l_load(
b,
TypeSizeT, v_resvaluep,
"");
815 LLVMBuildICmp(
b, LLVMIntEQ, v_boolnull,
816 l_sbool_const(1),
""),
821 LLVMPositionBuilderAtEnd(
b, b_boolisnull);
823 LLVMBuildStore(
b, l_sbool_const(1), v_boolanynullp);
825 LLVMBuildBr(
b, b_boolcont);
828 LLVMPositionBuilderAtEnd(
b, b_boolchecktrue);
830 LLVMBuildICmp(
b, LLVMIntEQ, v_boolvalue,
831 l_sizet_const(1),
""),
839 LLVMPositionBuilderAtEnd(
b, b_boolistrue);
842 LLVMBuildBr(
b, opblocks[op->
d.
boolexpr.jumpdone]);
845 LLVMPositionBuilderAtEnd(
b, b_boolcont);
851 LLVMBuildICmp(
b, LLVMIntEQ, v_boolanynull,
852 l_sbool_const(0),
""),
853 opblocks[opno + 1], b_boolisanynull);
855 LLVMPositionBuilderAtEnd(
b, b_boolisanynull);
857 LLVMBuildStore(
b, l_sbool_const(1), v_resnullp);
859 LLVMBuildStore(
b, l_sizet_const(0), v_resvaluep);
861 LLVMBuildBr(
b, opblocks[opno + 1]);
867 LLVMValueRef v_boolvalue;
868 LLVMValueRef v_negbool;
871 v_boolvalue = l_load(
b,
TypeSizeT, v_resvaluep,
"");
872 v_negbool = LLVMBuildZExt(
b,
873 LLVMBuildICmp(
b, LLVMIntEQ,
884 LLVMBuildStore(
b, v_negbool, v_resvaluep);
886 LLVMBuildBr(
b, opblocks[opno + 1]);
892 LLVMValueRef v_resnull;
893 LLVMValueRef v_resvalue;
894 LLVMValueRef v_nullorfalse;
895 LLVMBasicBlockRef b_qualfail;
897 b_qualfail = l_bb_before_v(opblocks[opno + 1],
898 "op.%d.qualfail", opno);
900 v_resvalue = l_load(
b,
TypeSizeT, v_resvaluep,
"");
905 LLVMBuildICmp(
b, LLVMIntEQ, v_resnull,
906 l_sbool_const(1),
""),
907 LLVMBuildICmp(
b, LLVMIntEQ, v_resvalue,
908 l_sizet_const(0),
""),
917 LLVMPositionBuilderAtEnd(
b, b_qualfail);
919 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
921 LLVMBuildStore(
b, l_sizet_const(0), v_resvaluep);
923 LLVMBuildBr(
b, opblocks[op->
d.
qualexpr.jumpdone]);
929 LLVMBuildBr(
b, opblocks[op->
d.
jump.jumpdone]);
935 LLVMValueRef v_resnull;
942 LLVMBuildICmp(
b, LLVMIntEQ, v_resnull,
943 l_sbool_const(1),
""),
944 opblocks[op->
d.
jump.jumpdone],
951 LLVMValueRef v_resnull;
958 LLVMBuildICmp(
b, LLVMIntEQ, v_resnull,
959 l_sbool_const(0),
""),
960 opblocks[op->
d.
jump.jumpdone],
968 LLVMValueRef v_resnull;
969 LLVMValueRef v_resvalue;
970 LLVMValueRef v_nullorfalse;
974 v_resvalue = l_load(
b,
TypeSizeT, v_resvaluep,
"");
979 LLVMBuildICmp(
b, LLVMIntEQ, v_resnull,
980 l_sbool_const(1),
""),
981 LLVMBuildICmp(
b, LLVMIntEQ, v_resvalue,
982 l_sizet_const(0),
""),
987 opblocks[op->
d.
jump.jumpdone],
995 LLVMValueRef v_resvalue;
999 LLVMBuildICmp(
b, LLVMIntEQ, v_resnull,
1000 l_sbool_const(1),
""),
1004 LLVMBuildStore(
b, v_resvalue, v_resvaluep);
1005 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
1007 LLVMBuildBr(
b, opblocks[opno + 1]);
1014 LLVMValueRef v_resvalue;
1018 LLVMBuildICmp(
b, LLVMIntEQ, v_resnull,
1019 l_sbool_const(1),
""),
1023 LLVMBuildStore(
b, v_resvalue, v_resvaluep);
1024 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
1026 LLVMBuildBr(
b, opblocks[opno + 1]);
1032 v_state, op, v_econtext);
1033 LLVMBuildBr(
b, opblocks[opno + 1]);
1038 v_state, op, v_econtext);
1039 LLVMBuildBr(
b, opblocks[opno + 1]);
1047 LLVMBasicBlockRef b_isnull,
1051 b_isnull = l_bb_before_v(opblocks[opno + 1],
1052 "op.%d.isnull", opno);
1053 b_notnull = l_bb_before_v(opblocks[opno + 1],
1054 "op.%d.isnotnull", opno);
1058 LLVMBuildICmp(
b, LLVMIntEQ, v_resnull,
1059 l_sbool_const(1),
""),
1060 b_isnull, b_notnull);
1063 LLVMPositionBuilderAtEnd(
b, b_isnull);
1066 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
1071 LLVMBuildStore(
b, l_sizet_const(0), v_resvaluep);
1075 LLVMBuildStore(
b, l_sizet_const(1), v_resvaluep);
1078 LLVMBuildBr(
b, opblocks[opno + 1]);
1080 LLVMPositionBuilderAtEnd(
b, b_notnull);
1092 LLVMValueRef v_value =
1095 v_value = LLVMBuildZExt(
b,
1096 LLVMBuildICmp(
b, LLVMIntEQ,
1101 LLVMBuildStore(
b, v_value, v_resvaluep);
1103 LLVMBuildBr(
b, opblocks[opno + 1]);
1109 v_state, op, v_econtext);
1110 LLVMBuildBr(
b, opblocks[opno + 1]);
1115 v_state, op, v_econtext);
1116 LLVMBuildBr(
b, opblocks[opno + 1]);
1121 LLVMValueRef v_func;
1122 LLVMValueRef v_params[3];
1124 v_func = l_ptr_const(op->
d.
cparam.paramfunc,
1127 v_params[0] = v_state;
1129 v_params[2] = v_econtext;
1135 LLVMBuildBr(
b, opblocks[opno + 1]);
1141 v_state, op, v_econtext);
1142 LLVMBuildBr(
b, opblocks[opno + 1]);
1148 LLVMValueRef v_func;
1149 LLVMValueRef v_params[3];
1155 v_params[0] = v_state;
1157 v_params[2] = v_econtext;
1165 LLVMBuildICmp(
b, LLVMIntEQ, v_ret,
1166 l_sbool_const(1),
""),
1168 opblocks[jumpdone]);
1176 LLVMValueRef v_func;
1177 LLVMValueRef v_params[3];
1179 v_func = l_ptr_const(op->
d.
sbsref.subscriptfunc,
1182 v_params[0] = v_state;
1184 v_params[2] = v_econtext;
1190 LLVMBuildBr(
b, opblocks[opno + 1]);
1196 LLVMBasicBlockRef b_avail,
1198 LLVMValueRef v_casevaluep,
1200 LLVMValueRef v_casenullp,
1202 LLVMValueRef v_casevaluenull;
1204 b_avail = l_bb_before_v(opblocks[opno + 1],
1205 "op.%d.avail", opno);
1206 b_notavail = l_bb_before_v(opblocks[opno + 1],
1207 "op.%d.notavail", opno);
1209 v_casevaluep = l_ptr_const(op->
d.
casetest.value,
1211 v_casenullp = l_ptr_const(op->
d.
casetest.isnull,
1215 LLVMBuildICmp(
b, LLVMIntEQ,
1216 LLVMBuildPtrToInt(
b, v_casevaluep,
1218 l_sizet_const(0),
"");
1219 LLVMBuildCondBr(
b, v_casevaluenull, b_notavail, b_avail);
1222 LLVMPositionBuilderAtEnd(
b, b_avail);
1223 v_casevalue = l_load(
b,
TypeSizeT, v_casevaluep,
"");
1225 LLVMBuildStore(
b, v_casevalue, v_resvaluep);
1226 LLVMBuildStore(
b, v_casenull, v_resnullp);
1227 LLVMBuildBr(
b, opblocks[opno + 1]);
1230 LLVMPositionBuilderAtEnd(
b, b_notavail);
1232 l_load_struct_gep(
b,
1237 l_load_struct_gep(
b,
1241 LLVMBuildStore(
b, v_casevalue, v_resvaluep);
1242 LLVMBuildStore(
b, v_casenull, v_resnullp);
1244 LLVMBuildBr(
b, opblocks[opno + 1]);
1250 LLVMBasicBlockRef b_notnull;
1251 LLVMValueRef v_params[1];
1253 LLVMValueRef v_nullp;
1254 LLVMValueRef v_valuep;
1255 LLVMValueRef v_null;
1256 LLVMValueRef v_value;
1258 b_notnull = l_bb_before_v(opblocks[opno + 1],
1259 "op.%d.readonly.notnull", opno);
1267 LLVMBuildStore(
b, v_null, v_resnullp);
1271 LLVMBuildICmp(
b, LLVMIntEQ, v_null,
1272 l_sbool_const(1),
""),
1273 opblocks[opno + 1], b_notnull);
1276 LLVMPositionBuilderAtEnd(
b, b_notnull);
1281 v_value = l_load(
b,
TypeSizeT, v_valuep,
"");
1283 v_params[0] = v_value;
1287 llvm_pg_func(mod,
"MakeExpandedObjectReadOnlyInternal"),
1289 LLVMBuildStore(
b, v_ret, v_resvaluep);
1291 LLVMBuildBr(
b, opblocks[opno + 1]);
1299 LLVMValueRef v_fn_out,
1301 LLVMValueRef v_fcinfo_out,
1303 LLVMValueRef v_fcinfo_in_isnullp;
1304 LLVMValueRef v_retval;
1305 LLVMValueRef v_resvalue;
1306 LLVMValueRef v_resnull;
1308 LLVMValueRef v_output_skip;
1309 LLVMValueRef v_output;
1311 LLVMBasicBlockRef b_skipoutput;
1312 LLVMBasicBlockRef b_calloutput;
1313 LLVMBasicBlockRef b_input;
1314 LLVMBasicBlockRef b_inputcall;
1316 fcinfo_out = op->
d.
iocoerce.fcinfo_data_out;
1317 fcinfo_in = op->
d.
iocoerce.fcinfo_data_in;
1319 b_skipoutput = l_bb_before_v(opblocks[opno + 1],
1320 "op.%d.skipoutputnull", opno);
1321 b_calloutput = l_bb_before_v(opblocks[opno + 1],
1322 "op.%d.calloutput", opno);
1323 b_input = l_bb_before_v(opblocks[opno + 1],
1324 "op.%d.input", opno);
1325 b_inputcall = l_bb_before_v(opblocks[opno + 1],
1326 "op.%d.inputcall", opno);
1333 v_fcinfo_in_isnullp =
1338 "v_fcinfo_in_isnull");
1343 LLVMBuildICmp(
b, LLVMIntEQ, v_resnull,
1344 l_sbool_const(1),
""),
1348 LLVMPositionBuilderAtEnd(
b, b_skipoutput);
1349 v_output_skip = l_sizet_const(0);
1350 LLVMBuildBr(
b, b_input);
1352 LLVMPositionBuilderAtEnd(
b, b_calloutput);
1353 v_resvalue = l_load(
b,
TypeSizeT, v_resvaluep,
"");
1358 l_funcvaluep(
b, v_fcinfo_out, 0));
1361 l_funcnullp(
b, v_fcinfo_out, 0));
1363 v_output = l_call(
b,
1365 v_fn_out, &v_fcinfo_out,
1366 1,
"funccall_coerce_out");
1367 LLVMBuildBr(
b, b_input);
1370 LLVMPositionBuilderAtEnd(
b, b_input);
1374 LLVMValueRef incoming_values[2];
1375 LLVMBasicBlockRef incoming_blocks[2];
1377 incoming_values[0] = v_output_skip;
1378 incoming_blocks[0] = b_skipoutput;
1380 incoming_values[1] = v_output;
1381 incoming_blocks[1] = b_calloutput;
1383 v_output = LLVMBuildPhi(
b,
TypeSizeT,
"output");
1384 LLVMAddIncoming(v_output,
1385 incoming_values, incoming_blocks,
1396 LLVMBuildICmp(
b, LLVMIntEQ, v_output,
1397 l_sizet_const(0),
""),
1403 LLVMBuildBr(
b, b_inputcall);
1406 LLVMPositionBuilderAtEnd(
b, b_inputcall);
1409 LLVMBuildStore(
b, v_output,
1410 l_funcvaluep(
b, v_fcinfo_in, 0));
1411 LLVMBuildStore(
b, v_resnull,
1412 l_funcnullp(
b, v_fcinfo_in, 0));
1418 LLVMBuildStore(
b, l_sbool_const(0), v_fcinfo_in_isnullp);
1420 v_retval = l_call(
b,
1422 v_fn_in, &v_fcinfo_in, 1,
1423 "funccall_iocoerce_in");
1425 LLVMBuildStore(
b, v_retval, v_resvaluep);
1427 LLVMBuildBr(
b, opblocks[opno + 1]);
1434 LLVMBuildBr(
b, opblocks[opno + 1]);
1442 LLVMValueRef v_fcinfo;
1443 LLVMValueRef v_fcinfo_isnull;
1445 LLVMValueRef v_argnull0,
1447 LLVMValueRef v_argnull1,
1450 LLVMValueRef v_anyargisnull;
1451 LLVMValueRef v_bothargisnull;
1453 LLVMValueRef v_result;
1455 LLVMBasicBlockRef b_noargnull;
1456 LLVMBasicBlockRef b_checkbothargnull;
1457 LLVMBasicBlockRef b_bothargnull;
1458 LLVMBasicBlockRef b_anyargnull;
1460 b_noargnull = l_bb_before_v(opblocks[opno + 1],
"op.%d.noargnull", opno);
1461 b_checkbothargnull = l_bb_before_v(opblocks[opno + 1],
"op.%d.checkbothargnull", opno);
1462 b_bothargnull = l_bb_before_v(opblocks[opno + 1],
"op.%d.bothargnull", opno);
1463 b_anyargnull = l_bb_before_v(opblocks[opno + 1],
"op.%d.anyargnull", opno);
1468 v_argnull0 = l_funcnull(
b, v_fcinfo, 0);
1469 v_argisnull0 = LLVMBuildICmp(
b, LLVMIntEQ, v_argnull0,
1470 l_sbool_const(1),
"");
1471 v_argnull1 = l_funcnull(
b, v_fcinfo, 1);
1472 v_argisnull1 = LLVMBuildICmp(
b, LLVMIntEQ, v_argnull1,
1473 l_sbool_const(1),
"");
1475 v_anyargisnull = LLVMBuildOr(
b, v_argisnull0, v_argisnull1,
"");
1476 v_bothargisnull = LLVMBuildAnd(
b, v_argisnull0, v_argisnull1,
"");
1483 LLVMBuildCondBr(
b, v_anyargisnull, b_checkbothargnull,
1489 LLVMPositionBuilderAtEnd(
b, b_checkbothargnull);
1490 LLVMBuildCondBr(
b, v_bothargisnull, b_bothargnull,
1495 LLVMPositionBuilderAtEnd(
b, b_bothargnull);
1496 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
1498 LLVMBuildStore(
b, l_sizet_const(1), v_resvaluep);
1500 LLVMBuildStore(
b, l_sizet_const(0), v_resvaluep);
1502 LLVMBuildBr(
b, opblocks[opno + 1]);
1505 LLVMPositionBuilderAtEnd(
b, b_anyargnull);
1506 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
1508 LLVMBuildStore(
b, l_sizet_const(0), v_resvaluep);
1510 LLVMBuildStore(
b, l_sizet_const(1), v_resvaluep);
1511 LLVMBuildBr(
b, opblocks[opno + 1]);
1514 LLVMPositionBuilderAtEnd(
b, b_noargnull);
1524 LLVMBuildICmp(
b, LLVMIntEQ,
1526 l_sizet_const(0),
""),
1530 LLVMBuildStore(
b, v_fcinfo_isnull, v_resnullp);
1531 LLVMBuildStore(
b, v_result, v_resvaluep);
1533 LLVMBuildBr(
b, opblocks[opno + 1]);
1541 LLVMValueRef v_fcinfo;
1542 LLVMValueRef v_fcinfo_isnull;
1543 LLVMValueRef v_argnull0;
1544 LLVMValueRef v_argnull1;
1545 LLVMValueRef v_anyargisnull;
1546 LLVMValueRef v_arg0;
1547 LLVMBasicBlockRef b_hasnull;
1548 LLVMBasicBlockRef b_nonull;
1549 LLVMBasicBlockRef b_argsequal;
1550 LLVMValueRef v_retval;
1551 LLVMValueRef v_argsequal;
1553 b_hasnull = l_bb_before_v(opblocks[opno + 1],
1554 "b.%d.null-args", opno);
1555 b_nonull = l_bb_before_v(opblocks[opno + 1],
1556 "b.%d.no-null-args", opno);
1557 b_argsequal = l_bb_before_v(opblocks[opno + 1],
1558 "b.%d.argsequal", opno);
1563 v_arg0 = l_funcvalue(
b, v_fcinfo, 0);
1566 v_argnull0 = l_funcnull(
b, v_fcinfo, 0);
1567 v_argnull1 = l_funcnull(
b, v_fcinfo, 1);
1571 LLVMBuildICmp(
b, LLVMIntEQ, v_argnull0,
1572 l_sbool_const(1),
""),
1573 LLVMBuildICmp(
b, LLVMIntEQ, v_argnull1,
1574 l_sbool_const(1),
""),
1577 LLVMBuildCondBr(
b, v_anyargisnull, b_hasnull, b_nonull);
1580 LLVMPositionBuilderAtEnd(
b, b_hasnull);
1581 LLVMBuildStore(
b, v_argnull0, v_resnullp);
1582 LLVMBuildStore(
b, v_arg0, v_resvaluep);
1583 LLVMBuildBr(
b, opblocks[opno + 1]);
1586 LLVMPositionBuilderAtEnd(
b, b_nonull);
1596 if (op->
d.
func.make_ro)
1598 LLVMValueRef v_params[1];
1599 LLVMValueRef v_arg0_ro;
1601 v_params[0] = v_arg0;
1605 llvm_pg_func(mod,
"MakeExpandedObjectReadOnlyInternal"),
1607 LLVMBuildStore(
b, v_arg0_ro,
1608 l_funcvaluep(
b, v_fcinfo, 0));
1618 v_argsequal = LLVMBuildAnd(
b,
1619 LLVMBuildICmp(
b, LLVMIntEQ,
1623 LLVMBuildICmp(
b, LLVMIntEQ,
1628 LLVMBuildCondBr(
b, v_argsequal, b_argsequal, b_hasnull);
1631 LLVMPositionBuilderAtEnd(
b, b_argsequal);
1632 LLVMBuildStore(
b, l_sbool_const(1), v_resnullp);
1633 LLVMBuildStore(
b, l_sizet_const(0), v_resvaluep);
1635 LLVMBuildBr(
b, opblocks[opno + 1]);
1642 LLVMBuildBr(
b, opblocks[opno + 1]);
1648 LLVMBuildBr(
b, opblocks[opno + 1]);
1654 LLVMBuildBr(
b, opblocks[opno + 1]);
1660 LLVMBuildBr(
b, opblocks[opno + 1]);
1665 v_state, op, v_econtext);
1666 LLVMBuildBr(
b, opblocks[opno + 1]);
1672 LLVMBuildBr(
b, opblocks[opno + 1]);
1678 LLVMValueRef v_fcinfo_isnull;
1679 LLVMBasicBlockRef b_null;
1680 LLVMBasicBlockRef b_compare;
1681 LLVMBasicBlockRef b_compare_result;
1683 LLVMValueRef v_retval;
1685 b_null = l_bb_before_v(opblocks[opno + 1],
1686 "op.%d.row-null", opno);
1687 b_compare = l_bb_before_v(opblocks[opno + 1],
1688 "op.%d.row-compare", opno);
1690 l_bb_before_v(opblocks[opno + 1],
1691 "op.%d.row-compare-result",
1700 LLVMValueRef v_fcinfo;
1701 LLVMValueRef v_argnull0;
1702 LLVMValueRef v_argnull1;
1703 LLVMValueRef v_anyargisnull;
1705 v_fcinfo = l_ptr_const(fcinfo,
1708 v_argnull0 = l_funcnull(
b, v_fcinfo, 0);
1709 v_argnull1 = l_funcnull(
b, v_fcinfo, 1);
1718 LLVMBuildICmp(
b, LLVMIntEQ,
1720 l_sbool_const(1),
""),
1723 LLVMBuildCondBr(
b, v_anyargisnull, b_null, b_compare);
1727 LLVMBuildBr(
b, b_compare);
1731 LLVMPositionBuilderAtEnd(
b, b_compare);
1736 LLVMBuildStore(
b, v_retval, v_resvaluep);
1749 LLVMPositionBuilderAtEnd(
b, b_compare_result);
1756 l_sizet_const(0),
""),
1764 LLVMPositionBuilderAtEnd(
b, b_null);
1765 LLVMBuildStore(
b, l_sbool_const(1), v_resnullp);
1775 LLVMValueRef v_cmpresult;
1776 LLVMValueRef v_result;
1777 LLVMIntPredicate predicate;
1787 LLVMInt32TypeInContext(lc),
"");
1792 predicate = LLVMIntSLT;
1795 predicate = LLVMIntSLE;
1798 predicate = LLVMIntSGT;
1801 predicate = LLVMIntSGE;
1810 v_result = LLVMBuildICmp(
b,
1813 l_int32_const(lc, 0),
1815 v_result = LLVMBuildZExt(
b, v_result,
TypeSizeT,
"");
1817 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
1818 LLVMBuildStore(
b, v_result, v_resvaluep);
1820 LLVMBuildBr(
b, opblocks[opno + 1]);
1827 LLVMBuildBr(
b, opblocks[opno + 1]);
1832 v_state, op, v_econtext);
1833 LLVMBuildBr(
b, opblocks[opno + 1]);
1838 v_state, op, v_econtext);
1839 LLVMBuildBr(
b, opblocks[opno + 1]);
1844 v_state, op, v_econtext);
1845 LLVMBuildBr(
b, opblocks[opno + 1]);
1850 LLVMBasicBlockRef b_avail,
1852 LLVMValueRef v_casevaluep,
1854 LLVMValueRef v_casenullp,
1856 LLVMValueRef v_casevaluenull;
1858 b_avail = l_bb_before_v(opblocks[opno + 1],
1859 "op.%d.avail", opno);
1860 b_notavail = l_bb_before_v(opblocks[opno + 1],
1861 "op.%d.notavail", opno);
1863 v_casevaluep = l_ptr_const(op->
d.
casetest.value,
1865 v_casenullp = l_ptr_const(op->
d.
casetest.isnull,
1869 LLVMBuildICmp(
b, LLVMIntEQ,
1870 LLVMBuildPtrToInt(
b, v_casevaluep,
1872 l_sizet_const(0),
"");
1875 b_notavail, b_avail);
1878 LLVMPositionBuilderAtEnd(
b, b_avail);
1879 v_casevalue = l_load(
b,
TypeSizeT, v_casevaluep,
"");
1881 LLVMBuildStore(
b, v_casevalue, v_resvaluep);
1882 LLVMBuildStore(
b, v_casenull, v_resnullp);
1883 LLVMBuildBr(
b, opblocks[opno + 1]);
1886 LLVMPositionBuilderAtEnd(
b, b_notavail);
1888 l_load_struct_gep(
b,
1894 l_load_struct_gep(
b,
1899 LLVMBuildStore(
b, v_casevalue, v_resvaluep);
1900 LLVMBuildStore(
b, v_casenull, v_resnullp);
1902 LLVMBuildBr(
b, opblocks[opno + 1]);
1909 LLVMBuildBr(
b, opblocks[opno + 1]);
1915 LLVMBuildBr(
b, opblocks[opno + 1]);
1920 LLVMValueRef v_initvalue;
1924 LLVMBuildStore(
b, v_initvalue, v_resvaluep);
1925 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
1926 LLVMBuildBr(
b, opblocks[opno + 1]);
1936 LLVMValueRef v_fcinfo;
1937 LLVMValueRef v_fcinfo_isnull;
1938 LLVMValueRef v_retval;
1939 LLVMBasicBlockRef b_checkargnull;
1940 LLVMBasicBlockRef b_ifnotnull;
1941 LLVMBasicBlockRef b_ifnullblock;
1942 LLVMValueRef v_argisnull;
1943 LLVMValueRef v_prevhash = NULL;
1956 LLVMValueRef v_tmp1;
1957 LLVMValueRef v_tmp2;
1960 tmp = l_ptr_const(&op->
d.
hashdatum.iresult->value,
1967 v_prevhash = l_load(
b,
TypeSizeT, tmp,
"prevhash");
1973 v_tmp1 = LLVMBuildShl(
b, v_prevhash, l_sizet_const(1),
1975 v_tmp1 = LLVMBuildAnd(
b, v_tmp1,
1976 l_sizet_const(0xffffffff),
"");
1977 v_tmp2 = LLVMBuildLShr(
b, v_prevhash,
1978 l_sizet_const(31),
"");
1979 v_prevhash = LLVMBuildOr(
b, v_tmp1, v_tmp2,
1987 b_ifnotnull = l_bb_before_v(opblocks[opno + 1],
1992 if (fcinfo->
nargs != 1)
1993 elog(
ERROR,
"incorrect number of function arguments");
1995 v_fcinfo = l_ptr_const(fcinfo,
1998 b_checkargnull = l_bb_before_v(b_ifnotnull,
1999 "b.%d.isnull.0", opno);
2001 LLVMBuildBr(
b, b_checkargnull);
2010 b_ifnullblock = l_bb_before_v(b_ifnotnull,
2014 LLVMPositionBuilderAtEnd(
b, b_ifnullblock);
2020 LLVMBuildStore(
b, l_sbool_const(1), v_resnullp);
2021 LLVMBuildStore(
b, l_sizet_const(0), v_resvaluep);
2022 LLVMBuildBr(
b, opblocks[op->
d.
hashdatum.jumpdone]);
2026 b_ifnullblock = l_bb_before_v(b_ifnotnull,
2030 LLVMPositionBuilderAtEnd(
b, b_ifnullblock);
2033 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
2037 Assert(v_prevhash != NULL);
2043 LLVMBuildStore(
b, v_prevhash, v_resvaluep);
2053 LLVMBuildStore(
b, l_sizet_const(0), v_resvaluep);
2056 LLVMBuildBr(
b, opblocks[opno + 1]);
2059 LLVMPositionBuilderAtEnd(
b, b_checkargnull);
2062 v_argisnull = l_funcnull(
b, v_fcinfo, 0);
2072 LLVMPositionBuilderAtEnd(
b, b_ifnotnull);
2081 LLVMValueRef v_tmp1;
2082 LLVMValueRef v_tmp2;
2085 tmp = l_ptr_const(&op->
d.
hashdatum.iresult->value,
2092 v_prevhash = l_load(
b,
TypeSizeT, tmp,
"prevhash");
2098 v_tmp1 = LLVMBuildShl(
b, v_prevhash, l_sizet_const(1),
2100 v_tmp1 = LLVMBuildAnd(
b, v_tmp1,
2101 l_sizet_const(0xffffffff),
"");
2102 v_tmp2 = LLVMBuildLShr(
b, v_prevhash,
2103 l_sizet_const(31),
"");
2104 v_prevhash = LLVMBuildOr(
b, v_tmp1, v_tmp2,
2118 v_retval = LLVMBuildXor(
b, v_prevhash, v_retval,
2121 LLVMBuildStore(
b, v_retval, v_resvaluep);
2122 LLVMBuildStore(
b, l_sbool_const(0), v_resnullp);
2124 LLVMBuildBr(
b, opblocks[opno + 1]);
2130 v_state, op, v_econtext);
2131 LLVMBuildBr(
b, opblocks[opno + 1]);
2137 LLVMBuildBr(
b, opblocks[opno + 1]);
2142 v_state, op, v_econtext);
2143 LLVMBuildBr(
b, opblocks[opno + 1]);
2149 LLVMBuildBr(
b, opblocks[opno + 1]);
2154 v_state, op, v_econtext);
2155 LLVMBuildBr(
b, opblocks[opno + 1]);
2161 LLVMBuildBr(
b, opblocks[opno + 1]);
2174 v_state, op, v_econtext);
2186 LLVMValueRef v_jump_empty;
2187 LLVMValueRef v_jump_error;
2188 LLVMValueRef v_jump_coercion;
2189 LLVMValueRef v_switch;
2190 LLVMBasicBlockRef b_done,
2196 l_bb_before_v(opblocks[opno + 1],
2197 "op.%d.jsonexpr_empty", opno);
2199 l_bb_before_v(opblocks[opno + 1],
2200 "op.%d.jsonexpr_error", opno);
2202 l_bb_before_v(opblocks[opno + 1],
2203 "op.%d.jsonexpr_coercion", opno);
2205 l_bb_before_v(opblocks[opno + 1],
2206 "op.%d.jsonexpr_done", opno);
2208 v_switch = LLVMBuildSwitch(
b,
2215 v_jump_empty = l_int32_const(lc, jsestate->
jump_empty);
2216 LLVMAddCase(v_switch, v_jump_empty, b_empty);
2219 LLVMPositionBuilderAtEnd(
b, b_empty);
2223 LLVMBuildUnreachable(
b);
2228 v_jump_error = l_int32_const(lc, jsestate->
jump_error);
2229 LLVMAddCase(v_switch, v_jump_error, b_error);
2232 LLVMPositionBuilderAtEnd(
b, b_error);
2236 LLVMBuildUnreachable(
b);
2242 LLVMAddCase(v_switch, v_jump_coercion, b_coercion);
2245 LLVMPositionBuilderAtEnd(
b, b_coercion);
2249 LLVMBuildUnreachable(
b);
2251 LLVMPositionBuilderAtEnd(
b, b_done);
2254 LLVMBuildBr(
b, opblocks[jsestate->
jump_end]);
2260 v_state, op, v_econtext);
2262 LLVMBuildBr(
b, opblocks[opno + 1]);
2269 LLVMBuildBr(
b, opblocks[opno + 1]);
2274 LLVMValueRef v_aggno;
2278 v_aggno = l_int32_const(lc, op->
d.
aggref.aggno);
2285 LLVMBuildStore(
b,
value, v_resvaluep);
2286 LLVMBuildStore(
b, isnull, v_resnullp);
2288 LLVMBuildBr(
b, opblocks[opno + 1]);
2295 LLVMBuildBr(
b, opblocks[opno + 1]);
2301 LLVMValueRef v_wfuncnop;
2302 LLVMValueRef v_wfuncno;
2311 v_wfuncnop = l_ptr_const(&wfunc->
wfuncno,
2312 l_ptr(LLVMInt32TypeInContext(lc)));
2313 v_wfuncno = l_load(
b, LLVMInt32TypeInContext(lc), v_wfuncnop,
"v_wfuncno");
2321 LLVMBuildStore(
b,
value, v_resvaluep);
2322 LLVMBuildStore(
b, isnull, v_resnullp);
2324 LLVMBuildBr(
b, opblocks[opno + 1]);
2330 v_state, op, v_econtext);
2331 LLVMBuildBr(
b, opblocks[opno + 1]);
2336 v_state, op, v_econtext);
2337 LLVMBuildBr(
b, opblocks[opno + 1]);
2346 LLVMValueRef v_retval;
2347 LLVMValueRef v_fcinfo_isnull;
2348 LLVMValueRef v_tmpcontext;
2349 LLVMValueRef v_oldcontext;
2353 LLVMValueRef v_fcinfo;
2354 LLVMValueRef v_argnull0;
2355 LLVMBasicBlockRef b_deserialize;
2357 b_deserialize = l_bb_before_v(opblocks[opno + 1],
2358 "op.%d.deserialize", opno);
2360 v_fcinfo = l_ptr_const(fcinfo,
2362 v_argnull0 = l_funcnull(
b, v_fcinfo, 0);
2372 LLVMPositionBuilderAtEnd(
b, b_deserialize);
2381 v_oldcontext = l_mcxt_switch(mod,
b, v_tmpcontext);
2384 l_mcxt_switch(mod,
b, v_oldcontext);
2386 LLVMBuildStore(
b, v_retval, v_resvaluep);
2387 LLVMBuildStore(
b, v_fcinfo_isnull, v_resnullp);
2389 LLVMBuildBr(
b, opblocks[opno + 1]);
2401 LLVMValueRef v_argsp;
2402 LLVMValueRef v_nullsp;
2403 LLVMBasicBlockRef *b_checknulls;
2412 b_checknulls =
palloc(
sizeof(LLVMBasicBlockRef *) * nargs);
2413 for (
int argno = 0; argno < nargs; argno++)
2415 b_checknulls[argno] =
2416 l_bb_before_v(opblocks[opno + 1],
2417 "op.%d.check-null.%d",
2421 LLVMBuildBr(
b, b_checknulls[0]);
2424 for (
int argno = 0; argno < nargs; argno++)
2426 LLVMValueRef v_argno = l_int32_const(lc, argno);
2427 LLVMValueRef v_argisnull;
2428 LLVMBasicBlockRef b_argnotnull;
2430 LLVMPositionBuilderAtEnd(
b, b_checknulls[argno]);
2432 if (argno + 1 == nargs)
2433 b_argnotnull = opblocks[opno + 1];
2435 b_argnotnull = b_checknulls[argno + 1];
2441 LLVMValueRef v_argn;
2454 l_sbool_const(1),
""),
2465 LLVMValueRef v_aggstatep;
2466 LLVMValueRef v_allpergroupsp;
2467 LLVMValueRef v_pergroup_allaggs;
2468 LLVMValueRef v_setoff;
2476 v_aggstatep = LLVMBuildBitCast(
b, v_parent,
2479 v_allpergroupsp = l_load_struct_gep(
b,
2483 "aggstate.all_pergroups");
2488 v_allpergroupsp, v_setoff,
"");
2491 LLVMBuildICmp(
b, LLVMIntEQ,
2492 LLVMBuildPtrToInt(
b, v_pergroup_allaggs,
TypeSizeT,
""),
2493 l_sizet_const(0),
""),
2495 opblocks[opno + 1]);
2510 LLVMValueRef v_aggstatep;
2511 LLVMValueRef v_fcinfo;
2512 LLVMValueRef v_fcinfo_isnull;
2514 LLVMValueRef v_transvaluep;
2515 LLVMValueRef v_transnullp;
2517 LLVMValueRef v_setoff;
2518 LLVMValueRef v_transno;
2520 LLVMValueRef v_aggcontext;
2522 LLVMValueRef v_allpergroupsp;
2523 LLVMValueRef v_current_setp;
2524 LLVMValueRef v_current_pertransp;
2525 LLVMValueRef v_curaggcontext;
2527 LLVMValueRef v_pertransp;
2529 LLVMValueRef v_pergroupp;
2531 LLVMValueRef v_retval;
2533 LLVMValueRef v_tmpcontext;
2534 LLVMValueRef v_oldcontext;
2543 v_pertransp = l_ptr_const(pertrans,
2551 l_load_struct_gep(
b,
2555 "aggstate.all_pergroups");
2556 v_setoff = l_int32_const(lc, op->
d.
agg_trans.setoff);
2557 v_transno = l_int32_const(lc, op->
d.
agg_trans.transno);
2562 v_allpergroupsp, v_setoff,
""),
2569 LLVMValueRef v_notransvalue;
2570 LLVMBasicBlockRef b_init;
2571 LLVMBasicBlockRef b_no_init;
2574 l_load_struct_gep(
b,
2580 b_init = l_bb_before_v(opblocks[opno + 1],
2581 "op.%d.inittrans", opno);
2582 b_no_init = l_bb_before_v(opblocks[opno + 1],
2583 "op.%d.no_inittrans", opno);
2586 LLVMBuildICmp(
b, LLVMIntEQ, v_notransvalue,
2587 l_sbool_const(1),
""),
2593 LLVMValueRef params[4];
2595 LLVMPositionBuilderAtEnd(
b, b_init);
2597 v_aggcontext = l_ptr_const(op->
d.
agg_trans.aggcontext,
2600 params[0] = v_aggstatep;
2601 params[1] = v_pertransp;
2602 params[2] = v_pergroupp;
2603 params[3] = v_aggcontext;
2611 LLVMBuildBr(
b, opblocks[opno + 1]);
2614 LLVMPositionBuilderAtEnd(
b, b_no_init);
2622 LLVMValueRef v_transnull;
2623 LLVMBasicBlockRef b_strictpass;
2625 b_strictpass = l_bb_before_v(opblocks[opno + 1],
2626 "op.%d.strictpass", opno);
2628 l_load_struct_gep(
b,
2635 LLVMBuildICmp(
b, LLVMIntEQ, v_transnull,
2636 l_sbool_const(1),
""),
2640 LLVMPositionBuilderAtEnd(
b, b_strictpass);
2644 v_fcinfo = l_ptr_const(fcinfo,
2646 v_aggcontext = l_ptr_const(op->
d.
agg_trans.aggcontext,
2654 "aggstate.current_set");
2660 "aggstate.curaggcontext");
2661 v_current_pertransp =
2666 "aggstate.curpertrans");
2669 LLVMBuildStore(
b, v_aggcontext, v_curaggcontext);
2670 LLVMBuildStore(
b, l_int32_const(lc, op->
d.
agg_trans.setno),
2672 LLVMBuildStore(
b, v_pertransp, v_current_pertransp);
2678 v_oldcontext = l_mcxt_switch(mod,
b, v_tmpcontext);
2698 l_funcvaluep(
b, v_fcinfo, 0));
2701 l_funcnullp(
b, v_fcinfo, 0));
2720 LLVMBasicBlockRef b_call;
2721 LLVMBasicBlockRef b_nocall;
2723 LLVMValueRef v_transvalue;
2724 LLVMValueRef v_transnull;
2725 LLVMValueRef v_newval;
2726 LLVMValueRef params[6];
2728 b_call = l_bb_before_v(opblocks[opno + 1],
2729 "op.%d.transcall", opno);
2730 b_nocall = l_bb_before_v(opblocks[opno + 1],
2731 "op.%d.transnocall", opno);
2733 v_transvalue = l_load(
b,
TypeSizeT, v_transvaluep,
"");
2741 LLVMBuildICmp(
b, LLVMIntEQ,
2747 LLVMPositionBuilderAtEnd(
b, b_call);
2749 params[0] = v_aggstatep;
2750 params[1] = v_pertransp;
2751 params[2] = v_retval;
2752 params[3] = LLVMBuildTrunc(
b, v_fcinfo_isnull,
2754 params[4] = v_transvalue;
2755 params[5] = LLVMBuildTrunc(
b, v_transnull,
2767 LLVMBuildStore(
b, v_newval, v_transvaluep);
2768 LLVMBuildStore(
b, v_fcinfo_isnull, v_transnullp);
2770 l_mcxt_switch(mod,
b, v_oldcontext);
2771 LLVMBuildBr(
b, opblocks[opno + 1]);
2774 LLVMPositionBuilderAtEnd(
b, b_nocall);
2778 LLVMBuildStore(
b, v_retval, v_transvaluep);
2779 LLVMBuildStore(
b, v_fcinfo_isnull, v_transnullp);
2781 l_mcxt_switch(mod,
b, v_oldcontext);
2783 LLVMBuildBr(
b, opblocks[opno + 1]);
2793 LLVMValueRef v_fn =
llvm_pg_func(mod,
"ExecEvalPreOrderedDistinctSingle");
2794 LLVMValueRef v_args[2];
2804 LLVMBuildICmp(
b, LLVMIntEQ, v_ret,
2805 l_sbool_const(1),
""),
2807 opblocks[jumpdistinct]);
2817 LLVMValueRef v_fn =
llvm_pg_func(mod,
"ExecEvalPreOrderedDistinctMulti");
2818 LLVMValueRef v_args[2];
2828 LLVMBuildICmp(
b, LLVMIntEQ, v_ret,
2829 l_sbool_const(1),
""),
2831 opblocks[jumpdistinct]);
2837 v_state, op, v_econtext);
2838 LLVMBuildBr(
b, opblocks[opno + 1]);
2843 v_state, op, v_econtext);
2844 LLVMBuildBr(
b, opblocks[opno + 1]);
2853 LLVMDisposeBuilder(
b);
2869 state->evalfunc_private = cstate;
2876 endtime, starttime);
ExprEvalOp ExecEvalStepOp(ExprState *state, ExprEvalStep *op)
@ EEOP_FUNCEXPR_STRICT_FUSAGE
@ EEOP_HASHDATUM_NEXT32_STRICT
@ EEOP_JSONEXPR_COERCION_FINISH
@ EEOP_HASHDATUM_FIRST_STRICT
@ EEOP_AGG_PLAIN_PERGROUP_NULLCHECK
@ EEOP_AGG_STRICT_DESERIALIZE
@ EEOP_BOOLTEST_IS_NOT_FALSE
@ EEOP_AGG_PLAIN_TRANS_BYREF
@ EEOP_AGG_PRESORTED_DISTINCT_MULTI
@ EEOP_AGG_PLAIN_TRANS_BYVAL
@ EEOP_NULLTEST_ROWISNOTNULL
@ EEOP_ASSIGN_TMP_MAKE_RO
@ EEOP_BOOL_OR_STEP_FIRST
@ EEOP_AGG_STRICT_INPUT_CHECK_NULLS
@ EEOP_AGG_STRICT_INPUT_CHECK_ARGS
@ EEOP_NULLTEST_ROWISNULL
@ EEOP_NULLTEST_ISNOTNULL
@ EEOP_MERGE_SUPPORT_FUNC
@ EEOP_AGG_PRESORTED_DISTINCT_SINGLE
@ EEOP_BOOL_AND_STEP_FIRST
@ EEOP_BOOL_AND_STEP_LAST
@ EEOP_AGG_ORDERED_TRANS_DATUM
@ EEOP_HASHDATUM_SET_INITVAL
@ EEOP_AGG_PLAIN_TRANS_STRICT_BYREF
@ EEOP_BOOLTEST_IS_NOT_TRUE
@ EEOP_AGG_PLAIN_TRANS_INIT_STRICT_BYVAL
@ EEOP_AGG_PLAIN_TRANS_STRICT_BYVAL
@ EEOP_AGG_PLAIN_TRANS_INIT_STRICT_BYREF
@ EEOP_HASHED_SCALARARRAYOP
@ EEOP_AGG_ORDERED_TRANS_TUPLE
const TupleTableSlotOps TTSOpsVirtual
#define FIELDNO_EXPRSTATE_RESULTSLOT
#define FIELDNO_EXPRCONTEXT_CASENULL
#define FIELDNO_EXPRCONTEXT_INNERTUPLE
#define FIELDNO_EXPRCONTEXT_DOMAINNULL
#define FIELDNO_EXPRCONTEXT_DOMAINDATUM
#define FIELDNO_EXPRCONTEXT_CASEDATUM
#define FIELDNO_AGGSTATE_CURPERTRANS
#define FIELDNO_EXPRSTATE_RESNULL
#define FIELDNO_EXPRCONTEXT_AGGNULLS
#define FIELDNO_EXPRSTATE_RESVALUE
#define FIELDNO_AGGSTATE_CURRENT_SET
#define FIELDNO_EXPRCONTEXT_AGGVALUES
#define FIELDNO_EXPRCONTEXT_OUTERTUPLE
#define FIELDNO_AGGSTATE_ALL_PERGROUPS
#define FIELDNO_EXPRSTATE_PARENT
#define FIELDNO_EXPRCONTEXT_SCANTUPLE
#define FIELDNO_AGGSTATE_CURAGGCONTEXT
#define INSTR_TIME_SET_CURRENT(t)
#define INSTR_TIME_ACCUM_DIFF(x, y, z)
LLVMTypeRef StructExprState
LLVMTypeRef TypeParamBool
LLVMTypeRef StructMemoryContextData
LLVMTypeRef StructAggStatePerGroupData
LLVMTypeRef llvm_pg_var_type(const char *varname)
char * llvm_expand_funcname(struct LLVMJitContext *context, const char *basename)
LLVMTypeRef llvm_pg_var_func_type(const char *varname)
LLVMTypeRef StructTupleTableSlot
LLVMJitContext * llvm_create_context(int jitFlags)
LLVMModuleRef llvm_mutable_module(LLVMJitContext *context)
LLVMTypeRef StructAggState
LLVMTypeRef StructExprContext
LLVMTypeRef StructNullableDatum
LLVMValueRef ExecEvalSubroutineTemplate
LLVMValueRef ExecEvalBoolSubroutineTemplate
LLVMTypeRef StructAggStatePerTransData
void llvm_copy_attributes(LLVMValueRef v_from, LLVMValueRef v_to)
static Datum ExecRunCompiledExpr(ExprState *state, ExprContext *econtext, bool *isNull)
#define build_EvalXFunc(b, mod, funcname, v_state, op,...)
static LLVMValueRef BuildV1Call(LLVMJitContext *context, LLVMBuilderRef b, LLVMModuleRef mod, FunctionCallInfo fcinfo, LLVMValueRef *v_fcinfo_isnull)
void * palloc0(Size size)
#define FIELDNO_AGGSTATEPERGROUPDATA_TRANSVALUE
#define FIELDNO_AGGSTATEPERGROUPDATA_TRANSVALUEISNULL
#define FIELDNO_AGGSTATEPERGROUPDATA_NOTRANSVALUE
#define castNode(_type_, nodeptr)
#define FIELDNO_NULLABLE_DATUM_ISNULL
FunctionCallInfo transfn_fcinfo
struct JitContext * es_jit
MemoryContext ecxt_per_tuple_memory
struct ExprEvalStep::@55::@65 jump
struct ExprEvalStep::@55::@78 rowcompare_final
struct ExprEvalStep::@55::@86 hashdatum
struct ExprEvalStep::@55::@60 assign_tmp
struct ExprEvalStep::@55::@100 agg_trans
struct ExprEvalStep::@55::@57 var
struct ExprEvalStep::@55::@63 boolexpr
struct ExprEvalStep::@55::@98 agg_plain_pergroup_nullcheck
struct ExprEvalStep::@55::@92 aggref
struct ExprEvalStep::@55::@64 qualexpr
struct ExprEvalStep::@55::@82 sbsref_subscript
struct ExprEvalStep::@55::@62 func
struct ExprEvalStep::@55::@94 window_func
struct ExprEvalStep::@55::@77 rowcompare_step
struct ExprEvalStep::@55::@102 jsonexpr
struct ExprEvalStep::@55::@70 make_readonly
union ExprEvalStep::@55 d
struct ExprEvalStep::@55::@71 iocoerce
struct ExprEvalStep::@55::@68 cparam
struct ExprEvalStep::@55::@69 casetest
struct ExprEvalStep::@55::@83 sbsref
struct ExprEvalStep::@55::@97 agg_strict_input_check
struct ExprEvalStep::@55::@61 constval
struct ExprEvalStep::@55::@56 fetch
struct ExprEvalStep::@55::@85 hashdatum_initvalue
struct ExprEvalStep::@55::@59 assign_var
struct ExprEvalStep::@55::@99 agg_presorted_distinctcheck
struct ExprEvalStep::@55::@96 agg_deserialize
#define FIELDNO_TUPLETABLESLOT_ISNULL
#define FIELDNO_TUPLETABLESLOT_VALUES
#define FIELDNO_TUPLETABLESLOT_NVALID