19
19
import argparse
20
20
import json
21
21
import re
22
+ import sys
22
23
from collections import defaultdict
23
24
from dataclasses import dataclass
24
25
from enum import Enum
25
26
from itertools import product
26
27
from pathlib import Path
27
- from typing import Dict , Iterable , List , Sequence , Tuple
28
+ from typing import Any , Dict , Iterable , List , Sequence , Tuple
29
+
30
+ assert sys .version_info >= (3 , 10 ), "Only Python 3.10+ is supported."
28
31
29
32
30
33
# Are we testing arm_sve.h or arm_sme.h based builtins.
@@ -156,7 +159,7 @@ def make_arg_for_type(ty: str) -> Tuple[str, str]:
156
159
# Specifically the expected input is of the form:
157
160
# feat1,feat2,...(feat3 | feat4 | ...),...
158
161
def expand_feature_guard (
159
- guard : str , flags : str , base_feature : str = None
162
+ guard : str , flags : Sequence [ str ] , base_feature : str = ""
160
163
) -> list [set [str ]]:
161
164
"""
162
165
Expand a guard expression where ',' = AND and '|' = OR, with parentheses
@@ -389,7 +392,7 @@ def build_calls_for_group(builtins: Iterable[str]) -> Tuple[List[str], List[str]
389
392
"""
390
393
var_decls : List [str ] = []
391
394
seen_types : set [str ] = set ()
392
- calls : List [Tuple [ str , str ] ] = []
395
+ calls : List [str ] = []
393
396
394
397
for decl in builtins :
395
398
fn , param_types = parse_builtin_declaration (decl )
@@ -411,14 +414,15 @@ def build_calls_for_group(builtins: Iterable[str]) -> Tuple[List[str], List[str]
411
414
return var_decls , calls
412
415
413
416
414
- def gen_streaming_guard_tests (mode : MODE , json_path : Path , out_dir : Path ) -> None :
417
+ def gen_streaming_guard_tests (mode : Mode , json_path : Path , out_dir : Path ) -> None :
415
418
"""Generate a set of Clang Sema test files to ensure SVE/SME builtins are
416
419
callable based on the function type, or the required diagnostic is emitted.
417
420
"""
418
421
try :
419
422
data = json .loads (json_path .read_text ())
420
423
except json .JSONDecodeError as e :
421
- ap .error (f"Failed to parse JSON { args .json } : { e } " )
424
+ print (f"Failed to parse JSON { json_path } : { e } " , file = sys .stderr )
425
+ return
422
426
423
427
# Group by (guard, streaming_guard)
424
428
by_guard : Dict [BuiltinContext , List [str ]] = defaultdict (list )
@@ -468,7 +472,7 @@ def gen_streaming_guard_tests(mode: MODE, json_path: Path, out_dir: Path) -> Non
468
472
else :
469
473
print (output )
470
474
471
- return 0
475
+ return
472
476
473
477
474
478
# --- Main -------------------------------------------------------------------
0 commit comments