diff --git a/.basedpyright/baseline.json b/.basedpyright/baseline.json index cf31cdf61..faf88f576 100644 --- a/.basedpyright/baseline.json +++ b/.basedpyright/baseline.json @@ -68875,182 +68875,6 @@ } ], "./loopy/target/c/__init__.py": [ - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 27, - "endColumn": 40, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 27, - "endColumn": 40, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 11, - "endColumn": 28, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 11, - "endColumn": 69, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 44, - "endColumn": 69, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 24, - "endColumn": 49, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 11, - "endColumn": 27, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 11, - "endColumn": 68, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 43, - "endColumn": 68, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 16, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 16, - "endColumn": 50, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 16, - "endColumn": 63, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 8, - "endColumn": 41, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 24, - "endColumn": 37, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 24, - "endColumn": 37, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 39, - "endColumn": 53, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 15, - "endColumn": 26, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 39, - "endColumn": 67, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 16, - "endColumn": 44, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 11, - "endColumn": 20, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 25, - "endColumn": 45, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 25, - "endColumn": 52, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -69059,30 +68883,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 20, - "endColumn": 35, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 24, - "endColumn": 44, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 24, - "endColumn": 51, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -69091,30 +68891,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 20, - "endColumn": 35, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 24, - "endColumn": 44, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 24, - "endColumn": 51, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -69123,54 +68899,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 20, - "endColumn": 38, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 15, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 15, - "endColumn": 45, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 15, - "endColumn": 50, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 25, - "endColumn": 36, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 32, - "endColumn": 43, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { diff --git a/loopy/target/c/__init__.py b/loopy/target/c/__init__.py index 8bf97fb50..13026f61c 100644 --- a/loopy/target/c/__init__.py +++ b/loopy/target/c/__init__.py @@ -75,11 +75,11 @@ if TYPE_CHECKING: - from collections.abc import Callable, Mapping, Sequence + from collections.abc import Callable, Iterator, Mapping, Sequence from numpy.typing import DTypeLike - from loopy.codegen import CodeGenerationState + from loopy.codegen import CodeGenerationState, PreambleInfo from loopy.codegen.result import CodeGenerationResult from loopy.kernel import LoopKernel from loopy.kernel.instruction import MultiAssignmentBase @@ -209,7 +209,7 @@ def map_nan(self, expr: p.NaN): return super().map_nan(expr) -def c99_preamble_generator(preamble_info): +def c99_preamble_generator(preamble_info: PreambleInfo) -> Iterator[tuple[str, str]]: if any(dtype.is_integral() for dtype in preamble_info.seen_dtypes): yield ("10_stdint", """ #include @@ -235,7 +235,12 @@ def c99_preamble_generator(preamble_info): # }}} -def _preamble_generator(preamble_info, func_qualifier="inline"): +def _preamble_generator( + preamble_info: PreambleInfo, + func_qualifier: str = "static inline" + ) -> Iterator[tuple[str, str]]: + assert isinstance(preamble_info.kernel.target, CFamilyTarget) + integer_type_names = ["int8", "int16", "int32", "int64"] def_integer_types_macro = ("03_def_integer_types", r""" @@ -333,7 +338,7 @@ def _preamble_generator(preamble_info, func_qualifier="inline"): }""") yield (f"07_{func.c_name}", f""" - inline {res_ctype} {func.c_name}({base_ctype} x, {exp_ctype} n) {{ + static inline {res_ctype} {func.c_name}({base_ctype} x, {exp_ctype} n) {{ if (n == 0) return 1; {re.sub(r"^", 14*" ", signed_exponent_preamble, flags=re.M)} @@ -778,7 +783,7 @@ def generate_preambles(self, target): dtype = self.arg_id_to_dtype[0] ctype = target.dtype_to_typename(dtype) yield (f"08_c_{self.name_in_target}", f""" - inline static int {self.name_in_target}({ctype} x) {{ + static inline static int {self.name_in_target}({ctype} x) {{ return 0; }}""") @@ -877,7 +882,7 @@ class CFamilyASTBuilder(ASTBuilderBase[Generable]): target: CFamilyTarget - preamble_function_qualifier: ClassVar[str] = "inline" + preamble_function_qualifier: ClassVar[str] = "static inline" # {{{ library