Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Mar 1, 2024
1 parent 3018fcc commit 380ca20
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion seal5/backends/llvmir/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def main():
input_file,
output_file,
skip_patterns=True,
skip_formats=True
skip_formats=True,
)
metrics["n_success"] += 1
except AssertionError:
Expand Down
1 change: 0 additions & 1 deletion seal5/backends/patterngen/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def main():
skip_formats=not args.formats,
ext=predicate,
mattr=mattr,

)
if output_file.is_file():
metrics["n_success"] += 1
Expand Down
6 changes: 4 additions & 2 deletions seal5/backends/riscv_gisel_legalizer/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

# if (ST.hasVendorXCvsimd()) {


def type_helper(ty):
print("type_helper", ty)
ty_ = ty.replace("seal5_", "")
Expand All @@ -43,7 +44,6 @@ def type_helper(ty):
raise RuntimeError(f"Unsupported: {ty}")



def gen_riscv_gisel_legalizer_str(legalizer_settings: RISCVLegalizerSettings):
print("legalizer_settings", legalizer_settings)
ops = legalizer_settings.ops
Expand Down Expand Up @@ -167,7 +167,9 @@ def main():
with open(out_path, "w") as f:
f.write(content)
riscv_gisel_legalizer_patch = NamedPatch(
"llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp", key="riscv_legalizer_info", src_path=out_path
"llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp",
key="riscv_legalizer_info",
src_path=out_path,
)
artifacts[None].append(riscv_gisel_legalizer_patch)
if args.metrics:
Expand Down
8 changes: 3 additions & 5 deletions seal5/backends/riscv_isa_info/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
logger = logging.getLogger("riscv_isa_info")


MAKO_TEMPLATE = " {\"${arch}\", RISCVExtensionVersion{${version_major}, ${version_minor}}},"
MAKO_TEMPLATE_LLVM18 = " {\"${arch}\", {${version_major}, ${version_minor}}},"
MAKO_TEMPLATE = ' {"${arch}", RISCVExtensionVersion{${version_major}, ${version_minor}}},'
MAKO_TEMPLATE_LLVM18 = ' {"${arch}", {${version_major}, ${version_minor}}},'


def gen_riscv_isa_info_str(name: str, ext_settings: ExtensionsSettings, llvm_version: LLVMVersion):
Expand Down Expand Up @@ -140,9 +140,7 @@ def main():
key = "riscv_isa_info_experimental"
else:
key = "riscv_isa_info"
riscv_isa_info_patch = NamedPatch(
"llvm/lib/Support/RISCVISAInfo.cpp", key=key, src_path=out_path
)
riscv_isa_info_patch = NamedPatch("llvm/lib/Support/RISCVISAInfo.cpp", key=key, src_path=out_path)
artifacts[None].append(riscv_isa_info_patch)
if args.metrics:
metrics_file = args.metrics
Expand Down
16 changes: 11 additions & 5 deletions seal5/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ def initialize(
sha, version_info = llvm.clone_llvm_repo(self.directory, clone_url, ref=clone_ref, label=self.name)
else:
if force:
sha, version_info = llvm.clone_llvm_repo(self.directory, clone_url, ref=clone_ref, refresh=True, label=self.name)
sha, version_info = llvm.clone_llvm_repo(
self.directory, clone_url, ref=clone_ref, refresh=True, label=self.name
)
if self.meta_dir.is_dir():
if force is False and not utils.ask_user(
"Overwrite existing .seal5 diretcory?", default=False, interactive=interactive
Expand Down Expand Up @@ -405,12 +407,12 @@ def load(self, files: List[Path], verbose: bool = False, overwrite: bool = False
logger.info("Completed load of Seal5 inputs")

def build(self, config="release", target="all", verbose: bool = False):
logger.info("Building Seal5 LLVM")
logger.info("Building Seal5 LLVM (%s)", target)
llvm_config = self.settings.llvm.configs.get(config, None)
assert llvm_config is not None, f"Invalid llvm config: {config}"
cmake_options = llvm_config.options
llvm.build_llvm(self.directory, self.build_dir / config, cmake_options=cmake_options, target=target)
logger.info("Completed build of Seal5 LLVM")
logger.info("Completed build of Seal5 LLVM (%s)", target)

def convert_models(self, verbose: bool = False, inplace: bool = False):
assert not inplace
Expand Down Expand Up @@ -1348,7 +1350,9 @@ def convert_llvmir_to_gmir_splitted(self, verbose: bool = False, inplace: bool =
cdsl2llvm_build_dir = str(self.deps_dir / "cdsl2llvm" / "llvm" / "build")
cdsl2llvm.convert_ll_to_gmir(
# self.deps_dir / "cdsl2llvm" / "llvm" / "build", ll_file, output_file
cdsl2llvm_build_dir, ll_file, output_file
cdsl2llvm_build_dir,
ll_file,
output_file,
)
except AssertionError:
pass
Expand Down Expand Up @@ -1587,7 +1591,9 @@ def patch(self, verbose: bool = False, stages: List[PatchStage] = None, force: b
self.apply_patch(patch, force=force)
logger.info("Completed application of Seal5 patches")

def test(self, debug: bool = False, verbose: bool = False, ignore_error: bool = False, config: Optional[str] = None):
def test(
self, debug: bool = False, verbose: bool = False, ignore_error: bool = False, config: Optional[str] = None
):
logger.info("Testing Seal5 LLVM")
if config is None:
config = "debug" if debug else "release"
Expand Down
10 changes: 7 additions & 3 deletions seal5/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class PassScope(Enum):


class Seal5Pass:

def __init__(self, name, pass_type, pass_scope, handler, order=-1, options=None):
self.name: str = name
self.pass_type: PassType = pass_type
Expand All @@ -35,7 +34,7 @@ def __init__(self, name, pass_type, pass_scope, handler, order=-1, options=None)

@property
def is_pending(self):
return self.status in [PassStatus.CREATED]
return self.status in [PassStatus.CREATED, PassStatus.SKIPPED]

def skip(self):
self.status = PassStatus.SKIPPED
Expand All @@ -53,7 +52,12 @@ def run(self, *args, **kwargs):
raise e


def filter_passes(passes: List[Seal5Pass], pass_name: Optional[str] = None, pass_type: Optional[PassType] = None, pass_scope: Optional[PassScope] = None):
def filter_passes(
passes: List[Seal5Pass],
pass_name: Optional[str] = None,
pass_type: Optional[PassType] = None,
pass_scope: Optional[PassScope] = None,
):
# TODO: support regex patters in name
ret = []
for pass_ in passes:
Expand Down
4 changes: 2 additions & 2 deletions seal5/resources/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from lit.llvm.subst import ToolSubst

# name: The name of this test suite.
config.name = 'LLVM'
config.name = "LLVM"

# testFormat: The test format to use to interpret tests.
# config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
config.test_format = lit.formats.ShTest(True)

# # suffixes: A list of file extensions to treat as test files. This is overriden
# # by individual lit.local.cfg files in the test subdirectories.
config.suffixes = ['.ll', '.c', '.test', '.txt', '.s', '.mir', '.yaml']
config.suffixes = [".ll", ".c", ".test", ".txt", ".s", ".mir", ".yaml"]
4 changes: 4 additions & 0 deletions seal5/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,19 @@ class LLVMSettings(YAMLSettings):
state: Optional[LLVMState] = None
configs: Optional[Dict[str, LLVMConfig]] = None


@dataclass
class RISCVLegalizerSetting(YAMLSettings):
name: Optional[Union[str, List[str]]] = None
types: Optional[Union[str, List[str]]] = None
onlyif: Optional[Union[str, List[str]]] = None


@dataclass
class RISCVLegalizerSettings(YAMLSettings):
ops: Optional[List[RISCVLegalizerSetting]] = None


@dataclass
class RISCVSettings(YAMLSettings):
xlen: Optional[int] = None
Expand All @@ -481,6 +484,7 @@ class PatternGenSettings(YAMLSettings):
class ToolsSettings(YAMLSettings):
pattern_gen: Optional[PatternGenSettings] = None


@dataclass
class Seal5Settings(YAMLSettings):
logging: Optional[LoggingSettings] = None
Expand Down
4 changes: 3 additions & 1 deletion seal5/tools/cdsl2llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def build_pattern_gen(


def get_pattern_gen_patches(
src: Path, temp_dir: Path, verbose: bool = False,
src: Path,
temp_dir: Path,
verbose: bool = False,
):
# TODO: copy!
artifacts = []
Expand Down
2 changes: 1 addition & 1 deletion seal5/tools/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def build_llvm(


def test_llvm(base: Path, build_dir: Path, test_paths: List[str] = [], verbose: bool = False):
env = os.eviron.copy()
env = os.environ.copy()
old_path = env["PATH"]
env["PATH"] = f"{build_dir}/bin:{old_path}"
lit_exe = build_dir / "bin" / "llvm-lit"
Expand Down
2 changes: 1 addition & 1 deletion seal5/transform/filter_model/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def check_encoding_filter(enc, keep, drop, keep2, drop2):
if drop2 and keep2:
ret = size not in drop2 and size in keep2
elif keep2:
ret = size in keep2
ret = size in keep2
elif drop2:
ret = size not in drop2
if not ret:
Expand Down

0 comments on commit 380ca20

Please sign in to comment.