From 0ebd4c333d0deab4a2459750124c6f41a543af96 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 11 May 2023 23:43:41 -0700 Subject: [PATCH] add bfp classification predicates --- src/openpower/decoder/helpers.py | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/openpower/decoder/helpers.py b/src/openpower/decoder/helpers.py index 6d4c6d9a..a6d902df 100644 --- a/src/openpower/decoder/helpers.py +++ b/src/openpower/decoder/helpers.py @@ -843,6 +843,46 @@ def log2(val): return retval +# BFP classification predicates +# these need to be implemented in python because they work with multiple +# input types +def IsInf(v): + if isinstance(v, BFPState): + return onebit(v.class_.Infinity) + # TODO: implement for SelectableInt/int + raise NotImplementedError("not yet implemented for non-BFPState values") + + +def IsNaN(v): + if isinstance(v, BFPState): + return onebit(v.class_.SNaN or v.class_.QNaN) + # TODO: implement for SelectableInt/int + raise NotImplementedError("not yet implemented for non-BFPState values") + + +def IsNeg(v): + if isinstance(v, BFPState): + if v.class_.SNaN or v.class_.QNaN or v.class_.Zero: + return onebit(0) + return onebit(v.sign) + # TODO: implement for SelectableInt/int + raise NotImplementedError("not yet implemented for non-BFPState values") + + +def IsSNaN(v): + if isinstance(v, BFPState): + return onebit(v.class_.SNaN) + # TODO: implement for SelectableInt/int + raise NotImplementedError("not yet implemented for non-BFPState values") + + +def IsZero(v): + if isinstance(v, BFPState): + return onebit(v.class_.Zero) + # TODO: implement for SelectableInt/int + raise NotImplementedError("not yet implemented for non-BFPState values") + + class ISACallerHelper: def __init__(self, XLEN, FPSCR): self.__XLEN = XLEN -- 2.30.2