def METHOD_NAME(output, basename=None):
    if output == "coreir":
        with tempfile.TemporaryDirectory() as tempdir:
            basename = f"{tempdir}/Top"
            m.compile(basename, _Top, output="coreir")
        modules = m.backend.coreir.coreir_runtime.module_map()
        return modules[list(modules.keys())[0]]['global']
    if output == "mlir":
        m.compile(f"build/{basename}", _Top, output="mlir")
        return
    raise NotImplementedError(output)