Skip to content

Commit

Permalink
add missing file: /work/git/seal5_new/seal5/riscv_utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Aug 22, 2024
1 parent 4526356 commit cf365f5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions seal5/riscv_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from typing import Optional


def get_riscv_defaults(riscv_settings):
default_features = ["+m", "+fast-unaligned-access"]
default_xlen = None
if riscv_settings:
default_features_ = riscv_settings.features
if default_features_ is not None:
default_features = default_features_
default_xlen_ = riscv_settings.xlen
if default_xlen is not None:
default_xlen = default_xlen_
return default_features, default_xlen


def build_mattr(features, xlen: Optional[int] = None):
mattrs = []

def fix_prefix(x):
assert len(x) > 0
if x[0] in ["-", "+"]:
return x
return f"+{x}"

if features is not None:
mattrs += [f"+{f}" for f in features]
if xlen is not None:
if xlen == 64:
mattrs += ["+64bit"]
mattrs = list(set(map(fix_prefix, mattrs)))
mattr = ",".join(mattrs)
return mattr

0 comments on commit cf365f5

Please sign in to comment.