Exemplo n.º 1
0
Arquivo: jit.py Projeto: cr1901/artiq
def main():
    libartiq_support = os.getenv('LIBARTIQ_SUPPORT')
    if libartiq_support is not None:
        llvm.load_library_permanently(libartiq_support)

    def process_diagnostic(diag):
        print("\n".join(diag.render()))
        if diag.level in ("fatal", "error"):
            exit(1)

    engine = diagnostic.Engine()
    engine.process = process_diagnostic

    source = "".join(fileinput.input())
    source = source.replace("#ARTIQ#", "")
    mod = Module(Source.from_string(source.expandtabs(), engine=engine))

    target = NativeTarget()
    llmod = mod.build_llvm_ir(target)
    llparsedmod = llvm.parse_assembly(str(llmod))
    llparsedmod.verify()

    llmachine = llvm.Target.from_triple(target.triple).create_target_machine()
    lljit = llvm.create_mcjit_compiler(llparsedmod, llmachine)
    llmain = lljit.get_pointer_to_global(llparsedmod.get_function(llmod.name + ".__modinit__"))
    ctypes.CFUNCTYPE(None)(llmain)()
Exemplo n.º 2
0
def main():
    libartiq_support = os.getenv("LIBARTIQ_SUPPORT")
    if libartiq_support is not None:
        llvm.load_library_permanently(libartiq_support)

    def process_diagnostic(diag):
        print("\n".join(diag.render()))
        if diag.level in ("fatal", "error"):
            exit(1)

    engine = diagnostic.Engine()
    engine.process = process_diagnostic

    source = "".join(fileinput.input())
    source = source.replace("#ARTIQ#", "")
    mod = Module(Source.from_string(source.expandtabs(), engine=engine))

    target = NativeTarget()
    llmod = mod.build_llvm_ir(target)
    llparsedmod = llvm.parse_assembly(str(llmod))
    llparsedmod.verify()

    llmachine = llvm.Target.from_triple(target.triple).create_target_machine()
    lljit = llvm.create_mcjit_compiler(llparsedmod, llmachine)
    llmain = lljit.get_function_address(llmod.name + ".__modinit__")
    ctypes.CFUNCTYPE(None)(llmain)()
Exemplo n.º 3
0
 def get_ee(self):
     self.finalize()
     tm = llvm.Target.from_default_triple().create_target_machine()
     ee = llvm.create_mcjit_compiler(self.llvm_module_ref, tm)
     ee.finalize_object()
     return ee
Exemplo n.º 4
0
 def get_ee(self):
     self.finalize()
     tm = llvm.Target.from_default_triple().create_target_machine()
     ee = llvm.create_mcjit_compiler(self.llvm_module_ref, tm)
     ee.finalize_object()
     return ee