Skip to content

Commit 328457b

Browse files
committed
Rename 'llvm_compiler.Compiler' to 'native_compiler.NativeCompiler'.
This class is intended to be the main entrypoint for client code that wants to compile native_ast objects into actual runnable code. All LLVM/compiler details should be encapsulated by it.
1 parent a7779b0 commit 328457b

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

typed_python/compiler/native_compiler/native_ast_to_llvm_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Expression, Void, Int32, nullExpr, Function, FunctionBody,
1717
Teardown, const_int32_expr, CallTarget, NamedCallTarget
1818
)
19-
from typed_python.compiler.native_compiler.llvm_compiler import llvm
19+
import llvmlite.binding as llvm
2020
import typed_python.compiler.native_compiler.native_ast_to_llvm as native_ast_to_llvm
2121
import unittest
2222

typed_python/compiler/native_compiler/llvm_compiler.py renamed to typed_python/compiler/native_compiler/native_compiler.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@ def create_execution_engine(inlineThreshold):
8383
return engine, pass_manager
8484

8585

86-
class Compiler:
86+
class NativeCompiler:
87+
""""Engine for compiling bundles of native_ast.Function objects into NativeFunctionPointers.
88+
89+
This class is responsible for
90+
* telling clients what named functions have been defined and what their types are.
91+
* compiling functions into a runnable form using llvm
92+
* performing any runtime-based performance optimizations
93+
* maintaining the compiler cache
94+
"""
8795
def __init__(self, inlineThreshold):
8896
self.engine, self.module_pass_manager = create_execution_engine(inlineThreshold)
8997
self.converter = native_ast_to_llvm.Converter()

typed_python/compiler/native_compiler/llvm_compiler_test.py renamed to typed_python/compiler/native_compiler/native_compiler_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def test_global_variable_pointers():
5555

5656
# we have to use the singleton here because the llvm context
5757
# is global.
58-
llvmCompiler = Runtime.singleton().llvm_compiler
58+
nativeCompiler = Runtime.singleton().native_compiler
5959

60-
loadedModule = llvmCompiler.buildModule(
60+
loadedModule = nativeCompiler.buildModule(
6161
dict(
6262
_readGlobalVarFunc=readGlobalVarFunc,
6363
_returnGlobalVarPtrFunc=returnGlobalVarPtrFunc
@@ -109,9 +109,9 @@ def test_create_binary_shared_object():
109109
)
110110
)
111111

112-
llvmCompiler = Runtime.singleton().llvm_compiler
112+
nativeCompiler = Runtime.singleton().native_compiler
113113

114-
bso = llvmCompiler.buildSharedObject(
114+
bso = nativeCompiler.buildSharedObject(
115115
{'__test_f_2': f}
116116
)
117117

typed_python/compiler/runtime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import time
1818
import types
1919
import typed_python.compiler.python_to_native_converter as python_to_native_converter
20-
import typed_python.compiler.native_compiler.llvm_compiler as llvm_compiler
20+
import typed_python.compiler.native_compiler.native_compiler as native_compiler
2121
import typed_python
2222
from typed_python.compiler.runtime_lock import runtimeLock
2323
from typed_python.compiler.conversion_level import ConversionLevel
@@ -207,9 +207,9 @@ def __init__(self):
207207
)
208208
else:
209209
self.compilerCache = None
210-
self.llvm_compiler = llvm_compiler.Compiler(inlineThreshold=100)
210+
self.native_compiler = native_compiler.NativeCompiler(inlineThreshold=100)
211211
self.converter = python_to_native_converter.PythonToNativeConverter(
212-
self.llvm_compiler,
212+
self.native_compiler,
213213
self.compilerCache
214214
)
215215
self.lock = runtimeLock
@@ -223,9 +223,9 @@ def __init__(self):
223223
else:
224224
self.addEventVisitor(PrintNewFunctionVisitor(True))
225225
if self.verbosityLevel >= 4:
226-
self.llvm_compiler.mark_converter_verbose()
226+
self.native_compiler.mark_converter_verbose()
227227
if self.verbosityLevel >= 5:
228-
self.llvm_compiler.mark_llvm_codegen_verbose()
228+
self.native_compiler.mark_llvm_codegen_verbose()
229229
else:
230230
self.verbosityLevel = 0
231231

0 commit comments

Comments
 (0)