diff --git a/backends/llvm.py b/backends/llvm.py index 695b6b10094cbb13d5edc643f686dc50b4ac9a9c..4a45844f58575c0325a9374750915c4ee24e7ca3 100644 --- a/backends/llvm.py +++ b/backends/llvm.py @@ -7,6 +7,15 @@ from sympy import S from pystencils.llvm.control_flow import Loop +def generateLLVM(ast_node): + """ + Prints the ast as llvm code + """ + module = ir.Module() + builder = ir.IRBuilder() + printer = LLVMPrinter(module, builder) + return printer._print(ast_node) + class LLVMPrinter(Printer): """Convert expressions to LLVM IR""" @@ -133,10 +142,3 @@ class LLVMPrinter(Printer): def emptyPrinter(self, expr): raise TypeError("Unsupported type for LLVM JIT conversion: %s" % type(expr)) - - -def generateLLVM(astNode): - module = ir.Module() - builder = ir.IRBuilder() - printer = LLVMPrinter(module, builder) - return printer._print(astNode) diff --git a/llvm/__init__.py b/llvm/__init__.py index 7eb3311e99358390954c2ec0b86ce7bc2fd3bbbf..681ec00a7a3e268fa55252521da2a3d1c7a610f8 100644 --- a/llvm/__init__.py +++ b/llvm/__init__.py @@ -1,2 +1 @@ from pystencils.cpu.kernelcreation import createKernel -from pystencils.backends.llvm import generateLLVM \ No newline at end of file