diff --git a/scripts/march-to-cpu-opt b/scripts/march-to-cpu-opt index f6777f4b79d..bbf5978df8c 100755 --- a/scripts/march-to-cpu-opt +++ b/scripts/march-to-cpu-opt @@ -41,6 +41,7 @@ SPIKE_EXT_NOT_ALLOWED = [ CPU_OPTIONS = { "xlen": "", "vlen": "", + "elen": "", "extensions": [], } @@ -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'])) @@ -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): @@ -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)