gooderp18绿色标准版
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

147 lines
4.4KB

  1. /*-------------------------------------------------------------------------
  2. * llvmjit.h
  3. * LLVM JIT provider.
  4. *
  5. * Copyright (c) 2016-2019, PostgreSQL Global Development Group
  6. *
  7. * src/include/jit/llvmjit.h
  8. *
  9. *-------------------------------------------------------------------------
  10. */
  11. #ifndef LLVMJIT_H
  12. #define LLVMJIT_H
  13. /*
  14. * To avoid breaking cpluspluscheck, allow including the file even when LLVM
  15. * is not available.
  16. */
  17. #ifdef USE_LLVM
  18. #include <llvm-c/Types.h>
  19. /*
  20. * File needs to be includable by both C and C++ code, and include other
  21. * headers doing the same. Therefore wrap C portion in our own extern "C" if
  22. * in C++ mode.
  23. */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. #include "fmgr.h"
  29. #include "jit/jit.h"
  30. #include "nodes/pg_list.h"
  31. #include "access/tupdesc.h"
  32. typedef struct LLVMJitContext
  33. {
  34. JitContext base;
  35. /* number of modules created */
  36. size_t module_generation;
  37. /* current, "open for write", module */
  38. LLVMModuleRef module;
  39. /* is there any pending code that needs to be emitted */
  40. bool compiled;
  41. /* # of objects emitted, used to generate non-conflicting names */
  42. int counter;
  43. /* list of handles for code emitted via Orc */
  44. List *handles;
  45. } LLVMJitContext;
  46. /* type and struct definitions */
  47. extern LLVMTypeRef TypeParamBool;
  48. extern LLVMTypeRef TypePGFunction;
  49. extern LLVMTypeRef TypeSizeT;
  50. extern LLVMTypeRef TypeStorageBool;
  51. extern LLVMTypeRef StructNullableDatum;
  52. extern LLVMTypeRef StructTupleDescData;
  53. extern LLVMTypeRef StructHeapTupleData;
  54. extern LLVMTypeRef StructTupleTableSlot;
  55. extern LLVMTypeRef StructHeapTupleTableSlot;
  56. extern LLVMTypeRef StructMinimalTupleTableSlot;
  57. extern LLVMTypeRef StructMemoryContextData;
  58. extern LLVMTypeRef StructFunctionCallInfoData;
  59. extern LLVMTypeRef StructExprContext;
  60. extern LLVMTypeRef StructExprEvalStep;
  61. extern LLVMTypeRef StructExprState;
  62. extern LLVMTypeRef StructAggState;
  63. extern LLVMTypeRef StructAggStatePerTransData;
  64. extern LLVMTypeRef StructAggStatePerGroupData;
  65. extern LLVMValueRef AttributeTemplate;
  66. extern LLVMValueRef FuncStrlen;
  67. extern LLVMValueRef FuncVarsizeAny;
  68. extern LLVMValueRef FuncSlotGetmissingattrs;
  69. extern LLVMValueRef FuncSlotGetsomeattrsInt;
  70. extern LLVMValueRef FuncMakeExpandedObjectReadOnlyInternal;
  71. extern LLVMValueRef FuncExecEvalSubscriptingRef;
  72. extern LLVMValueRef FuncExecEvalSysVar;
  73. extern LLVMValueRef FuncExecAggTransReparent;
  74. extern LLVMValueRef FuncExecAggInitGroup;
  75. extern void llvm_enter_fatal_on_oom(void);
  76. extern void llvm_leave_fatal_on_oom(void);
  77. extern void llvm_reset_after_error(void);
  78. extern void llvm_assert_in_fatal_section(void);
  79. extern LLVMJitContext *llvm_create_context(int jitFlags);
  80. extern LLVMModuleRef llvm_mutable_module(LLVMJitContext *context);
  81. extern char *llvm_expand_funcname(LLVMJitContext *context, const char *basename);
  82. extern void *llvm_get_function(LLVMJitContext *context, const char *funcname);
  83. extern void llvm_split_symbol_name(const char *name, char **modname, char **funcname);
  84. extern LLVMValueRef llvm_get_decl(LLVMModuleRef mod, LLVMValueRef f);
  85. extern void llvm_copy_attributes(LLVMValueRef from, LLVMValueRef to);
  86. extern LLVMValueRef llvm_function_reference(LLVMJitContext *context,
  87. LLVMBuilderRef builder,
  88. LLVMModuleRef mod,
  89. FunctionCallInfo fcinfo);
  90. extern void llvm_inline(LLVMModuleRef mod);
  91. /*
  92. ****************************************************************************
  93. * Code generation functions.
  94. ****************************************************************************
  95. */
  96. extern bool llvm_compile_expr(struct ExprState *state);
  97. struct TupleTableSlotOps;
  98. extern LLVMValueRef slot_compile_deform(struct LLVMJitContext *context, TupleDesc desc,
  99. const struct TupleTableSlotOps *ops, int natts);
  100. /*
  101. ****************************************************************************
  102. * Extensions / Backward compatibility section of the LLVM C API
  103. * Error handling related functions.
  104. ****************************************************************************
  105. */
  106. #if defined(HAVE_DECL_LLVMGETHOSTCPUNAME) && !HAVE_DECL_LLVMGETHOSTCPUNAME
  107. /** Get the host CPU as a string. The result needs to be disposed with
  108. LLVMDisposeMessage. */
  109. extern char *LLVMGetHostCPUName(void);
  110. #endif
  111. #if defined(HAVE_DECL_LLVMGETHOSTCPUFEATURES) && !HAVE_DECL_LLVMGETHOSTCPUFEATURES
  112. /** Get the host CPU features as a string. The result needs to be disposed
  113. with LLVMDisposeMessage. */
  114. extern char *LLVMGetHostCPUFeatures(void);
  115. #endif
  116. #ifdef __cplusplus
  117. } /* extern "C" */
  118. #endif
  119. #endif /* USE_LLVM */
  120. #endif /* LLVMJIT_H */
上海开阖软件有限公司 沪ICP备12045867号-1