-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add missing file: /work/git/seal5_new/seal5/riscv_utils.py
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |