2018-03-22 03:44:17 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* llvmjit_wrap.cpp
|
|
|
|
* Parts of the LLVM interface not (yet) exposed to C.
|
|
|
|
*
|
2019-01-02 18:44:25 +01:00
|
|
|
* Copyright (c) 2016-2019, PostgreSQL Global Development Group
|
2018-03-22 03:44:17 +01:00
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2019-01-22 20:46:59 +01:00
|
|
|
* src/backend/lib/llvm/llvmjit_wrap.cpp
|
2018-03-22 03:44:17 +01:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2018-08-24 19:20:55 +02:00
|
|
|
#if defined(HAVE_DECL_LLVMGETHOSTCPUFEATURES) && !HAVE_DECL_LLVMGETHOSTCPUFEATURES
|
2018-03-22 03:44:17 +01:00
|
|
|
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());
|
|
|
|
}
|
2018-08-24 19:20:55 +02:00
|
|
|
#endif
|