|
15 | 15 | CHERI_GENERIC_UTC_CMD = re.compile((r'.*' + CHERI_GENERIC_UTC_KEY + r'\s*(?P<cmd>.*)\s*$').encode("utf-8"))
|
16 | 16 |
|
17 | 17 |
|
| 18 | +def _list2bytes(l: "list[str]") -> bytes: |
| 19 | + return " ".join(l).encode("utf-8") |
| 20 | + |
18 | 21 | class ArchSpecificValues(object):
|
19 | 22 | def __init__(self, architecture: str, *, cap_range, cap_width,
|
20 | 23 | common_args: list, hybrid_sf_args: list, hybrid_hf_args: list,
|
21 | 24 | purecap_sf_args: list, purecap_hf_args: list, datalayout: bytes,
|
22 | 25 | base_architecture: str = None):
|
23 |
| - self.hybrid_datalayout = datalayout |
24 |
| - self.purecap_datalayout = datalayout + b"-A200-P200-G200" |
25 |
| - self.hybrid_softfloat_args = (" ".join(common_args + hybrid_sf_args)).encode("utf-8") |
26 |
| - self.hybrid_hardfloat_args = (" ".join(common_args + hybrid_hf_args)).encode("utf-8") |
27 |
| - self.purecap_softfloat_args = (" ".join(common_args + purecap_sf_args)).encode("utf-8") |
28 |
| - self.purecap_hardfloat_args = (" ".join(common_args + purecap_hf_args)).encode("utf-8") |
| 26 | + |
| 27 | + self.replacements: "dict[bytes, bytes]" = { |
| 28 | + b"@HYBRID_DATALAYOUT@": datalayout, |
| 29 | + b"@PURECAP_DATALAYOUT@": datalayout + b"-A200-P200-G200", |
| 30 | + b"@HYBRID_SOFTFLOAT_ARGS@": _list2bytes(common_args + hybrid_sf_args), |
| 31 | + b"@HYBRID_HARDFLOAT_ARGS@": _list2bytes(common_args + hybrid_hf_args), |
| 32 | + b"@PURECAP_SOFTFLOAT_ARGS@": _list2bytes(common_args + purecap_sf_args), |
| 33 | + b"@PURECAP_HARDFLOAT_ARGS@": _list2bytes(common_args + purecap_hf_args), |
| 34 | + } |
29 | 35 | self.cap_width = cap_width
|
30 | 36 | self.cap_range = cap_range
|
31 | 37 | self.name = architecture
|
@@ -200,12 +206,9 @@ def update_one_test(test_name: str, input_file: typing.BinaryIO,
|
200 | 206 | int(math.log2(arch_def.cap_range / 8))).encode("utf-8"))
|
201 | 207 | # Opt tests require a datalayout since the lit substitutions don't
|
202 | 208 | # include it in their commandline
|
203 |
| - converted_line = converted_line.replace(b"@PURECAP_DATALAYOUT@", arch_def.purecap_datalayout) |
204 |
| - converted_line = converted_line.replace(b"@HYBRID_DATALAYOUT@", arch_def.hybrid_datalayout) |
205 |
| - converted_line = converted_line.replace(b"@HYBRID_SOFTFLOAT_ARGS@", arch_def.hybrid_softfloat_args) |
206 |
| - converted_line = converted_line.replace(b"@HYBRID_HARDFLOAT_ARGS@", arch_def.hybrid_hardfloat_args) |
207 |
| - converted_line = converted_line.replace(b"@PURECAP_SOFTFLOAT_ARGS@", arch_def.purecap_softfloat_args) |
208 |
| - converted_line = converted_line.replace(b"@PURECAP_HARDFLOAT_ARGS@", arch_def.purecap_hardfloat_args) |
| 209 | + for key, replacement in arch_def.replacements.items(): |
| 210 | + converted_line = converted_line.replace(key, replacement) |
| 211 | + |
209 | 212 | if args.verbose and converted_line != line:
|
210 | 213 | print("Adjusted line:")
|
211 | 214 | print(" Before:", line)
|
|
0 commit comments