Browse Source
Merge pull request #1168 from riscv-collab/march-to-cpu-opt-unittest
Add unittest to march-to-cpu-opt
pull/1171/head
2022.12.17
Christoph Müllner
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
16 additions and
1 deletions
-
scripts/march-to-cpu-opt
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
import argparse |
|
|
|
import sys |
|
|
|
import unittest |
|
|
|
|
|
|
|
EXT_OPTS = { |
|
|
|
"zba": "zba=true", |
|
|
|
@ -138,8 +139,22 @@ def conver_arch_to_qemu_cpu_opt(march): |
|
|
|
cpu_opt.append("d=false") |
|
|
|
return ",".join(cpu_opt) |
|
|
|
|
|
|
|
|
|
|
|
class TestArchStringParse(unittest.TestCase): |
|
|
|
def _test(self, arch, expected_arch_list, expected_vlen=0): |
|
|
|
exts = parse_march(arch) |
|
|
|
vlen = get_vlen(exts) |
|
|
|
self.assertEqual(expected_vlen, vlen) |
|
|
|
self.assertEqual(set(expected_arch_list), set(exts.keys())) |
|
|
|
|
|
|
|
def test_rv64gc(self): |
|
|
|
self._test("rv64gc", ['i', 'm', 'a', 'f', 'd', 'c']) |
|
|
|
self._test("rv32imc_zve32x", ['i', 'm', 'c', 'zve32x'], expected_vlen=32) |
|
|
|
self._test("rv32imc_zve32x_zvl128b", ['i', 'm', 'c', 'zve32x', 'zvl128b'], expected_vlen=128) |
|
|
|
|
|
|
|
|
|
|
|
def selftest(): |
|
|
|
print(parse_march("rv64gc")) |
|
|
|
unittest.main(argv=sys.argv[1:]) |
|
|
|
|
|
|
|
def main(argv): |
|
|
|
opt = parse_opt(argv) |
|
|
|
|