llvmlite 0.10.0__tar.gz → 0.12.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of llvmlite might be problematic. Click here for more details.
- {llvmlite-0.10.0 → llvmlite-0.12.0}/PKG-INFO +1 -1
- {llvmlite-0.10.0 → llvmlite-0.12.0}/README.rst +2 -1
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/Makefile.freebsd +2 -1
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/Makefile.linux +2 -1
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/Makefile.osx +2 -1
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/build.py +12 -1
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/initfini.cpp +4 -3
- llvmlite-0.12.0/ffi/passmanagers.cpp +153 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/targets.cpp +5 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/_version.py +2 -2
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/initfini.py +18 -0
- llvmlite-0.12.0/llvmlite/binding/passmanagers.py +170 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/targets.py +10 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/ir/_utils.py +20 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/ir/builder.py +4 -4
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/ir/instructions.py +29 -34
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/ir/values.py +24 -3
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/tests/test_binding.py +93 -2
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/tests/test_ir.py +20 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/setup.py +4 -1
- llvmlite-0.10.0/ffi/passmanagers.cpp +0 -51
- llvmlite-0.10.0/llvmlite/binding/passmanagers.py +0 -87
- {llvmlite-0.10.0 → llvmlite-0.12.0}/LICENSE +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/examples/floatrep.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/examples/ir_fpadd.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/examples/ll_fpadd.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/examples/llvmir.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/examples/parseasm.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/examples/sum.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/examples/test.ll +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/CMakeLists.txt +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/assembly.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/bitcode.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/build/CMakeFiles/3.0.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/build/CMakeFiles/TargetDirectories.txt +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/core.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/core.h +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/dummy/CMakeLists.txt +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/dummy/build/CMakeFiles/3.0.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/dummy/build/CMakeFiles/TargetDirectories.txt +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/dylib.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/executionengine.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/linker.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/module.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/transforms.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/ffi/value.cpp +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/__init__.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/__init__.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/common.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/dylib.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/executionengine.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/ffi.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/linker.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/module.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/options.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/transforms.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/binding/value.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/ir/__init__.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/ir/context.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/ir/module.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/ir/transforms.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/ir/types.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/llvmpy/__init__.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/llvmpy/core.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/llvmpy/passes.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/six.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/tests/__init__.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/tests/__main__.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/tests/customize.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/tests/test_valuerepr.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/llvmlite/utils.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/run_coverage.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/runtests.py +0 -0
- {llvmlite-0.10.0 → llvmlite-0.12.0}/versioneer.py +0 -0
|
@@ -50,7 +50,8 @@ Compatibility
|
|
|
50
50
|
|
|
51
51
|
llvmlite works with Python 2.7 and Python 3.4 or greater.
|
|
52
52
|
|
|
53
|
-
As of version 0.
|
|
53
|
+
As of version 0.10, llvmlite requires LLVM 3.7. It does not support earlier
|
|
54
|
+
or later versions of LLVM.
|
|
54
55
|
|
|
55
56
|
Documentation
|
|
56
57
|
=============
|
|
@@ -3,6 +3,7 @@ CXX = clang++ -std=c++11 -stdlib=libc++
|
|
|
3
3
|
CXXFLAGS = $(LLVM_CXXFLAGS)
|
|
4
4
|
LDFLAGS = $(LLVM_LDFLAGS)
|
|
5
5
|
LIBS = $(LLVM_LIBS)
|
|
6
|
+
INCLUDE = core.h
|
|
6
7
|
SRC = assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp \
|
|
7
8
|
executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp \
|
|
8
9
|
linker.cpp
|
|
@@ -10,7 +11,7 @@ OUTPUT = libllvmlite.so
|
|
|
10
11
|
|
|
11
12
|
all: $(OUTPUT)
|
|
12
13
|
|
|
13
|
-
$(OUTPUT): $(SRC)
|
|
14
|
+
$(OUTPUT): $(SRC) $(INCLUDE)
|
|
14
15
|
$(CXX) -shared $(CXXFLAGS) $(SRC) -o $(OUTPUT) $(LDFLAGS) $(LIBS)
|
|
15
16
|
|
|
16
17
|
clean:
|
|
@@ -8,6 +8,7 @@ LD_FLTO_FLAGS ?= -flto -Wl,--exclude-libs=ALL
|
|
|
8
8
|
CXXFLAGS = $(LLVM_CXXFLAGS) $(CXX_FLTO_FLAGS)
|
|
9
9
|
LDFLAGS = $(LLVM_LDFLAGS) $(LD_FLTO_FLAGS)
|
|
10
10
|
LIBS = $(LLVM_LIBS)
|
|
11
|
+
INCLUDE = core.h
|
|
11
12
|
SRC = assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp \
|
|
12
13
|
executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp \
|
|
13
14
|
linker.cpp
|
|
@@ -15,7 +16,7 @@ OUTPUT = libllvmlite.so
|
|
|
15
16
|
|
|
16
17
|
all: $(OUTPUT)
|
|
17
18
|
|
|
18
|
-
$(OUTPUT): $(SRC)
|
|
19
|
+
$(OUTPUT): $(SRC) $(INCLUDE)
|
|
19
20
|
# static-libstdc++ avoids runtime dependencies on a
|
|
20
21
|
# particular libstdc++ version.
|
|
21
22
|
$(CXX) -static-libstdc++ -shared $(CXXFLAGS) $(SRC) -o $(OUTPUT) $(LDFLAGS) $(LIBS)
|
|
@@ -3,12 +3,13 @@ CXX = clang++ -std=c++11 -stdlib=libc++
|
|
|
3
3
|
CXXFLAGS = $(LLVM_CXXFLAGS)
|
|
4
4
|
LDFLAGS = $(LLVM_LDFLAGS)
|
|
5
5
|
LIBS = $(LLVM_LIBS)
|
|
6
|
+
INCLUDE = core.h
|
|
6
7
|
SRC = assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp \
|
|
7
8
|
executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp \
|
|
8
9
|
linker.cpp
|
|
9
10
|
OUTPUT = libllvmlite.dylib
|
|
10
11
|
|
|
11
|
-
all: $(SRC)
|
|
12
|
+
all: $(SRC) $(INCLUDE)
|
|
12
13
|
MACOSX_DEPLOYMENT_TARGET=10.7 $(CXX) -dynamiclib $(CXXFLAGS) $(SRC) -o $(OUTPUT) $(LDFLAGS) $(LIBS)
|
|
13
14
|
|
|
14
15
|
clean:
|
|
@@ -102,11 +102,22 @@ def main_posix(kind, library_ext):
|
|
|
102
102
|
print("LLVM version... ", end='')
|
|
103
103
|
sys.stdout.flush()
|
|
104
104
|
try:
|
|
105
|
-
subprocess.
|
|
105
|
+
out = subprocess.check_output([llvm_config, '--version'])
|
|
106
106
|
except (OSError, subprocess.CalledProcessError):
|
|
107
107
|
raise RuntimeError("%s failed executing, please point LLVM_CONFIG "
|
|
108
108
|
"to the path for llvm-config" % (llvm_config,))
|
|
109
109
|
|
|
110
|
+
out = out.decode('latin1')
|
|
111
|
+
print(out)
|
|
112
|
+
if not out.startswith('3.7.'):
|
|
113
|
+
msg = (
|
|
114
|
+
"Building llvmlite requires LLVM 3.7.x. Be sure to "
|
|
115
|
+
"set LLVM_CONFIG to the right executable path.\n"
|
|
116
|
+
"Read the documentation at http://llvmlite.pydata.org/ for more "
|
|
117
|
+
"information about building llvmlite.\n"
|
|
118
|
+
)
|
|
119
|
+
raise RuntimeError(msg)
|
|
120
|
+
|
|
110
121
|
# Get LLVM information for building
|
|
111
122
|
libs = run_llvm_config(llvm_config, "--system-libs --libs all".split())
|
|
112
123
|
# Normalize whitespace (trim newlines)
|
|
@@ -38,9 +38,10 @@ LLVMPY_Shutdown(){
|
|
|
38
38
|
// NOTE: it is important that we don't export functions which we don't use,
|
|
39
39
|
// especially those which may pull in large amounts of additional code or data.
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
INIT(AllTargetInfos)
|
|
42
|
+
INIT(AllTargets)
|
|
43
|
+
INIT(AllTargetMCs)
|
|
44
|
+
INIT(AllAsmPrinters)
|
|
44
45
|
INIT(NativeTarget)
|
|
45
46
|
INIT(NativeAsmParser)
|
|
46
47
|
INIT(NativeAsmPrinter)
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#include "core.h"
|
|
2
|
+
#include "llvm-c/Transforms/Scalar.h"
|
|
3
|
+
#include "llvm-c/Transforms/IPO.h"
|
|
4
|
+
#include "llvm/IR/LegacyPassManager.h"
|
|
5
|
+
#include "llvm/Transforms/Scalar.h"
|
|
6
|
+
#include "llvm/Transforms/IPO.h"
|
|
7
|
+
|
|
8
|
+
using namespace llvm;
|
|
9
|
+
|
|
10
|
+
extern "C" {
|
|
11
|
+
|
|
12
|
+
API_EXPORT(LLVMPassManagerRef)
|
|
13
|
+
LLVMPY_CreatePassManager()
|
|
14
|
+
{
|
|
15
|
+
return LLVMCreatePassManager();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
API_EXPORT(void)
|
|
19
|
+
LLVMPY_DisposePassManager(LLVMPassManagerRef PM)
|
|
20
|
+
{
|
|
21
|
+
return LLVMDisposePassManager(PM);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
API_EXPORT(LLVMPassManagerRef)
|
|
26
|
+
LLVMPY_CreateFunctionPassManager(LLVMModuleRef M)
|
|
27
|
+
{
|
|
28
|
+
return LLVMCreateFunctionPassManagerForModule(M);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
API_EXPORT(int)
|
|
32
|
+
LLVMPY_RunPassManager(LLVMPassManagerRef PM,
|
|
33
|
+
LLVMModuleRef M)
|
|
34
|
+
{
|
|
35
|
+
return LLVMRunPassManager(PM, M);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
API_EXPORT(int)
|
|
39
|
+
LLVMPY_RunFunctionPassManager(LLVMPassManagerRef PM,
|
|
40
|
+
LLVMValueRef F)
|
|
41
|
+
{
|
|
42
|
+
return LLVMRunFunctionPassManager(PM, F);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
API_EXPORT(int)
|
|
46
|
+
LLVMPY_InitializeFunctionPassManager(LLVMPassManagerRef FPM)
|
|
47
|
+
{
|
|
48
|
+
return LLVMInitializeFunctionPassManager(FPM);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
API_EXPORT(int)
|
|
52
|
+
LLVMPY_FinalizeFunctionPassManager(LLVMPassManagerRef FPM)
|
|
53
|
+
{
|
|
54
|
+
return LLVMFinalizeFunctionPassManager(FPM);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
API_EXPORT(void)
|
|
58
|
+
LLVMPY_AddConstantMergePass(LLVMPassManagerRef PM)
|
|
59
|
+
{
|
|
60
|
+
LLVMAddConstantMergePass(PM);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
API_EXPORT(void)
|
|
64
|
+
LLVMPY_AddDeadArgEliminationPass(LLVMPassManagerRef PM)
|
|
65
|
+
{
|
|
66
|
+
LLVMAddDeadArgEliminationPass(PM);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
API_EXPORT(void)
|
|
70
|
+
LLVMPY_AddFunctionAttrsPass(LLVMPassManagerRef PM)
|
|
71
|
+
{
|
|
72
|
+
LLVMAddFunctionAttrsPass(PM);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
API_EXPORT(void)
|
|
76
|
+
LLVMPY_AddFunctionInliningPass(LLVMPassManagerRef PM, int Threshold)
|
|
77
|
+
{
|
|
78
|
+
unwrap(PM)->add(createFunctionInliningPass(Threshold));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
API_EXPORT(void)
|
|
82
|
+
LLVMPY_AddGlobalOptimizerPass(LLVMPassManagerRef PM)
|
|
83
|
+
{
|
|
84
|
+
LLVMAddGlobalOptimizerPass(PM);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
API_EXPORT(void)
|
|
88
|
+
LLVMPY_AddGlobalDCEPass(LLVMPassManagerRef PM)
|
|
89
|
+
{
|
|
90
|
+
LLVMAddGlobalDCEPass(PM);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
API_EXPORT(void)
|
|
94
|
+
LLVMPY_AddIPSCCPPass(LLVMPassManagerRef PM)
|
|
95
|
+
{
|
|
96
|
+
LLVMAddIPSCCPPass(PM);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
API_EXPORT(void)
|
|
100
|
+
LLVMPY_AddDeadCodeEliminationPass(LLVMPassManagerRef PM)
|
|
101
|
+
{
|
|
102
|
+
unwrap(PM)->add(createDeadCodeEliminationPass());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
API_EXPORT(void)
|
|
106
|
+
LLVMPY_AddCFGSimplificationPass(LLVMPassManagerRef PM)
|
|
107
|
+
{
|
|
108
|
+
LLVMAddCFGSimplificationPass(PM);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
API_EXPORT(void)
|
|
112
|
+
LLVMPY_AddGVNPass(LLVMPassManagerRef PM)
|
|
113
|
+
{
|
|
114
|
+
LLVMAddGVNPass(PM);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
API_EXPORT(void)
|
|
118
|
+
LLVMPY_AddInstructionCombiningPass(LLVMPassManagerRef PM)
|
|
119
|
+
{
|
|
120
|
+
LLVMAddInstructionCombiningPass(PM);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
API_EXPORT(void)
|
|
124
|
+
LLVMPY_AddLICMPass(LLVMPassManagerRef PM)
|
|
125
|
+
{
|
|
126
|
+
LLVMAddLICMPass(PM);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
API_EXPORT(void)
|
|
130
|
+
LLVMPY_AddSCCPPass(LLVMPassManagerRef PM)
|
|
131
|
+
{
|
|
132
|
+
LLVMAddSCCPPass(PM);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
API_EXPORT(void)
|
|
136
|
+
LLVMPY_AddSROAPass(LLVMPassManagerRef PM)
|
|
137
|
+
{
|
|
138
|
+
unwrap(PM)->add(createSROAPass());
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
API_EXPORT(void)
|
|
142
|
+
LLVMPY_AddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM)
|
|
143
|
+
{
|
|
144
|
+
LLVMAddTypeBasedAliasAnalysisPass(PM);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
API_EXPORT(void)
|
|
148
|
+
LLVMPY_AddBasicAliasAnalysisPass(LLVMPassManagerRef PM)
|
|
149
|
+
{
|
|
150
|
+
LLVMAddBasicAliasAnalysisPass(PM);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
} // end extern "C"
|
|
@@ -245,6 +245,11 @@ LLVMPY_GetTargetMachineTriple(LLVMTargetMachineRef TM, const char **Out)
|
|
|
245
245
|
*Out = LLVMGetTargetMachineTriple(TM);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
API_EXPORT(void)
|
|
249
|
+
LLVMPY_SetTargetMachineAsmVerbosity(LLVMTargetMachineRef TM, int verbose)
|
|
250
|
+
{
|
|
251
|
+
LLVMSetTargetMachineAsmVerbosity(TM, verbose);
|
|
252
|
+
}
|
|
248
253
|
|
|
249
254
|
API_EXPORT(LLVMMemoryBufferRef)
|
|
250
255
|
LLVMPY_TargetMachineEmitToMemory (
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
|
5
5
|
# of this file.
|
|
6
6
|
|
|
7
|
-
version_version = '0.
|
|
8
|
-
version_full = '
|
|
7
|
+
version_version = '0.12.0'
|
|
8
|
+
version_full = '960b89612ab2bb1fc1f0041dfdc60d77fb540eaf'
|
|
9
9
|
def get_versions(default={}, verbose=False):
|
|
10
10
|
return {'version': version_version, 'full': version_full}
|
|
11
11
|
|
|
@@ -10,6 +10,24 @@ def initialize():
|
|
|
10
10
|
ffi.lib.LLVMPY_InitializeCore()
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
def initialize_all_targets():
|
|
14
|
+
"""
|
|
15
|
+
Initialize all targets. Necessary before targets can be looked up
|
|
16
|
+
via the :class:`Target` class.
|
|
17
|
+
"""
|
|
18
|
+
ffi.lib.LLVMPY_InitializeAllTargetInfos()
|
|
19
|
+
ffi.lib.LLVMPY_InitializeAllTargets()
|
|
20
|
+
ffi.lib.LLVMPY_InitializeAllTargetMCs()
|
|
21
|
+
|
|
22
|
+
def initialize_all_asmprinters():
|
|
23
|
+
"""
|
|
24
|
+
Initialize all code generators. Necessary before generating
|
|
25
|
+
any assembly or machine code via the :meth:`TargetMachine.emit_object`
|
|
26
|
+
and :meth:`TargetMachine.emit_assembly` methods.
|
|
27
|
+
"""
|
|
28
|
+
ffi.lib.LLVMPY_InitializeAllAsmPrinters()
|
|
29
|
+
|
|
30
|
+
|
|
13
31
|
def initialize_native_target():
|
|
14
32
|
"""
|
|
15
33
|
Initialize the native (host) target. Necessary before doing any
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
from __future__ import print_function, absolute_import
|
|
2
|
+
from ctypes import c_bool, c_int
|
|
3
|
+
from . import ffi
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def create_module_pass_manager():
|
|
7
|
+
return ModulePassManager()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def create_function_pass_manager(module):
|
|
11
|
+
return FunctionPassManager(module)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PassManager(ffi.ObjectRef):
|
|
15
|
+
"""PassManager
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def _dispose(self):
|
|
19
|
+
self._capi.LLVMPY_DisposePassManager(self)
|
|
20
|
+
|
|
21
|
+
def add_constant_merge_pass(self):
|
|
22
|
+
"""See http://llvm.org/docs/Passes.html#constmerge-merge-duplicate-global-constants."""
|
|
23
|
+
ffi.lib.LLVMPY_AddConstantMergePass(self)
|
|
24
|
+
|
|
25
|
+
def add_dead_arg_elimination_pass(self):
|
|
26
|
+
"""See http://llvm.org/docs/Passes.html#deadargelim-dead-argument-elimination."""
|
|
27
|
+
ffi.lib.LLVMPY_AddDeadArgEliminationPass(self)
|
|
28
|
+
|
|
29
|
+
def add_function_attrs_pass(self):
|
|
30
|
+
"""See http://llvm.org/docs/Passes.html#functionattrs-deduce-function-attributes."""
|
|
31
|
+
ffi.lib.LLVMPY_AddFunctionAttrsPass(self)
|
|
32
|
+
|
|
33
|
+
def add_function_inlining_pass(self, threshold):
|
|
34
|
+
"""See http://llvm.org/docs/Passes.html#inline-function-integration-inlining."""
|
|
35
|
+
ffi.lib.LLVMPY_AddFunctionInliningPass(self, threshold)
|
|
36
|
+
|
|
37
|
+
def add_global_dce_pass(self):
|
|
38
|
+
"""See http://llvm.org/docs/Passes.html#globaldce-dead-global-elimination."""
|
|
39
|
+
ffi.lib.LLVMPY_AddGlobalDCEPass(self)
|
|
40
|
+
|
|
41
|
+
def add_global_optimizer_pass(self):
|
|
42
|
+
"""See http://llvm.org/docs/Passes.html#globalopt-global-variable-optimizer."""
|
|
43
|
+
ffi.lib.LLVMPY_AddGlobalOptimizerPass(self)
|
|
44
|
+
|
|
45
|
+
def add_ipsccp_pass(self):
|
|
46
|
+
"""See http://llvm.org/docs/Passes.html#ipsccp-interprocedural-sparse-conditional-constant-propagation."""
|
|
47
|
+
ffi.lib.LLVMPY_AddIPSCCPPass(self)
|
|
48
|
+
|
|
49
|
+
def add_dead_code_elimination_pass(self):
|
|
50
|
+
"""See http://llvm.org/docs/Passes.html#dce-dead-code-elimination."""
|
|
51
|
+
ffi.lib.LLVMPY_AddDeadCodeEliminationPass(self)
|
|
52
|
+
|
|
53
|
+
def add_cfg_simplification_pass(self):
|
|
54
|
+
"""See http://llvm.org/docs/Passes.html#simplifycfg-simplify-the-cfg."""
|
|
55
|
+
ffi.lib.LLVMPY_AddCFGSimplificationPass(self)
|
|
56
|
+
|
|
57
|
+
def add_gvn_pass(self):
|
|
58
|
+
"""See http://llvm.org/docs/Passes.html#gvn-global-value-numbering."""
|
|
59
|
+
ffi.lib.LLVMPY_AddGVNPass(self)
|
|
60
|
+
|
|
61
|
+
def add_instruction_combining_pass(self):
|
|
62
|
+
"""See http://llvm.org/docs/Passes.html#passes-instcombine."""
|
|
63
|
+
ffi.lib.LLVMPY_AddInstructionCombiningPass(self)
|
|
64
|
+
|
|
65
|
+
def add_licm_pass(self):
|
|
66
|
+
"""See http://llvm.org/docs/Passes.html#licm-loop-invariant-code-motion."""
|
|
67
|
+
ffi.lib.LLVMPY_AddLICMPass(self)
|
|
68
|
+
|
|
69
|
+
def add_sccp_pass(self):
|
|
70
|
+
"""See http://llvm.org/docs/Passes.html#sccp-sparse-conditional-constant-propagation."""
|
|
71
|
+
ffi.lib.LLVMPY_AddSCCPPass(self)
|
|
72
|
+
|
|
73
|
+
def add_sroa_pass(self):
|
|
74
|
+
"""See http://llvm.org/docs/Passes.html#scalarrepl-scalar-replacement-of-aggregates-dt.
|
|
75
|
+
Note that this pass corresponds to the ``opt -sroa`` command-line option,
|
|
76
|
+
despite the link above."""
|
|
77
|
+
ffi.lib.LLVMPY_AddSROAPass(self)
|
|
78
|
+
|
|
79
|
+
def add_type_based_alias_analysis_pass(self):
|
|
80
|
+
ffi.lib.LLVMPY_AddTypeBasedAliasAnalysisPass(self)
|
|
81
|
+
|
|
82
|
+
def add_basic_alias_analysis_pass(self):
|
|
83
|
+
"""See http://llvm.org/docs/AliasAnalysis.html#the-basicaa-pass."""
|
|
84
|
+
ffi.lib.LLVMPY_AddBasicAliasAnalysisPass(self)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class ModulePassManager(PassManager):
|
|
88
|
+
|
|
89
|
+
def __init__(self, ptr=None):
|
|
90
|
+
if ptr is None:
|
|
91
|
+
ptr = ffi.lib.LLVMPY_CreatePassManager()
|
|
92
|
+
PassManager.__init__(self, ptr)
|
|
93
|
+
|
|
94
|
+
def run(self, module):
|
|
95
|
+
"""
|
|
96
|
+
Run optimization passes on the given module.
|
|
97
|
+
"""
|
|
98
|
+
return ffi.lib.LLVMPY_RunPassManager(self, module)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class FunctionPassManager(PassManager):
|
|
102
|
+
|
|
103
|
+
def __init__(self, module):
|
|
104
|
+
ptr = ffi.lib.LLVMPY_CreateFunctionPassManager(module)
|
|
105
|
+
self._module = module
|
|
106
|
+
module._owned = True
|
|
107
|
+
PassManager.__init__(self, ptr)
|
|
108
|
+
|
|
109
|
+
def initialize(self):
|
|
110
|
+
"""
|
|
111
|
+
Initialize the FunctionPassManager. Returns True if it produced
|
|
112
|
+
any changes (?).
|
|
113
|
+
"""
|
|
114
|
+
return ffi.lib.LLVMPY_InitializeFunctionPassManager(self)
|
|
115
|
+
|
|
116
|
+
def finalize(self):
|
|
117
|
+
"""
|
|
118
|
+
Finalize the FunctionPassManager. Returns True if it produced
|
|
119
|
+
any changes (?).
|
|
120
|
+
"""
|
|
121
|
+
return ffi.lib.LLVMPY_FinalizeFunctionPassManager(self)
|
|
122
|
+
|
|
123
|
+
def run(self, function):
|
|
124
|
+
"""
|
|
125
|
+
Run optimization passes on the given function.
|
|
126
|
+
"""
|
|
127
|
+
return ffi.lib.LLVMPY_RunFunctionPassManager(self, function)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# ============================================================================
|
|
131
|
+
# FFI
|
|
132
|
+
|
|
133
|
+
ffi.lib.LLVMPY_CreatePassManager.restype = ffi.LLVMPassManagerRef
|
|
134
|
+
|
|
135
|
+
ffi.lib.LLVMPY_CreateFunctionPassManager.argtypes = [ffi.LLVMModuleRef]
|
|
136
|
+
ffi.lib.LLVMPY_CreateFunctionPassManager.restype = ffi.LLVMPassManagerRef
|
|
137
|
+
|
|
138
|
+
ffi.lib.LLVMPY_DisposePassManager.argtypes = [ffi.LLVMPassManagerRef]
|
|
139
|
+
|
|
140
|
+
ffi.lib.LLVMPY_RunPassManager.argtypes = [ffi.LLVMPassManagerRef,
|
|
141
|
+
ffi.LLVMModuleRef]
|
|
142
|
+
ffi.lib.LLVMPY_RunPassManager.restype = c_bool
|
|
143
|
+
|
|
144
|
+
ffi.lib.LLVMPY_InitializeFunctionPassManager.argtypes = [ffi.LLVMPassManagerRef]
|
|
145
|
+
ffi.lib.LLVMPY_InitializeFunctionPassManager.restype = c_bool
|
|
146
|
+
|
|
147
|
+
ffi.lib.LLVMPY_FinalizeFunctionPassManager.argtypes = [ffi.LLVMPassManagerRef]
|
|
148
|
+
ffi.lib.LLVMPY_FinalizeFunctionPassManager.restype = c_bool
|
|
149
|
+
|
|
150
|
+
ffi.lib.LLVMPY_RunFunctionPassManager.argtypes = [ffi.LLVMPassManagerRef,
|
|
151
|
+
ffi.LLVMValueRef]
|
|
152
|
+
ffi.lib.LLVMPY_RunFunctionPassManager.restype = c_bool
|
|
153
|
+
|
|
154
|
+
ffi.lib.LLVMPY_AddConstantMergePass.argtypes = [ffi.LLVMPassManagerRef]
|
|
155
|
+
ffi.lib.LLVMPY_AddDeadArgEliminationPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
156
|
+
ffi.lib.LLVMPY_AddFunctionAttrsPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
157
|
+
ffi.lib.LLVMPY_AddFunctionInliningPass.argtypes = [ffi.LLVMPassManagerRef, c_int]
|
|
158
|
+
ffi.lib.LLVMPY_AddGlobalDCEPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
159
|
+
ffi.lib.LLVMPY_AddGlobalOptimizerPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
160
|
+
ffi.lib.LLVMPY_AddIPSCCPPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
161
|
+
|
|
162
|
+
ffi.lib.LLVMPY_AddDeadCodeEliminationPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
163
|
+
ffi.lib.LLVMPY_AddCFGSimplificationPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
164
|
+
ffi.lib.LLVMPY_AddGVNPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
165
|
+
ffi.lib.LLVMPY_AddInstructionCombiningPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
166
|
+
ffi.lib.LLVMPY_AddLICMPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
167
|
+
ffi.lib.LLVMPY_AddSCCPPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
168
|
+
ffi.lib.LLVMPY_AddSROAPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
169
|
+
ffi.lib.LLVMPY_AddTypeBasedAliasAnalysisPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
170
|
+
ffi.lib.LLVMPY_AddBasicAliasAnalysisPass.argtypes = [ffi.LLVMPassManagerRef]
|
|
@@ -246,6 +246,13 @@ class TargetMachine(ffi.ObjectRef):
|
|
|
246
246
|
"""
|
|
247
247
|
ffi.lib.LLVMPY_AddAnalysisPasses(self, pm)
|
|
248
248
|
|
|
249
|
+
def set_asm_verbosity(self, verbose):
|
|
250
|
+
"""
|
|
251
|
+
Set whether this target machine will emit assembly with human-readable
|
|
252
|
+
comments describing control flow, debug information, and so on.
|
|
253
|
+
"""
|
|
254
|
+
ffi.lib.LLVMPY_SetTargetMachineAsmVerbosity(self, verbose)
|
|
255
|
+
|
|
249
256
|
def emit_object(self, module):
|
|
250
257
|
"""
|
|
251
258
|
Represent the module as a code object, suitable for use with
|
|
@@ -366,6 +373,9 @@ ffi.lib.LLVMPY_DisposeTargetMachine.argtypes = [ffi.LLVMTargetMachineRef]
|
|
|
366
373
|
ffi.lib.LLVMPY_GetTargetMachineTriple.argtypes = [ffi.LLVMTargetMachineRef,
|
|
367
374
|
POINTER(c_char_p)]
|
|
368
375
|
|
|
376
|
+
ffi.lib.LLVMPY_SetTargetMachineAsmVerbosity.argtypes = [ffi.LLVMTargetMachineRef,
|
|
377
|
+
c_int]
|
|
378
|
+
|
|
369
379
|
ffi.lib.LLVMPY_AddAnalysisPasses.argtypes = [
|
|
370
380
|
ffi.LLVMTargetMachineRef,
|
|
371
381
|
ffi.LLVMPassManagerRef,
|
|
@@ -53,3 +53,23 @@ class _StringReferenceCaching(object):
|
|
|
53
53
|
except AttributeError:
|
|
54
54
|
s = self.__cached_refstr = self._get_reference()
|
|
55
55
|
return s
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class _HasMetadata(object):
|
|
59
|
+
|
|
60
|
+
def set_metadata(self, name, node):
|
|
61
|
+
"""
|
|
62
|
+
Attach unnamed metadata *node* to the metadata slot *name* of this value.
|
|
63
|
+
"""
|
|
64
|
+
self.metadata[name] = node
|
|
65
|
+
|
|
66
|
+
def _stringify_metadata(self, leading_comma=False):
|
|
67
|
+
if self.metadata:
|
|
68
|
+
buf = []
|
|
69
|
+
if leading_comma:
|
|
70
|
+
buf.append("")
|
|
71
|
+
buf += ["!{0} {1}".format(k, v.get_reference())
|
|
72
|
+
for k, v in self.metadata.items()]
|
|
73
|
+
return ', '.join(buf)
|
|
74
|
+
else:
|
|
75
|
+
return ''
|
|
@@ -472,7 +472,7 @@ class IRBuilder(object):
|
|
|
472
472
|
"""
|
|
473
473
|
return self._icmp('u', cmpop, lhs, rhs, name)
|
|
474
474
|
|
|
475
|
-
def fcmp_ordered(self, cmpop, lhs, rhs, name=''):
|
|
475
|
+
def fcmp_ordered(self, cmpop, lhs, rhs, name='', flags=[]):
|
|
476
476
|
"""
|
|
477
477
|
Floating-point ordered comparison:
|
|
478
478
|
name = lhs <cmpop> rhs
|
|
@@ -483,11 +483,11 @@ class IRBuilder(object):
|
|
|
483
483
|
op = 'o' + _CMP_MAP[cmpop]
|
|
484
484
|
else:
|
|
485
485
|
op = cmpop
|
|
486
|
-
instr = instructions.FCMPInstr(self.block, op, lhs, rhs, name=name)
|
|
486
|
+
instr = instructions.FCMPInstr(self.block, op, lhs, rhs, name=name, flags=flags)
|
|
487
487
|
self._insert(instr)
|
|
488
488
|
return instr
|
|
489
489
|
|
|
490
|
-
def fcmp_unordered(self, cmpop, lhs, rhs, name=''):
|
|
490
|
+
def fcmp_unordered(self, cmpop, lhs, rhs, name='', flags=[]):
|
|
491
491
|
"""
|
|
492
492
|
Floating-point unordered comparison:
|
|
493
493
|
name = lhs <cmpop> rhs
|
|
@@ -498,7 +498,7 @@ class IRBuilder(object):
|
|
|
498
498
|
op = 'u' + _CMP_MAP[cmpop]
|
|
499
499
|
else:
|
|
500
500
|
op = cmpop
|
|
501
|
-
instr = instructions.FCMPInstr(self.block, op, lhs, rhs, name=name)
|
|
501
|
+
instr = instructions.FCMPInstr(self.block, op, lhs, rhs, name=name, flags=flags)
|
|
502
502
|
self._insert(instr)
|
|
503
503
|
return instr
|
|
504
504
|
|