Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit31bc604

Browse files
committed
Add file containing extensions of the LLVM C API.
Author: Andres FreundDiscussion:https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
1 parent432bb9e commit31bc604

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

‎src/backend/jit/llvm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ override COMPILER = $(CXX) $(CFLAGS)
3737
OBJS=$(WIN32RES)
3838

3939
# Infrastructure
40-
OBJS += llvmjit.o llvmjit_error.o
40+
OBJS += llvmjit.o llvmjit_error.o llvmjit_wrap.o
4141
# Code generation
4242
OBJS +=
4343

‎src/backend/jit/llvm/llvmjit_wrap.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
returnstrdup(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+
returnstrdup(Features.getString().c_str());
44+
}

‎src/include/jit/llvmjit.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ extern void llvm_assert_in_fatal_section(void);
4444

4545
externLLVMJitContext*llvm_create_context(intjitFlags);
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+
externchar*LLVMGetHostCPUName(void);
58+
#endif
59+
60+
/** Get the host CPU features as a string. The result needs to be disposed
61+
with LLVMDisposeMessage. */
62+
externchar*LLVMGetHostCPUFeatures(void);
63+
4764
#ifdef__cplusplus
4865
}/* extern "C" */
4966
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp