Skip to content

Commit

Permalink
seal5/backends/riscv_features: support llvm19
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Nov 18, 2024
1 parent aa78a19 commit 84a2a0d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def Feature${predicate} : RISCVExperimentalExtension<"${arch}", ${major}, ${minor}, "'${feature}' (${description})">;
def Has${predicate} : Predicate<"Subtarget->has${predicate}()">, AssemblerPredicate<(any_of Feature${predicate}), "'${feature}' (${description})">;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def Feature${predicate} : RISCVExtension<"${arch}", ${major}, ${minor}, "'${feature}' (${description})">;
def Has${predicate} : Predicate<"Subtarget->has${predicate}()">, AssemblerPredicate<(any_of Feature${predicate}), "'${feature}' (${description})">;
28 changes: 26 additions & 2 deletions seal5/backends/riscv_features/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,36 @@ def gen_riscv_features_str(name: str, ext_settings: ExtensionsSettings):
arch_ = ext_settings.get_arch(name=name)
description = ext_settings.get_description(name=name)
predicate = ext_settings.get_predicate(name=name)
version = ext_settings.get_version()
experimental = ext_settings.experimental

if requires:
raise NotImplementedError

content_template = Template(filename=str(template_dir / "riscv_features.mako"))
content_text = content_template.render(predicate=predicate, feature=feature, arch=arch_, description=description)
legacy = True
if settings:

Check failure on line 45 in seal5/backends/riscv_features/writer.py

View workflow job for this annotation

GitHub Actions / Flake8

seal5/backends/riscv_features/writer.py#L45

Undefined name 'settings' (F821)
llvm_settings = settings.llvm

Check failure on line 46 in seal5/backends/riscv_features/writer.py

View workflow job for this annotation

GitHub Actions / Flake8

seal5/backends/riscv_features/writer.py#L46

Undefined name 'settings' (F821)
if llvm_settings:
llvm_state = llvm_settings.state
if llvm_state:
llvm_version = llvm_state.version # unused today, but needed very soon
if llvm_version.major >= 19:
legacy = False
if legacy:
template_name = "riscv_features"
else:
if experimental:
template_name = "riscv_features_experimental_new"
else:
template_name = "riscv_features_new"

# TODO: make util!
assert isinstance(version, float)
major, minor = list(map(int, f"{val:.1f}".split(".", 1)))

Check failure on line 63 in seal5/backends/riscv_features/writer.py

View workflow job for this annotation

GitHub Actions / Flake8

seal5/backends/riscv_features/writer.py#L63

Undefined name 'val' (F821)


content_template = Template(filename=str(template_dir / f"{template_name}.mako"))

Check failure on line 66 in seal5/backends/riscv_features/writer.py

View workflow job for this annotation

GitHub Actions / Flake8

seal5/backends/riscv_features/writer.py#L66

Too many blank lines (2) (E303)
content_text = content_template.render(predicate=predicate, feature=feature, arch=arch_, description=description, major=major, minor=minor)

Check failure on line 67 in seal5/backends/riscv_features/writer.py

View workflow job for this annotation

GitHub Actions / Flake8

seal5/backends/riscv_features/writer.py#L67

Line too long (143 > 120 characters) (E501)
return content_text + "\n"


Expand Down
8 changes: 8 additions & 0 deletions seal5/pass_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,14 @@ def gen_riscv_isa_info_patch(
**_kwargs,
):
assert not split, "TODO"
if settings:
llvm_settings = settings.llvm
if llvm_settings:
llvm_state = llvm_settings.state
if llvm_state:
llvm_version = llvm_state.version # unused today, but needed very soon
assert llvm_version.major >= 19
return PassResult(metrics={})
# formats = True
gen_metrics_file = True
gen_index_file = True
Expand Down

0 comments on commit 84a2a0d

Please sign in to comment.