Commit 31bc604e authored by Andres Freund's avatar Andres Freund

Add file containing extensions of the LLVM C API.

Author: Andres Freund
Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
parent 432bb9e0
...@@ -37,7 +37,7 @@ override COMPILER = $(CXX) $(CFLAGS) ...@@ -37,7 +37,7 @@ override COMPILER = $(CXX) $(CFLAGS)
OBJS=$(WIN32RES) OBJS=$(WIN32RES)
# Infrastructure # Infrastructure
OBJS += llvmjit.o llvmjit_error.o OBJS += llvmjit.o llvmjit_error.o llvmjit_wrap.o
# Code generation # Code generation
OBJS += OBJS +=
......
/*-------------------------------------------------------------------------
*
* llvmjit_wrap.cpp
* Parts of the LLVM interface not (yet) exposed to C.
*
* Copyright (c) 2016-2018, PostgreSQL Global Development Group
*
* IDENTIFICATION
* src/backend/lib/llvm/llvmjit_wrap.c
*
*-------------------------------------------------------------------------
*/
extern "C"
{
#include "postgres.h"
}
#include <llvm/MC/SubtargetFeature.h>
#include <llvm/Support/Host.h>
#include "jit/llvmjit.h"
/*
* C-API extensions.
*/
#if defined(HAVE_DECL_LLVMGETHOSTCPUNAME) && !HAVE_DECL_LLVMGETHOSTCPUNAME
char *LLVMGetHostCPUName(void) {
return strdup(llvm::sys::getHostCPUName().data());
}
#endif
char *LLVMGetHostCPUFeatures(void) {
llvm::SubtargetFeatures Features;
llvm::StringMap<bool> HostFeatures;
if (llvm::sys::getHostCPUFeatures(HostFeatures))
for (auto &F : HostFeatures)
Features.AddFeature(F.first(), F.second);
return strdup(Features.getString().c_str());
}
...@@ -44,6 +44,23 @@ extern void llvm_assert_in_fatal_section(void); ...@@ -44,6 +44,23 @@ extern void llvm_assert_in_fatal_section(void);
extern LLVMJitContext *llvm_create_context(int jitFlags); extern LLVMJitContext *llvm_create_context(int jitFlags);
/*
****************************************************************************
* Extensions / Backward compatibility section of the LLVM C API
* Error handling related functions.
****************************************************************************
*/
#if defined(HAVE_DECL_LLVMGETHOSTCPUNAME) && !HAVE_DECL_LLVMGETHOSTCPUNAME
/** Get the host CPU as a string. The result needs to be disposed with
LLVMDisposeMessage. */
extern char *LLVMGetHostCPUName(void);
#endif
/** Get the host CPU features as a string. The result needs to be disposed
with LLVMDisposeMessage. */
extern char *LLVMGetHostCPUFeatures(void);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment