diff options
| author | ckrinitsin <101062646+ckrinitsin@users.noreply.github.com> | 2025-11-08 09:50:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-08 09:50:56 +0100 |
| commit | b4114d32eab237c1b4f3e96544a40243097bf632 (patch) | |
| tree | 7ce528cfd41990b89a84116721fc65aa7f711da2 /src | |
| parent | baa97641f6b5889b1512c725c1273c38308034ba (diff) | |
| parent | 3659d5cdc2ae42908fcae70ddb16af669027c344 (diff) | |
| download | focaccia-b4114d32eab237c1b4f3e96544a40243097bf632.tar.gz focaccia-b4114d32eab237c1b4f3e96544a40243097bf632.zip | |
Merge pull request #20 from TUM-DSE/ck/x86-cvtps2pd
Add helper to convert single precision to double precision
Diffstat (limited to 'src')
| -rw-r--r-- | src/focaccia/miasm_util.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/focaccia/miasm_util.py b/src/focaccia/miasm_util.py index cacc6e8..c9dc4e5 100644 --- a/src/focaccia/miasm_util.py +++ b/src/focaccia/miasm_util.py @@ -86,10 +86,29 @@ def simp_fsub(expr_simp, expr: ExprOp): return expr_simp(ExprInt(res, expr.size)) return expr +def simp_fpconvert_fp64(expr_simp, expr: ExprOp): + from .utils import float_bits_to_uint, uint_bits_to_float, \ + double_bits_to_uint, uint_bits_to_double + + if expr.op != 'fpconvert_fp64': + return expr + + if not len(expr.args) == 1: + raise NotImplementedError(f'fpconvert_fp64 on number of arguments not in 1: {expr.args}') + + operand = expr.args[0] + if operand.is_int(): + if not operand.size == 32: + raise NotImplementedError(f'fpconvert_fp64 on values of size not in 64: {operand.size}') + + res = double_bits_to_uint(uint_bits_to_double(float_bits_to_uint(operand.arg))) + return expr_simp(ExprInt(res, 64)) + return expr + # The expression simplifier used in this module expr_simp = expr_simp_explicit expr_simp.enable_passes({ - ExprOp: [simp_segm, simp_fadd, simp_fsub], + ExprOp: [simp_segm, simp_fadd, simp_fsub, simp_fpconvert_fp64], }) class MiasmSymbolResolver: |