def _op_fgeneric_Round(self, args): if self._vector_size is not None: rm = { 'RM': claripy.fp.RM.RM_TowardsNegativeInf, 'RP': claripy.fp.RM.RM_TowardsPositiveInf, 'RN': claripy.fp.RM.RM_NearestTiesEven, 'RZ': claripy.fp.RM.RM_TowardsZero, }[self._rounding_mode] rounded = [] for i in reversed(range(self._vector_count)): #pylint:disable=no-member left = claripy.Extract((i + 1) * self._vector_size - 1, i * self._vector_size, args[0]).raw_to_fp() rounded.append(claripy.fpToSBV(rm, left, self._vector_size)) return claripy.Concat(*rounded) else: # note: this a bad solution because it will cut off high values # TODO: look into fixing this rm = self._translate_rm(args[0]) rounded_bv = claripy.fpToSBV(rm, args[1].raw_to_fp(), args[1].length) return claripy.fpToFP(claripy.fp.RM.RM_NearestTiesEven, rounded_bv, claripy.fp.FSort.from_size(args[1].length))
def _op_fp_to_int(self, args): rm = self._translate_rm(args[0]) arg = args[1].raw_to_fp() if self._to_signed == 'S': return claripy.fpToSBV(rm, arg, self._to_size) else: return claripy.fpToUBV(rm, arg, self._to_size)
def _op_fgeneric_Round(self, args): if self._vector_size is not None: rm = { 'RM': claripy.fp.RM_RTN, 'RP': claripy.fp.RM_RTP, 'RN': claripy.fp.RM_RNE, 'RZ': claripy.fp.RM_RTZ, }[self._rounding_mode] rounded = [] for i in reversed(range(self._vector_count)): left = claripy.Extract((i+1) * self._vector_size - 1, i * self._vector_size, args[0]).raw_to_fp() rounded.append(claripy.fpToSBV(rm, left, self._vector_size)) return claripy.Concat(*rounded) else: # note: this a bad solution because it will cut off high values # TODO: look into fixing this rm = self._translate_rm(args[0]) rounded_bv = claripy.fpToSBV(rm, args[1].raw_to_fp(), args[1].length) return claripy.fpToFP(claripy.fp.RM_RNE, rounded_bv, claripy.FSort.from_size(args[1].length))
def _op_fgeneric_Round(self, args): if self._vector_size is not None: rm = { 'RM': claripy.fp.RM_RTN, 'RP': claripy.fp.RM_RTP, 'RN': claripy.fp.RM_RNE, 'RZ': claripy.fp.RM_RTZ, }[self._rounding_mode] rounded = [] for i in reversed(range(self._vector_count)): left = claripy.Extract((i + 1) * self._vector_size - 1, i * self._vector_size, args[0]).raw_to_fp() rounded.append(claripy.fpToSBV(rm, left, self._vector_size)) return claripy.Concat(*rounded) else: # note: this a bad solution because it will cut off high values # TODO: look into fixing this rm = self._translate_rm(args[0]) rounded_bv = claripy.fpToSBV(rm, args[1].raw_to_fp(), args[1].length) return claripy.fpToFP(claripy.fp.RM_RNE, rounded_bv, claripy.FSort.from_size(args[1].length))
def _compute_fp_to_int(self, rm, arg, to_size): if self._to_signed == 'S': return claripy.fpToSBV(rm, arg, to_size) else: return claripy.fpToUBV(rm, arg, to_size)