Skip to content

Commit

Permalink
misc: move print_csl import away from top level (#2948)
Browse files Browse the repository at this point in the history
Currently, any call to xdsl-opt imports csl, which is slow, this change
moves the import to only the case when it's intended.
  • Loading branch information
superlopuh authored Jul 26, 2024
1 parent 31ea826 commit 2d67e7c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions xdsl/xdsl_opt_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from itertools import accumulate
from typing import IO

from xdsl.backend.csl.print_csl import print_to_csl
from xdsl.context import MLContext
from xdsl.dialects import riscv, x86
from xdsl.dialects.builtin import ModuleOp
Expand Down Expand Up @@ -231,12 +230,17 @@ def _emulate_riscv(prog: ModuleOp, output: IO[str]):
with redirect_stdout(output):
run_riscv(code, unlimited_regs=True, verbosity=0)

def _print_to_csl(prog: ModuleOp, output: IO[str]):
from xdsl.backend.csl.print_csl import print_to_csl

print_to_csl(prog, output)

self.available_targets["mlir"] = _output_mlir
self.available_targets["riscv-asm"] = _output_riscv_asm
self.available_targets["x86-asm"] = _output_x86_asm
self.available_targets["riscemu"] = _emulate_riscv
self.available_targets["wat"] = _output_wat
self.available_targets["csl"] = print_to_csl
self.available_targets["csl"] = _print_to_csl

def setup_pipeline(self):
"""
Expand Down

0 comments on commit 2d67e7c

Please sign in to comment.