File tree Expand file tree Collapse file tree 3 files changed +62
-1
lines changed Expand file tree Collapse file tree 3 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ override COMPILER = $(CXX) $(CFLAGS)
3737OBJS =$(WIN32RES )
3838
3939# Infrastructure
40- OBJS += llvmjit.o llvmjit_error.o
40+ OBJS += llvmjit.o llvmjit_error.o llvmjit_wrap.o
4141# Code generation
4242OBJS +=
4343
Original file line number Diff line number Diff line change 1+ /* -------------------------------------------------------------------------
2+ *
3+ * llvmjit_wrap.cpp
4+ * Parts of the LLVM interface not (yet) exposed to C.
5+ *
6+ * Copyright (c) 2016-2018, PostgreSQL Global Development Group
7+ *
8+ * IDENTIFICATION
9+ * src/backend/lib/llvm/llvmjit_wrap.c
10+ *
11+ *-------------------------------------------------------------------------
12+ */
13+
14+ extern " C"
15+ {
16+ #include " postgres.h"
17+ }
18+
19+ #include < llvm/MC/SubtargetFeature.h>
20+ #include < llvm/Support/Host.h>
21+
22+ #include " jit/llvmjit.h"
23+
24+
25+ /*
26+ * C-API extensions.
27+ */
28+ #if defined(HAVE_DECL_LLVMGETHOSTCPUNAME) && !HAVE_DECL_LLVMGETHOSTCPUNAME
29+ char *LLVMGetHostCPUName (void ) {
30+ return strdup (llvm::sys::getHostCPUName ().data ());
31+ }
32+ #endif
33+
34+
35+ char *LLVMGetHostCPUFeatures (void ) {
36+ llvm::SubtargetFeatures Features;
37+ llvm::StringMap<bool > HostFeatures;
38+
39+ if (llvm::sys::getHostCPUFeatures (HostFeatures))
40+ for (auto &F : HostFeatures)
41+ Features.AddFeature (F.first (), F.second );
42+
43+ return strdup (Features.getString ().c_str ());
44+ }
Original file line number Diff line number Diff line change @@ -44,6 +44,23 @@ extern void llvm_assert_in_fatal_section(void);
4444
4545extern LLVMJitContext * llvm_create_context (int jitFlags );
4646
47+
48+ /*
49+ ****************************************************************************
50+ * Extensions / Backward compatibility section of the LLVM C API
51+ * Error handling related functions.
52+ ****************************************************************************
53+ */
54+ #if defined(HAVE_DECL_LLVMGETHOSTCPUNAME ) && !HAVE_DECL_LLVMGETHOSTCPUNAME
55+ /** Get the host CPU as a string. The result needs to be disposed with
56+ LLVMDisposeMessage. */
57+ extern char * LLVMGetHostCPUName (void );
58+ #endif
59+
60+ /** Get the host CPU features as a string. The result needs to be disposed
61+ with LLVMDisposeMessage. */
62+ extern char * LLVMGetHostCPUFeatures (void );
63+
4764#ifdef __cplusplus
4865} /* extern "C" */
4966#endif
You can’t perform that action at this time.
0 commit comments