To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 54ae4170 authored by John Zhang's avatar John Zhang
Browse files

Enable compiling with both backends within one compilation process.

parent d66371b8
......@@ -291,7 +291,7 @@ translation_optiondescription = OptionDescription(
# Mu backend options
ChoiceOption("mucodegen", "Code generator to use for Mu backend",
["text", "api"], default="text", cmdline="--mugen"),
["text", "api", "both"], default="text", cmdline="--mugen"),
])
def get_combined_translation_config(other_optdescr=None,
......
......@@ -78,7 +78,7 @@ def extract_bundle(bdl):
return ir, hail, json.loads(info)
def get_c_args(ctx, args):
def get_c_args(ctx, args, info):
length = len(args)
argc = ctx.handle_from_int(length, 32)
buf = (ctypes.c_char_p * length)()
......@@ -86,7 +86,7 @@ def get_c_args(ctx, args):
arg = args[i]
buf[i] = ctypes.cast(ctypes.create_string_buffer(arg), ctypes.c_char_p)
argv = ctx.handle_from_ptr(ctx.id_of("@ptrhybarrayPtr_0"), ctypes.cast(buf, ctypes.c_void_p))
argv = ctx.handle_from_ptr(ctx.id_of(info['argv_t']), ctypes.cast(buf, ctypes.c_void_p))
return argc, argv
......@@ -103,7 +103,7 @@ def launch(cmdargs, ir, hail, info, args):
if cmdargs.checkOnly:
return 0
argc, argv = get_c_args(ctx, args)
argc, argv = get_c_args(ctx, args, info)
bundle_entry = ctx.handle_from_func(ctx.id_of(info['entrypoint']))
st = ctx.new_stack(bundle_entry)
th = ctx.new_thread(st, None, libmu.PassValues(argc, argv))
......
......@@ -14,7 +14,7 @@ from rpython.tool.ansi_print import AnsiLogger
from rpython.tool.udir import udir
from rpython.translator.goal import query
from rpython.translator.goal.timing import Timer
from rpython.translator.mu.genmu import get_codegen_class
from rpython.translator.mu.genmu import get_codegen_class, MuTextBundleGenerator, MuAPIBundleGenerator
from rpython.translator.tool.taskengine import SimpleTaskEngine
from rpython.translator.translator import TranslationContext
from .mu.database import MuDatabase
......@@ -603,13 +603,22 @@ class TranslationDriver(SimpleTaskEngine):
def task_compile_mu(self):
self.log.info("Task compile_mu")
target_name = self.compute_exe_name()
if target_name.ext != MuDatabase.bundle_suffix:
bundle_name = target_name + MuDatabase.bundle_suffix
if self.config.translation.mucodegen == "both":
self.log.info("generating bundle using text backend")
bdlgen_text = MuTextBundleGenerator(self.mudb)
bdlgen_text.bundlegen(target_name + '.mutxt')
self.log.info("generating bundle using Mu API backend")
bdlgen_api = MuAPIBundleGenerator(self.mudb)
bdlgen_api.bundlegen(target_name + '.muapi')
else:
bundle_name = target_name
cls = get_codegen_class()
bdlgen = cls(self.mudb)
bdlgen.bundlegen(bundle_name)
if target_name.ext != MuDatabase.bundle_suffix:
bundle_name = target_name + MuDatabase.bundle_suffix
else:
bundle_name = target_name
cls = get_codegen_class()
bdlgen = cls(self.mudb)
bdlgen.bundlegen(bundle_name)
def proceed(self, goals):
if not goals:
......
......@@ -60,10 +60,10 @@ class MuTextBundleGenerator(MuBundleGenerator):
strio.close()
zf.writestr(entry_name, s)
_writefrom(bdlpath.basename.replace('.mu', '.uir'), strio_ir)
_writefrom(bdlpath.basename.replace('.mu', '.hail'), strio_hail)
_writefrom(bdlpath.basename.replace('.mu', '.info'), strio_info)
_writefrom(bdlpath.basename.replace('.mu', '.txt'), strio_graphs)
_writefrom(bdlpath.basename.replace(bdlpath.ext, '.uir'), strio_ir)
_writefrom(bdlpath.basename.replace(bdlpath.ext, '.hail'), strio_hail)
_writefrom(bdlpath.basename.replace(bdlpath.ext, '.info'), strio_info)
_writefrom(bdlpath.basename.replace(bdlpath.ext, '.txt'), strio_graphs)
zf.close()
self.log.zipbundle("done.")
......@@ -109,7 +109,8 @@ class MuTextBundleGenerator(MuBundleGenerator):
# some extra information
info = {
"libdeps": ":".join(map(lambda lib: lib._name, self.db.dylibs)),
"entrypoint": str(self.db.prog_entry.mu_name)
"entrypoint": str(self.db.prog_entry.mu_name),
"argv_t": str(self.db.prog_entry.startblock.mu_inputargs[1].mu_type.mu_name)
}
fp_info.write(json.dumps(info))
......@@ -141,7 +142,7 @@ class MuAPIBundleGenerator(MuBundleGenerator):
libconfig.append("extraLibs=" + ":".join(extlibs))
# dumpBundle
libconfig.append("dumpBundle=%s" % True)
libconfig.append("dumpBundle=%s" % False)
return "\n".join(libconfig)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment