Skip to content

Commit

Permalink
Merge branch 'master' into centos7-build
Browse files Browse the repository at this point in the history
  • Loading branch information
tienntr committed Dec 21, 2023
2 parents 3b955ca + 8c969a9 commit 01fff56
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions scripts/march-to-cpu-opt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ SPIKE_EXT_NOT_ALLOWED = [
CPU_OPTIONS = {
"xlen": "",
"vlen": "",
"elen": "",
"extensions": [],
}

Expand Down Expand Up @@ -146,6 +147,16 @@ def get_vlen(ext_dict):
vlen = max(vlen, zvelen)
return vlen

def get_elen(ext_dict, xlen):
elen = xlen

if "zve32x" in ext_dict or "zve32f" in ext_dict:
elen = 32
if "zve64x" in ext_dict or "zve64f" in ext_dict or "zve64d" in ext_dict:
elen = 64

return elen

def print_qemu_cpu():
cpu_options = []
cpu_options.append("rv{0}".format(CPU_OPTIONS['xlen']))
Expand Down Expand Up @@ -186,7 +197,7 @@ def print_spike_varch():
if not CPU_OPTIONS['vlen']:
return ""

return "vlen:{0},elen:{1}".format(CPU_OPTIONS['vlen'], CPU_OPTIONS['xlen'])
return "vlen:{0},elen:{1}".format(CPU_OPTIONS['vlen'], CPU_OPTIONS['elen'])

class TestArchStringParse(unittest.TestCase):
def _test(self, arch, expected_arch_list, expected_vlen=0):
Expand Down Expand Up @@ -254,9 +265,12 @@ def parse_elf_file(elf_file_path):
for extension in extension_dict.keys():
extensions.append(extension)

xlen = get_xlen(elf_file_path)

CPU_OPTIONS["extensions"] = extensions
CPU_OPTIONS["vlen"] = get_vlen(extension_dict)
CPU_OPTIONS["xlen"] = get_xlen(elf_file_path)
CPU_OPTIONS["elen"] = get_elen(extension_dict, xlen)
CPU_OPTIONS["xlen"] = xlen

def main(argv):
opt = parse_opt(argv)
Expand Down

0 comments on commit 01fff56

Please sign in to comment.