1/*-------------------------------------------------------------------------
2 *
3 * llvmjit_wrap.cpp
4 * Parts of the LLVM interface not (yet) exposed to C.
5 *
6 * Copyright (c) 2016-2019, PostgreSQL Global Development Group
7 *
8 * IDENTIFICATION
9 * src/backend/lib/llvm/llvmjit_wrap.cpp
10 *
11 *-------------------------------------------------------------------------
12 */
13
14extern "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
29char *LLVMGetHostCPUName(void) {
30 return strdup(llvm::sys::getHostCPUName().data());
31}
32#endif
33
34
35#if defined(HAVE_DECL_LLVMGETHOSTCPUFEATURES) && !HAVE_DECL_LLVMGETHOSTCPUFEATURES
36char *LLVMGetHostCPUFeatures(void) {
37 llvm::SubtargetFeatures Features;
38 llvm::StringMap<bool> HostFeatures;
39
40 if (llvm::sys::getHostCPUFeatures(HostFeatures))
41 for (auto &F : HostFeatures)
42 Features.AddFeature(F.first(), F.second);
43
44 return strdup(Features.getString().c_str());
45}
46#endif
47