Skip to content
Snippets Groups Projects
Commit c96a9461 authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Add C function selection for numeric limits functions

parent e5861425
Branches
1 merge request!438Reduction Support
......@@ -3,8 +3,8 @@ from typing import Sequence
from pystencils.backend.ast.expressions import PsCall
from ..functions import CFunction, PsMathFunction, MathFunctions
from ...types import PsIntegerType, PsIeeeFloatType
from ..functions import CFunction, PsMathFunction, MathFunctions, NumericLimitsFunctions
from ...types import PsIntegerType, PsIeeeFloatType, PsScalarType
from .platform import Platform
from ..exceptions import MaterializationError
......@@ -62,7 +62,10 @@ class GenericCpu(Platform):
dtype = call.get_dtype()
arg_types = (dtype,) * func.num_args
# TODO: numeric limits
if isinstance(dtype, PsScalarType) and func in (NumericLimitsFunctions.Min, NumericLimitsFunctions.Max):
cfunc = CFunction(f"{dtype.c_string()}_{func.function_name}".capitalize(), arg_types, dtype)
call.function = cfunc
return call
if isinstance(dtype, PsIeeeFloatType) and dtype.width in (32, 64):
cfunc: CFunction
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment