def translate(func, env, _): emit = lambda s, *args: sys.stdout.write(format(s, *args) + "\n") # -- Create visitor -- # translator = Translator(func, env, emit) visitor = opgrouper(translator) # -- Codegen -- # argloader = CArgLoader() valuemap = vvisit(visitor, func, argloader)
def translate(func, env, lfunc): engine, llvm_module = env["codegen.llvm.engine"], env["codegen.llvm.module"] blockmap = allocate_blocks(lfunc, func) ### Create visitor ### translator = Translator(func, env, lfunc, llvm_type, llvm_module) visitor = opgrouper(translator) ### Codegen ### argloader = LLVMArgLoader(None, engine, llvm_module, lfunc, blockmap) valuemap = vvisit(visitor, func, argloader) update_phis(translator.phis, valuemap, argloader) return lfunc
def translate(func, engine, llvm_module): verify_lowlevel(func) ### Create lfunc ### lfunc = llvm_module.add_function(llvm_type(func.type), func.name) blockmap = allocate_blocks(lfunc, func) ### Create visitor ### translator = Translator(func, lfunc, llvm_type, llvm_module) visitor = opgrouper(translator) ### Codegen ### argloader = LLVMArgLoader(None, engine, llvm_module, lfunc, blockmap) valuemap = vvisit(visitor, func, argloader) update_phis(translator.phis, valuemap, argloader) return lfunc