Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions librz/arch/isa/arm/arm_il32.c
Original file line number Diff line number Diff line change
Expand Up @@ -3682,9 +3682,9 @@ static RzILOpEffect *try_as_int_cvt(cs_insn *insn, bool is_thumb, bool *success)
// VCVT.F32.S32/U32 <Sd>, <Sm>
RzILOpBitVector *from_val;
if (is_f2i) {
from_val = is_signed ? F2SINT(bv_sz, RZ_FLOAT_RMODE_RTZ,
from_val = is_signed ? F2SINT(bv_sz, RZ_FLOAT_RMODE_RTZ, RZ_FLOAT_CAST_OOB_SATURATE,
BV2F(from_fmt, REG(1)))
: F2INT(bv_sz, RZ_FLOAT_RMODE_RTZ,
: F2INT(bv_sz, RZ_FLOAT_RMODE_RTZ, RZ_FLOAT_CAST_OOB_SATURATE,
BV2F(from_fmt, REG(1)));
} else {
from_val = is_signed ? F2BV(SINT2F(to_fmt, RZ_FLOAT_RMODE_RNE,
Expand All @@ -3700,10 +3700,10 @@ static RzILOpEffect *try_as_int_cvt(cs_insn *insn, bool is_thumb, bool *success)
for (int i = 0; i < REG_WIDTH(0) / bv_sz; ++i) {
RzILOpBitVector *from_val;
if (is_f2i) {
from_val = is_signed ? F2SINT(bv_sz, RZ_FLOAT_RMODE_RTZ,
from_val = is_signed ? F2SINT(bv_sz, RZ_FLOAT_RMODE_RTZ, RZ_FLOAT_CAST_OOB_SATURATE,
BV2F(from_fmt,
read_reg_lane(REGID(1), i, fl_sz)))
: F2INT(bv_sz, RZ_FLOAT_RMODE_RTZ,
: F2INT(bv_sz, RZ_FLOAT_RMODE_RTZ, RZ_FLOAT_CAST_OOB_SATURATE,
BV2F(from_fmt,
read_reg_lane(REGID(1), i, fl_sz)));
} else {
Expand Down
8 changes: 4 additions & 4 deletions librz/arch/isa/hexagon/hexagon_il.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
#define HEX_FCIRC_ADD(bundle, RxV, offset, mu, CS) hex_fcircadd(bundle, RxV, offset, mu, CS)
#define HEX_GET_CORRESPONDING_CS(pkt, Mu) hex_get_corresponding_cs(pkt, Mu)
#define HEX_GET_INSN_RMODE(insn) (insn->fround_mode)
#define HEX_D_TO_SINT(mode, fval) F2SINT(64, mode, fval)
#define HEX_F_TO_SINT(mode, fval) F2SINT(32, mode, fval)
#define HEX_D_TO_INT(mode, fval) F2INT(64, mode, fval)
#define HEX_F_TO_INT(mode, fval) F2INT(32, mode, fval)
#define HEX_D_TO_SINT(mode, fval) F2SINT(64, mode, RZ_FLOAT_CAST_OOB_TRUNCATE, fval)
#define HEX_F_TO_SINT(mode, fval) F2SINT(32, mode, RZ_FLOAT_CAST_OOB_TRUNCATE, fval)
#define HEX_D_TO_INT(mode, fval) F2INT(64, mode, RZ_FLOAT_CAST_OOB_TRUNCATE, fval)
#define HEX_F_TO_INT(mode, fval) F2INT(32, mode, RZ_FLOAT_CAST_OOB_TRUNCATE, fval)
#define HEX_SINT_TO_D(mode, fval) SINT2F(64, mode, fval)
#define HEX_SINT_TO_F(mode, fval) SINT2F(32, mode, fval)
#define HEX_INT_TO_D(mode, fval) INT2F(64, mode, fval)
Expand Down
2 changes: 1 addition & 1 deletion librz/arch/isa/sparc/sparc_il_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ static RzILOpEffect *convert_float_op(const csh handle, const cs_insn *insn, con
case SPARC_INS_FDTOX:
case SPARC_INS_FQTOX:
case SPARC_INS_FSTOX:
return rz_sparc_bv_to_consec_regs(handle, mode, dst, F2INT(dst_width, SPARC_RMODE(), src0), dst_width);
return rz_sparc_bv_to_consec_regs(handle, mode, dst, F2INT(dst_width, SPARC_RMODE(), RZ_FLOAT_CAST_OOB_TRUNCATE, src0), dst_width);
// BitVector to Float
case SPARC_INS_FITOS:
case SPARC_INS_FXTOS:
Expand Down
5 changes: 3 additions & 2 deletions librz/arch/isa/tricore/tricore_il_fp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static const ut32 HP_NEG_INFINITY = 0xfc00;
/// This represents all negative numbers with an absolute value that is too big to be represented accurately as a normalized number.
static const ut32 HP_POS_INFINITY = 0x7c00;

#define F2SINT32(x, m) F2SINT(32, m, x)
#define F2SINT32(x, m) F2SINT(32, m, RZ_FLOAT_CAST_OOB_TRUNCATE, x)

#define denorm_to_zere_(T, x) \
LET("tmp", x, \
Expand Down Expand Up @@ -83,7 +83,8 @@ static inline RzILOpEffect *q_real_set_v(const char *k, RzILOpPure *x) {

#define FCAST32(f, _1, x, mode) FCAST_(f, _1, x, mode, F32(0))
#define FCAST64(f, _1, x, mode) FCAST_(f, _1, x, mode, F64(0))
#define round_to_integer(x, m) FCAST_(F2SINT, 32, x, m, U32(UT32_MAX))
#define F2SINT_TRUNC(_1, rmode, x) F2SINT(_1, rmode, RZ_FLOAT_CAST_OOB_TRUNCATE, x)
#define round_to_integer(x, m) FCAST_(F2SINT_TRUNC, 32, x, m, U32(UT32_MAX))

static RzILOpPure *minmax(const char *k, st64 min, st64 max, RzILOpPure *x) {
return ITE(IS_FNAN(VARL(k)),
Expand Down
4 changes: 2 additions & 2 deletions librz/arch/isa/v810/v810_il.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ static RzILOpPure *bv2f32(RzILOpPure *x) {
}

static RzILOpPure *f32_2int(RzILOpPure *x) {
return F2SINT(32, 0, x);
return F2SINT(32, 0, RZ_FLOAT_CAST_OOB_TRUNCATE, x);
}

static RzILOpPure *f32_trunc2int(RzILOpPure *x) {
return F2SINT(32, 0, FROUND(0, x));
return F2SINT(32, 0, RZ_FLOAT_CAST_OOB_TRUNCATE, FROUND(0, x));
}

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion librz/arch/isa/x86/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ RZ_IPI ILPureEffectPair x86_il_floating_from_int_ctx(RZ_OWN RZ_NONNULL RzILOpBit
}

RzILOpFloat *f2sint_floating_helper(RzFloatRMode rmode, ut32 width, RzILOpFloat *val) {
return F2SINT(width, rmode, val);
return F2SINT(width, rmode, RZ_FLOAT_CAST_OOB_INDEFINITE, val);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion librz/arch/isa/x86/il_sse_ops.inc
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ IL_LIFTER(cvtsi2ss) {
do { \
RzILOpFloat *f = x86_il_get_scalar_floating_op(ins->operands[1], (fmt), analysis->bits, pc); \
ut32 width = ins->operands[0].size * BITS_PER_BYTE; \
return x86_il_set_op(0, F2SINT(width, rmode, f)); \
return x86_il_set_op(0, F2SINT(width, rmode, RZ_FLOAT_CAST_OOB_INDEFINITE, f)); \
} while (0)

/**
Expand Down
8 changes: 4 additions & 4 deletions librz/arch/isa/xtensa/xtensa_il.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ static RzAnalysisLiftedILOp op_callx12(XtensaContext *ctx) {
static RzAnalysisLiftedILOp op_ceil_s(XtensaContext *ctx) {
return SEQ3(
SETL("fres", FMUL(RZ_FLOAT_RMODE_RNA, FLOATV32(IREG(1)), F32(powf(2, IMM(2))))),
SETG(REGN(0), F2INT(32, RZ_FLOAT_RMODE_RNA, VARL("fres"))),
SETG(REGN(0), F2INT(32, RZ_FLOAT_RMODE_RNA, RZ_FLOAT_CAST_OOB_TRUNCATE, VARL("fres"))),
FSR_set(FSR_V | FSR_I, VARL("fres")));
}

Expand Down Expand Up @@ -798,7 +798,7 @@ static RzAnalysisLiftedILOp op_float_s(XtensaContext *ctx) {
static RzAnalysisLiftedILOp op_floor_s(XtensaContext *ctx) {
return SEQ3(
SETL("fres", FMUL(RZ_FLOAT_RMODE_RNA, FLOATV32(IREG(1)), F32(pow(2, IMM(2))))),
SETG(REGN(0), F2SINT(32, RZ_FLOAT_RMODE_RNA, VARL("fres"))),
SETG(REGN(0), F2SINT(32, RZ_FLOAT_RMODE_RNA, RZ_FLOAT_CAST_OOB_TRUNCATE, VARL("fres"))),
FSR_set(FSR_V | FSR_I, VARL("fres")));
}

Expand Down Expand Up @@ -1638,7 +1638,7 @@ static RzAnalysisLiftedILOp op_syscall(XtensaContext *ctx) {
// statusflags: VI
static RzAnalysisLiftedILOp op_trunc_s(XtensaContext *ctx) {
return SEQ3(SETL("fres", FMUL(RZ_FLOAT_RMODE_RNA, FLOATV32(IREG(1)), F32(pow(2, IMM(2))))),
SETG(REGN(0), F2SINT(32, RZ_FLOAT_RMODE_RNA, VARL("fres"))),
SETG(REGN(0), F2SINT(32, RZ_FLOAT_RMODE_RNA, RZ_FLOAT_CAST_OOB_TRUNCATE, VARL("fres"))),
FSR_set(FSR_V | FSR_I, VARL("fres")));
}

Expand Down Expand Up @@ -1682,7 +1682,7 @@ static RzAnalysisLiftedILOp op_un_s(XtensaContext *ctx) {
// statusflags: VI
static RzAnalysisLiftedILOp op_utrunc_s(XtensaContext *ctx) {
return SEQ3(SETL("fres", FMUL(RZ_FLOAT_RMODE_RNA, FLOATV32(IREG(1)), F32(pow(2, IMM(2))))),
SETG(REGN(0), F2INT(32, RZ_FLOAT_RMODE_RNA, VARL("fres"))),
SETG(REGN(0), F2INT(32, RZ_FLOAT_RMODE_RNA, RZ_FLOAT_CAST_OOB_TRUNCATE, VARL("fres"))),
FSR_set(FSR_V | FSR_I, VARL("fres")));
}

Expand Down
2 changes: 2 additions & 0 deletions librz/il/il_export_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ static void il_opdmp_fcast_int(RzILOpPure *op, PJ *pj) {
pj_o(pj);
pj_ks(pj, "opcode", "fcast_int");
pj_kn(pj, "length", opx->length);
pj_kn(pj, "oob_behavior", opx->oob_behavior);
pj_k(pj, "rmode");
il_op_float_rmode_json_resolve(&opx->rmode, pj);
pj_k(pj, "value");
Expand All @@ -366,6 +367,7 @@ static void il_opdmp_fcast_sint(RzILOpPure *op, PJ *pj) {
pj_o(pj);
pj_ks(pj, "opcode", "fcast_sint");
pj_kn(pj, "length", opx->length);
pj_kn(pj, "oob_behavior", opx->oob_behavior);
pj_k(pj, "rmode");
il_op_float_rmode_json_resolve(&opx->rmode, pj);
pj_k(pj, "value");
Expand Down
12 changes: 6 additions & 6 deletions librz/il/il_export_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,19 @@ static void il_opdmp_fabs(RzILOpPure *op, RzStrBuf *sb, int pad) {
static void il_opdmp_fcast_int(RzILOpPure *op, RzStrBuf *sb, int pad) {
RzILOpArgsFCastint *opx = &op->op.fcast_int;
if (pad < 0) {
rz_strbuf_appendf(sb, "(fcast_int %u ", opx->length);
rz_strbuf_appendf(sb, "(fcast_int %u %d ", opx->length, opx->oob_behavior);
il_op_float_rmode_string_resolve(&opx->rmode, sb, pad);
rz_strbuf_append(sb, " ");
il_op_pure_string_resolve(opx->f, sb, pad);
rz_strbuf_append(sb, ")");
} else if (opx->rmode.kind == RZ_IL_OP_ARG_FLOAT_RMODE_STATIC) {
rz_strbuf_appendf(sb, "%*.s(fcast_int %u ", pad, "", opx->length);
rz_strbuf_appendf(sb, "%*.s(fcast_int %u %d ", pad, "", opx->length, opx->oob_behavior);
il_op_float_rmode_string_resolve(&opx->rmode, sb, pad);
rz_strbuf_append(sb, "\n");
il_op_pure_string_resolve(opx->f, sb, pad + PRETTY_PAD);
rz_strbuf_append(sb, ")");
} else {
rz_strbuf_appendf(sb, "%*.s(fcast_int %u\n", pad, "", opx->length);
rz_strbuf_appendf(sb, "%*.s(fcast_int %u %d\n", pad, "", opx->length, opx->oob_behavior);
il_op_float_rmode_string_resolve(&opx->rmode, sb, pad + PRETTY_PAD);
rz_strbuf_append(sb, "\n");
il_op_pure_string_resolve(opx->f, sb, pad + PRETTY_PAD);
Expand All @@ -459,19 +459,19 @@ static void il_opdmp_fcast_int(RzILOpPure *op, RzStrBuf *sb, int pad) {
static void il_opdmp_fcast_sint(RzILOpPure *op, RzStrBuf *sb, int pad) {
RzILOpArgsFCastsint *opx = &op->op.fcast_sint;
if (pad < 0) {
rz_strbuf_appendf(sb, "(fcast_sint %u ", opx->length);
rz_strbuf_appendf(sb, "(fcast_sint %u %d ", opx->length, opx->oob_behavior);
il_op_float_rmode_string_resolve(&opx->rmode, sb, pad);
rz_strbuf_append(sb, " ");
il_op_pure_string_resolve(opx->f, sb, pad);
rz_strbuf_append(sb, ")");
} else if (opx->rmode.kind == RZ_IL_OP_ARG_FLOAT_RMODE_STATIC) {
rz_strbuf_appendf(sb, "%*.s(fcast_sint %u ", pad, "", opx->length);
rz_strbuf_appendf(sb, "%*.s(fcast_sint %u %d ", pad, "", opx->length, opx->oob_behavior);
il_op_float_rmode_string_resolve(&opx->rmode, sb, pad);
rz_strbuf_append(sb, "\n");
il_op_pure_string_resolve(opx->f, sb, pad + PRETTY_PAD);
rz_strbuf_append(sb, ")");
} else {
rz_strbuf_appendf(sb, "%*.s(fcast_sint %u\n", pad, "", opx->length);
rz_strbuf_appendf(sb, "%*.s(fcast_sint %u %d\n", pad, "", opx->length, opx->oob_behavior);
il_op_float_rmode_string_resolve(&opx->rmode, sb, pad + PRETTY_PAD);
rz_strbuf_append(sb, "\n");
il_op_pure_string_resolve(opx->f, sb, pad + PRETTY_PAD);
Expand Down
4 changes: 2 additions & 2 deletions librz/il/il_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static void il_op_graph_fabs(RzILOpPure *op, RzGraph /*<RzGraphNodeInfo *, NULL

static void il_op_graph_fcast_int(RzILOpPure *op, RzGraph /*<RzGraphNodeInfo *, NULL *>*/ *g, RzGraphNode *from) {
RzILOpArgsFCastint *opx = &op->op.fcast_int;
char *value = rz_str_newf("fcast_int: %u", opx->length);
char *value = rz_str_newf("fcast_int: %u %d", opx->length, opx->oob_behavior);
if (!value) {
return;
}
Expand All @@ -321,7 +321,7 @@ static void il_op_graph_fcast_int(RzILOpPure *op, RzGraph /*<RzGraphNodeInfo *,

static void il_op_graph_fcast_sint(RzILOpPure *op, RzGraph /*<RzGraphNodeInfo *, NULL *>*/ *g, RzGraphNode *from) {
RzILOpArgsFCastsint *opx = &op->op.fcast_sint;
char *value = rz_str_newf("fcast_sint: %u", opx->length);
char *value = rz_str_newf("fcast_sint: %u %d", opx->length, opx->oob_behavior);
if (!value) {
return;
}
Expand Down
29 changes: 21 additions & 8 deletions librz/il/il_opcodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@
ret->op.s.v2 = v2; \
} while (0)

#define rz_il_op_new_4(sort, id, t, s, v0, v1, v2, v3) \
do { \
ret = RZ_NEW0(RzILOp##sort); \
if (!ret) { \
return NULL; \
} \
ret->code = id; \
ret->op.s.v0 = v0; \
ret->op.s.v1 = v1; \
ret->op.s.v2 = v2; \
ret->op.s.v3 = v3; \
} while (0)

static RzILOpArgFloatRMode float_rmode_static(RzFloatRMode mode) {
return (RzILOpArgFloatRMode){
.kind = RZ_IL_OP_ARG_FLOAT_RMODE_STATIC,
Expand Down Expand Up @@ -879,19 +892,19 @@ RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fabs(RZ_NONNULL RzILOpFloat *f) {
return ret;
}

RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_int(ut32 length, RzFloatRMode mode, RZ_NONNULL RzILOpFloat *f) {
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_int(ut32 length, RzFloatRMode mode, RzFloatCastOobBehavior oob_behavior, RZ_NONNULL RzILOpFloat *f) {
rz_return_val_if_fail(f, NULL);
RzILOpArgFloatRMode rmode = float_rmode_static(mode);
RzILOpBitVector *ret;
rz_il_op_new_3(BitVector, RZ_IL_OP_FCAST_INT, RzILOpArgsFCastint, fcast_int, length, rmode, f);
rz_il_op_new_4(BitVector, RZ_IL_OP_FCAST_INT, RzILOpArgsFCastint, fcast_int, length, rmode, oob_behavior, f);
return ret;
}

RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_sint(ut32 length, RzFloatRMode mode, RZ_NONNULL RzILOpFloat *f) {
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_sint(ut32 length, RzFloatRMode mode, RzFloatCastOobBehavior oob_behavior, RZ_NONNULL RzILOpFloat *f) {
rz_return_val_if_fail(f, NULL);
RzILOpArgFloatRMode rmode = float_rmode_static(mode);
RzILOpBitVector *ret;
rz_il_op_new_3(BitVector, RZ_IL_OP_FCAST_SINT, RzILOpArgsFCastsint, fcast_sint, length, rmode, f);
rz_il_op_new_4(BitVector, RZ_IL_OP_FCAST_SINT, RzILOpArgsFCastsint, fcast_sint, length, rmode, oob_behavior, f);
return ret;
}

Expand All @@ -911,19 +924,19 @@ RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fcast_sfloat(RzFloatFormat format, RzFlo
return ret;
}

RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_int_dyn_rmode(ut32 length, RZ_NONNULL RzILOpBitVector *mode, RZ_NONNULL RzILOpFloat *f) {
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_int_dyn_rmode(ut32 length, RZ_NONNULL RzILOpBitVector *mode, RzFloatCastOobBehavior oob_behavior, RZ_NONNULL RzILOpFloat *f) {
rz_return_val_if_fail(mode && f, NULL);
RzILOpArgFloatRMode rmode = float_rmode_dynamic(mode);
RzILOpBitVector *ret;
rz_il_op_new_3(BitVector, RZ_IL_OP_FCAST_INT, RzILOpArgsFCastint, fcast_int, length, rmode, f);
rz_il_op_new_4(BitVector, RZ_IL_OP_FCAST_INT, RzILOpArgsFCastint, fcast_int, length, rmode, oob_behavior, f);
return ret;
}

RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_sint_dyn_rmode(ut32 length, RZ_NONNULL RzILOpBitVector *mode, RZ_NONNULL RzILOpFloat *f) {
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_sint_dyn_rmode(ut32 length, RZ_NONNULL RzILOpBitVector *mode, RzFloatCastOobBehavior oob_behavior, RZ_NONNULL RzILOpFloat *f) {
rz_return_val_if_fail(mode && f, NULL);
RzILOpArgFloatRMode rmode = float_rmode_dynamic(mode);
RzILOpBitVector *ret;
rz_il_op_new_3(BitVector, RZ_IL_OP_FCAST_SINT, RzILOpArgsFCastsint, fcast_sint, length, rmode, f);
rz_il_op_new_4(BitVector, RZ_IL_OP_FCAST_SINT, RzILOpArgsFCastsint, fcast_sint, length, rmode, oob_behavior, f);
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions librz/il/theory_fbasic.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void *rz_il_handler_fcast_int(RzILVM *vm, RzILOpPure *op, RzILTypePure *type) {
return NULL;
}
ut32 length = cast_int.length;
RzBitVector *ret = rz_float_cast_int(f, length, mode);
RzBitVector *ret = rz_float_cast_int(f, length, mode, cast_int.oob_behavior);

rz_float_free(f);

Expand All @@ -197,7 +197,7 @@ void *rz_il_handler_fcast_sint(RzILVM *vm, RzILOpPure *op, RzILTypePure *type) {
return NULL;
}
ut32 length = cast_sint.length;
RzBitVector *ret = rz_float_cast_sint(f, length, mode);
RzBitVector *ret = rz_float_cast_sint(f, length, mode, cast_sint.oob_behavior);

rz_float_free(f);

Expand Down
8 changes: 4 additions & 4 deletions librz/include/rz_il/rz_il_opbuilder_begin.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
#define IS_FPOS(fl) rz_il_op_new_is_fpos(fl)
#define FNEG(fl) rz_il_op_new_fneg(fl)
#define FABS(fl) rz_il_op_new_fabs(fl)
#define F2INT(l, rmode, fl) rz_il_op_new_fcast_int(l, rmode, fl)
#define F2SINT(l, rmode, fl) rz_il_op_new_fcast_sint(l, rmode, fl)
#define F2INT(l, rmode, oob, fl) rz_il_op_new_fcast_int(l, rmode, oob, fl)
#define F2SINT(l, rmode, oob, fl) rz_il_op_new_fcast_sint(l, rmode, oob, fl)
#define INT2F(fmt, rmode, bv) rz_il_op_new_fcast_float(fmt, rmode, bv)
#define SINT2F(fmt, rmode, bv) rz_il_op_new_fcast_sfloat(fmt, rmode, bv)
#define F2INT_DYN_RMODE(l, rmode, fl) rz_il_op_new_fcast_int_dyn_rmode(l, rmode, fl)
#define F2SINT_DYN_RMODE(l, rmode, fl) rz_il_op_new_fcast_sint_dyn_rmode(l, rmode, fl)
#define F2INT_DYN_RMODE(l, rmode, oob, fl) rz_il_op_new_fcast_int_dyn_rmode(l, rmode, oob, fl)
#define F2SINT_DYN_RMODE(l, rmode, oob, fl) rz_il_op_new_fcast_sint_dyn_rmode(l, rmode, oob, fl)
#define INT2F_DYN_RMODE(fmt, rmode, bv) rz_il_op_new_fcast_float_dyn_rmode(fmt, rmode, bv)
#define SINT2F_DYN_RMODE(fmt, rmode, bv) rz_il_op_new_fcast_sfloat_dyn_rmode(fmt, rmode, bv)
#define FCONVERT(fmt, rmode, fl) rz_il_op_new_fconvert(fmt, rmode, fl)
Expand Down
9 changes: 5 additions & 4 deletions librz/include/rz_il/rz_il_opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ typedef struct rz_il_op_arg_float_rmode_t {
typedef struct rz_il_op_args_float_cast_int_t {
ut32 length;
RzILOpArgFloatRMode rmode;
RzFloatCastOobBehavior oob_behavior;
RzILOpFloat *f;
} RzILOpArgsFCastInt;

Expand Down Expand Up @@ -818,12 +819,12 @@ RZ_API RZ_OWN RzILOpBool *rz_il_op_new_is_fneg(RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpBool *rz_il_op_new_is_fpos(RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fneg(RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fabs(RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_int(ut32 length, RzFloatRMode mode, RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_sint(ut32 length, RzFloatRMode mode, RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_int(ut32 length, RzFloatRMode mode, RzFloatCastOobBehavior oob_behavior, RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_sint(ut32 length, RzFloatRMode mode, RzFloatCastOobBehavior oob_behavior, RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fcast_float(RzFloatFormat format, RzFloatRMode mode, RZ_NONNULL RzILOpBitVector *bv);
RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fcast_sfloat(RzFloatFormat format, RzFloatRMode mode, RZ_NONNULL RzILOpBitVector *bv);
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_int_dyn_rmode(ut32 length, RZ_NONNULL RzILOpBitVector *rmode, RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_sint_dyn_rmode(ut32 length, RZ_NONNULL RzILOpBitVector *rmode, RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_int_dyn_rmode(ut32 length, RZ_NONNULL RzILOpBitVector *rmode, RzFloatCastOobBehavior oob_behavior, RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpBitVector *rz_il_op_new_fcast_sint_dyn_rmode(ut32 length, RZ_NONNULL RzILOpBitVector *rmode, RzFloatCastOobBehavior oob_behavior, RZ_NONNULL RzILOpFloat *f);
RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fcast_float_dyn_rmode(RzFloatFormat format, RZ_NONNULL RzILOpBitVector *rmode, RZ_NONNULL RzILOpBitVector *bv);
RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fcast_sfloat_dyn_rmode(RzFloatFormat format, RZ_NONNULL RzILOpBitVector *rmode, RZ_NONNULL RzILOpBitVector *bv);
RZ_API RZ_OWN RzILOpFloat *rz_il_op_new_fconvert(RzFloatFormat format, RzFloatRMode mode, RZ_NONNULL RzILOpFloat *f);
Expand Down
10 changes: 8 additions & 2 deletions librz/include/rz_util/rz_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ typedef enum rz_float_round_enum {
RZ_FLOAT_RMODE_UNK ///< end
} RzFloatRMode; ///< Rounding Mode

typedef enum rz_float_cast_oob_behavior_enum {
RZ_FLOAT_CAST_OOB_TRUNCATE, ///< Truncate out of bounds value
RZ_FLOAT_CAST_OOB_SATURATE, ///< Saturate to integer min/max
RZ_FLOAT_CAST_OOB_INDEFINITE, ///< Return the indefinite value (e.g., 0x80..00)
} RzFloatCastOobBehavior;

/** Precision used by SoftFloat binary80 arithmetic. */
typedef enum rz_float_rprecision_enum {
RZ_FLOAT_RPREC_32 = 32, ///< 24-bit significand precision
Expand Down Expand Up @@ -210,8 +216,8 @@ RZ_API RZ_OWN RzFloat *rz_float_new_snan(RzFloatFormat format);

RZ_API RZ_OWN RzFloat *rz_float_cast_float(RZ_NONNULL RzBitVector *bv, RzFloatFormat format, RzFloatRMode mode);
RZ_API RZ_OWN RzFloat *rz_float_cast_sfloat(RZ_NONNULL RzBitVector *bv, RzFloatFormat format, RzFloatRMode mode);
RZ_API RZ_OWN RzBitVector *rz_float_cast_int(RZ_NONNULL RzFloat *f, ut32 length, RzFloatRMode mode);
RZ_API RZ_OWN RzBitVector *rz_float_cast_sint(RZ_NONNULL RzFloat *f, ut32 length, RzFloatRMode mode);
RZ_API RZ_OWN RzBitVector *rz_float_cast_int(RZ_NONNULL RzFloat *f, ut32 length, RzFloatRMode mode, RzFloatCastOobBehavior oob_behavior);
RZ_API RZ_OWN RzBitVector *rz_float_cast_sint(RZ_NONNULL RzFloat *f, ut32 length, RzFloatRMode mode, RzFloatCastOobBehavior oob_behavior);
RZ_API RZ_OWN RzFloat *rz_float_convert(RZ_NONNULL RzFloat *f, RzFloatFormat format, RzFloatRMode mode);
RZ_API RzFloatRPrecision rz_float_ext80_get_rounding_precision(void);
RZ_API bool rz_float_ext80_set_rounding_precision(RzFloatRPrecision precision);
Expand Down
Loading