mirror of https://github.com/postgres/postgres
Author: Andres Freund Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.depull/31/merge
parent
432bb9e04d
commit
31bc604e0b
@ -0,0 +1,44 @@ |
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* |
||||||
|
* 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()); |
||||||
|
} |
Loading…
Reference in new issue