Rizin
unix-like reverse engineering framework and cli tools
theory_bitv.c File Reference

Go to the source code of this file.

Functions

void * rz_il_handler_msb (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_lsb (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_is_zero (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_neg (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_logical_not (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_eq (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_sle (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_ule (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_add (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_append (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_logical_and (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_logical_or (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_logical_xor (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_sub (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_mul (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_div (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_sdiv (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_mod (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_smod (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_shiftl (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_shiftr (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_bitv (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
void * rz_il_handler_cast (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 

Function Documentation

◆ rz_il_handler_add()

void* rz_il_handler_add ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 114 of file theory_bitv.c.

114  {
115  rz_return_val_if_fail(vm && op && type, NULL);
116 
117  RzILOpArgsAdd *op_add = &op->op.add;
118 
119  RzBitVector *x = rz_il_evaluate_bitv(vm, op_add->x);
120  RzBitVector *y = rz_il_evaluate_bitv(vm, op_add->y);
121  RzBitVector *result = x && y ? rz_bv_add(x, y, NULL) : NULL;
122 
123  rz_bv_free(x);
124  rz_bv_free(y);
125 
127  return result;
128 }
#define NULL
Definition: cris-opc.c:27
RZ_API RZ_NULLABLE RZ_OWN RzBitVector * rz_il_evaluate_bitv(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILOpBitVector *op)
Definition: il_vm_eval.c:269
int x
Definition: mipsasm.c:20
int type
Definition: mipsasm.c:17
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API RZ_OWN RzBitVector * rz_bv_add(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *carry)
Definition: bitvector.c:683
RZ_API void rz_bv_free(RZ_NULLABLE RzBitVector *bv)
Definition: bitvector.c:85
@ RZ_IL_TYPE_PURE_BITVECTOR
Definition: sort.h:25
structure for bitvector
Definition: rz_bitvector.h:19
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: rz_il_opcodes.h:97
RzILOpBitVector * x
left operand
Definition: rz_il_opcodes.h:98
RzILOpBitVector * y
right operand
Definition: rz_il_opcodes.h:99
Definition: dis.c:32

References NULL, rz_bv_add(), rz_bv_free(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_append()

void* rz_il_handler_append ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 130 of file theory_bitv.c.

130  {
131  rz_return_val_if_fail(vm && op && type, NULL);
132 
133  RzILOpArgsAppend *op_append = &op->op.append;
134 
135  RzBitVector *high = rz_il_evaluate_bitv(vm, op_append->high);
136  RzBitVector *low = rz_il_evaluate_bitv(vm, op_append->low);
137  RzBitVector *result = high && low ? rz_bv_append(high, low) : NULL;
138  rz_bv_free(low);
139  rz_bv_free(high);
140 
142  return result;
143 }
RZ_API RZ_OWN RzBitVector * rz_bv_append(RZ_NONNULL RzBitVector *bv1, RZ_NONNULL RzBitVector *bv2)
Definition: bitvector.c:326
op structure for appending 2 bitv: MSB:LSB high:low
RzILOpBitVector * low
bitvector occupying the least significant bits
RzILOpBitVector * high
bitvector occupying the most significant bits

References rz_il_op_args_append_t::high, rz_il_op_args_append_t::low, NULL, rz_bv_append(), rz_bv_free(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, and type.

◆ rz_il_handler_bitv()

void* rz_il_handler_bitv ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 336 of file theory_bitv.c.

336  {
337  rz_return_val_if_fail(vm && op && type, NULL);
338  RzILOpArgsBv *op_bitv = &op->op.bitv;
339 
340  RzBitVector *bv = rz_bv_dup(op_bitv->value);
341 
343  return bv;
344 }
RZ_API RZ_OWN RzBitVector * rz_bv_dup(const RZ_NONNULL RzBitVector *bv)
Definition: bitvector.c:167
value is a bitvector constant.
Definition: rz_il_opcodes.h:51
RzBitVector * value
value of bitvector
Definition: rz_il_opcodes.h:52

References NULL, rz_bv_dup(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, and rz_il_op_args_bv_t::value.

◆ rz_il_handler_cast()

void* rz_il_handler_cast ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 346 of file theory_bitv.c.

346  {
347  rz_return_val_if_fail(vm && op && type, NULL);
348 
349  RzILOpArgsCast *op_cast = &op->op.cast;
350  RzILBool *fill = rz_il_evaluate_bool(vm, op_cast->fill);
351  if (!fill) {
352  return NULL;
353  }
354  RzBitVector *bv = rz_il_evaluate_bitv(vm, op_cast->val);
355  if (!bv) {
356  return NULL;
357  }
358 
359  RzBitVector *ret = rz_bv_new(op_cast->length);
360  rz_bv_set_all(ret, fill->b);
361  rz_bv_copy_nbits(bv, 0, ret, 0, RZ_MIN(bv->len, ret->len));
362 
363  rz_il_bool_free(fill);
364  rz_bv_free(bv);
365 
367  return ret;
368 }
RZ_API void rz_il_bool_free(RzILBool *bool_var)
Definition: bool.c:74
RZ_API RZ_NULLABLE RZ_OWN RzILBool * rz_il_evaluate_bool(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILOpBool *op)
Definition: il_vm_eval.c:289
RZ_API bool rz_bv_set_all(RZ_NONNULL RzBitVector *bv, bool b)
Definition: bitvector.c:367
RZ_API RZ_OWN RzBitVector * rz_bv_new(ut32 length)
Definition: bitvector.c:71
RZ_API ut32 rz_bv_copy_nbits(RZ_NONNULL const RzBitVector *src, ut32 src_start_pos, RZ_NONNULL RzBitVector *dst, ut32 dst_start_pos, ut32 nbit)
Definition: bitvector.c:210
#define RZ_MIN(x, y)
ut32 len
number of bits – virtual / logical
Definition: rz_bitvector.h:25
bool b
Definition: bool.h:15
op structure for casting bitv
RzILOpBool * fill
If m = size val - length > 0 then m fill-bits are prepended to the most significant part of the vecto...
RzILOpBitVector * val
value to cast
ut32 length
new bits length

References rz_il_bool_t::b, rz_il_op_args_cast_t::fill, bitvector_t::len, rz_il_op_args_cast_t::length, NULL, rz_bv_copy_nbits(), rz_bv_free(), rz_bv_new(), rz_bv_set_all(), rz_il_bool_free(), rz_il_evaluate_bitv(), rz_il_evaluate_bool(), RZ_IL_TYPE_PURE_BITVECTOR, RZ_MIN, rz_return_val_if_fail, type, and rz_il_op_args_cast_t::val.

◆ rz_il_handler_div()

void* rz_il_handler_div ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 221 of file theory_bitv.c.

221  {
222  rz_return_val_if_fail(vm && op && type, NULL);
223 
224  RzILOpArgsDiv *op_div = &op->op.div;
225 
226  RzBitVector *x = rz_il_evaluate_bitv(vm, op_div->x);
227  RzBitVector *y = rz_il_evaluate_bitv(vm, op_div->y);
228  RzBitVector *result = NULL;
229  if (x && y) {
230  if (rz_bv_is_zero_vector(y)) {
231  result = rz_bv_new(y->len);
232  rz_bv_set_all(result, true);
233  rz_il_vm_event_add(vm, rz_il_event_exception_new("division by zero"));
234  } else {
235  result = rz_bv_div(x, y);
236  }
237  }
238 
239  rz_bv_free(x);
240  rz_bv_free(y);
241 
243  return result;
244 }
RZ_API RZ_OWN RzILEvent * rz_il_event_exception_new(RZ_NONNULL const char *exception)
Definition: il_events.c:52
RZ_API void rz_il_vm_event_add(RzILVM *vm, RzILEvent *evt)
Definition: il_vm_eval.c:201
RZ_API bool rz_bv_is_zero_vector(RZ_NONNULL const RzBitVector *x)
Definition: bitvector.c:1021
RZ_API RZ_OWN RzBitVector * rz_bv_div(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:808

References bitvector_t::len, NULL, rz_bv_div(), rz_bv_free(), rz_bv_is_zero_vector(), rz_bv_new(), rz_bv_set_all(), rz_il_evaluate_bitv(), rz_il_event_exception_new(), RZ_IL_TYPE_PURE_BITVECTOR, rz_il_vm_event_add(), rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_eq()

void* rz_il_handler_eq ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 69 of file theory_bitv.c.

69  {
70  rz_return_val_if_fail(vm && op && type, NULL);
71 
72  RzILOpArgsSle *op_sle = &op->op.sle;
73 
74  RzBitVector *x = rz_il_evaluate_bitv(vm, op_sle->x);
75  RzBitVector *y = rz_il_evaluate_bitv(vm, op_sle->y);
76  RzILBool *result = x && y ? rz_il_bool_new(rz_bv_eq(x, y)) : NULL;
77  rz_bv_free(x);
78  rz_bv_free(y);
79 
81  return result;
82 }
RZ_API RzILBool * rz_il_bool_new(bool true_or_false)
Definition: bool.c:11
RZ_API bool rz_bv_eq(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:1041
@ RZ_IL_TYPE_PURE_BOOL
Definition: sort.h:24
op structure for binary comparison ops ('a bitv -> 'a bitv -> bool)
RzILOpBitVector * x
index of operand 1
RzILOpBitVector * y
index of operand 2

References NULL, rz_bv_eq(), rz_bv_free(), rz_il_bool_new(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BOOL, rz_return_val_if_fail, type, x, rz_il_op_args_cmp_t::x, and rz_il_op_args_cmp_t::y.

◆ rz_il_handler_is_zero()

void* rz_il_handler_is_zero ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 31 of file theory_bitv.c.

31  {
32  rz_return_val_if_fail(vm && op && type, NULL);
33 
34  RzILOpArgsLsb *op_lsb = &op->op.lsb;
35  RzBitVector *bv = rz_il_evaluate_bitv(vm, op_lsb->bv);
36  RzILBool *result = bv ? rz_il_bool_new(rz_bv_is_zero_vector(bv)) : NULL;
37  rz_bv_free(bv);
38 
40  return result;
41 }
op structure for 's bitv -> bool [MSB] msb x is the most significant bit of x. [LSB] lsb x is the lea...
Definition: rz_il_opcodes.h:61
RzILOpBitVector * bv
Definition: rz_il_opcodes.h:62

References rz_il_op_args_un_bv_b_t::bv, NULL, rz_bv_free(), rz_bv_is_zero_vector(), rz_il_bool_new(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BOOL, rz_return_val_if_fail, and type.

◆ rz_il_handler_logical_and()

void* rz_il_handler_logical_and ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 145 of file theory_bitv.c.

145  {
146  rz_return_val_if_fail(vm && op && type, NULL);
147 
148  RzILOpArgsAdd *op_add = &op->op.add;
149 
150  RzBitVector *x = rz_il_evaluate_bitv(vm, op_add->x);
151  RzBitVector *y = rz_il_evaluate_bitv(vm, op_add->y);
152  RzBitVector *result = x && y ? rz_bv_and(x, y) : NULL;
153  rz_bv_free(x);
154  rz_bv_free(y);
155 
157  return result;
158 }
RZ_API RZ_OWN RzBitVector * rz_bv_and(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:546

References NULL, rz_bv_and(), rz_bv_free(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_logical_not()

void* rz_il_handler_logical_not ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 56 of file theory_bitv.c.

56  {
57  rz_return_val_if_fail(vm && op && type, NULL);
58 
59  RzILOpArgsLogNot *op_not = &op->op.lognot;
60 
61  RzBitVector *bv = rz_il_evaluate_bitv(vm, op_not->bv);
62  RzBitVector *result = bv ? rz_bv_not(bv) : NULL;
63  rz_bv_free(bv);
64 
66  return result;
67 }
#define rz_bv_not
Definition: rz_bitvector.h:59
RzILOpBitVector * bv
unary operand
Definition: rz_il_opcodes.h:77

References rz_il_op_args_bv_unop_t::bv, NULL, rz_bv_free(), rz_bv_not, rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, and type.

◆ rz_il_handler_logical_or()

void* rz_il_handler_logical_or ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 160 of file theory_bitv.c.

160  {
161  rz_return_val_if_fail(vm && op && type, NULL);
162 
163  RzILOpArgsAdd *op_add = &op->op.add;
164 
165  RzBitVector *x = rz_il_evaluate_bitv(vm, op_add->x);
166  RzBitVector *y = rz_il_evaluate_bitv(vm, op_add->y);
167  RzBitVector *result = x && y ? rz_bv_or(x, y) : NULL;
168  rz_bv_free(x);
169  rz_bv_free(y);
170 
172  return result;
173 }
RZ_API RZ_OWN RzBitVector * rz_bv_or(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:573

References NULL, rz_bv_free(), rz_bv_or(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_logical_xor()

void* rz_il_handler_logical_xor ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 175 of file theory_bitv.c.

175  {
176  rz_return_val_if_fail(vm && op && type, NULL);
177 
178  RzILOpArgsAdd *op_add = &op->op.add;
179 
180  RzBitVector *x = rz_il_evaluate_bitv(vm, op_add->x);
181  RzBitVector *y = rz_il_evaluate_bitv(vm, op_add->y);
182  RzBitVector *result = x && y ? rz_bv_xor(x, y) : NULL;
183  rz_bv_free(x);
184  rz_bv_free(y);
185 
187  return result;
188 }
RZ_API RZ_OWN RzBitVector * rz_bv_xor(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:600

References NULL, rz_bv_free(), rz_bv_xor(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_lsb()

void* rz_il_handler_lsb ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 19 of file theory_bitv.c.

19  {
20  rz_return_val_if_fail(vm && op && type, NULL);
21 
22  RzILOpArgsLsb *op_lsb = &op->op.lsb;
23  RzBitVector *bv = rz_il_evaluate_bitv(vm, op_lsb->bv);
24  RzILBool *result = bv ? rz_il_bool_new(rz_bv_lsb(bv)) : NULL;
25  rz_bv_free(bv);
26 
28  return result;
29 }
RZ_API bool rz_bv_lsb(RZ_NONNULL RzBitVector *bv)
Definition: bitvector.c:1012

References rz_il_op_args_un_bv_b_t::bv, NULL, rz_bv_free(), rz_bv_lsb(), rz_il_bool_new(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BOOL, rz_return_val_if_fail, and type.

◆ rz_il_handler_mod()

void* rz_il_handler_mod ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 261 of file theory_bitv.c.

261  {
262  rz_return_val_if_fail(vm && op && type, NULL);
263 
264  RzILOpArgsMod *op_mod = &op->op.mod;
265 
266  RzBitVector *x = rz_il_evaluate_bitv(vm, op_mod->x);
267  RzBitVector *y = rz_il_evaluate_bitv(vm, op_mod->y);
268  RzBitVector *result = x && y ? rz_bv_mod(x, y) : NULL;
269  rz_bv_free(x);
270  rz_bv_free(y);
271 
273  return result;
274 }
RZ_API RZ_OWN RzBitVector * rz_bv_mod(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:865

References NULL, rz_bv_free(), rz_bv_mod(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_msb()

void* rz_il_handler_msb ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 7 of file theory_bitv.c.

7  {
9 
10  RzILOpArgsMsb *op_msb = &op->op.msb;
11  RzBitVector *bv = rz_il_evaluate_bitv(vm, op_msb->bv);
12  RzILBool *result = bv ? rz_il_bool_new(rz_bv_msb(bv)) : NULL;
13  rz_bv_free(bv);
14 
16  return result;
17 }
RZ_API bool rz_bv_msb(RZ_NONNULL RzBitVector *bv)
Definition: bitvector.c:1003

References rz_il_op_args_un_bv_b_t::bv, NULL, rz_bv_free(), rz_bv_msb(), rz_il_bool_new(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BOOL, rz_return_val_if_fail, and type.

◆ rz_il_handler_mul()

void* rz_il_handler_mul ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 205 of file theory_bitv.c.

205  {
206  rz_return_val_if_fail(vm && op && type, NULL);
207 
208  RzILOpArgsMul *op_mul = &op->op.mul;
209 
210  RzBitVector *x = rz_il_evaluate_bitv(vm, op_mul->x);
211  RzBitVector *y = rz_il_evaluate_bitv(vm, op_mul->y);
212  RzBitVector *result = x && y ? rz_bv_mul(x, y) : NULL;
213 
214  rz_bv_free(x);
215  rz_bv_free(y);
216 
218  return result;
219 }
RZ_API RZ_OWN RzBitVector * rz_bv_mul(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:734

References NULL, rz_bv_free(), rz_bv_mul(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_neg()

void* rz_il_handler_neg ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 43 of file theory_bitv.c.

43  {
44  rz_return_val_if_fail(vm && op && type, NULL);
45 
46  RzILOpArgsNeg *neg = &op->op.neg;
47 
48  RzBitVector *bv_arg = rz_il_evaluate_bitv(vm, neg->bv);
49  RzBitVector *bv_result = bv_arg ? rz_bv_neg(bv_arg) : NULL;
50  rz_bv_free(bv_arg);
51 
53  return bv_result;
54 }
static ut32 neg(ArmOp *op)
Definition: armass64.c:981
#define rz_bv_neg
Definition: rz_bitvector.h:58

References neg(), NULL, rz_bv_free(), rz_bv_neg, rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, and type.

◆ rz_il_handler_sdiv()

void* rz_il_handler_sdiv ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 246 of file theory_bitv.c.

246  {
247  rz_return_val_if_fail(vm && op && type, NULL);
248 
249  RzILOpArgsSdiv *op_sdiv = &op->op.sdiv;
250 
251  RzBitVector *x = rz_il_evaluate_bitv(vm, op_sdiv->x);
252  RzBitVector *y = rz_il_evaluate_bitv(vm, op_sdiv->y);
253  RzBitVector *result = x && y ? rz_bv_sdiv(x, y) : NULL;
254  rz_bv_free(x);
255  rz_bv_free(y);
256 
258  return result;
259 }
RZ_API RZ_OWN RzBitVector * rz_bv_sdiv(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:893

References NULL, rz_bv_free(), rz_bv_sdiv(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_shiftl()

void* rz_il_handler_shiftl ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 291 of file theory_bitv.c.

291  {
292  rz_return_val_if_fail(vm && op && type, NULL);
293 
294  RzILOpArgsShiftLeft *op_shiftl = &op->op.shiftl;
295 
296  RzBitVector *bv = rz_il_evaluate_bitv(vm, op_shiftl->x);
297  RzBitVector *shift = rz_il_evaluate_bitv(vm, op_shiftl->y);
298  RzILBool *fill_bit = rz_il_evaluate_bool(vm, op_shiftl->fill_bit);
299 
300  RzBitVector *result = NULL;
301  if (bv && shift && fill_bit) {
302  result = rz_bv_dup(bv);
303  rz_bv_lshift_fill(result, rz_bv_to_ut32(shift), fill_bit->b);
304  }
305  rz_bv_free(shift);
306  rz_bv_free(bv);
307  rz_il_bool_free(fill_bit);
308 
310  return result;
311 }
static RZ_NULLABLE RzILOpBitVector * shift(RzILOpBitVector *val, RZ_NULLABLE RzILOpBool **carry_out, arm_shifter type, RZ_OWN RzILOpBitVector *dist)
Definition: arm_il32.c:190
RZ_API bool rz_bv_lshift_fill(RZ_NONNULL RzBitVector *bv, ut32 size, bool fill_bit)
Definition: bitvector.c:469
RZ_API ut32 rz_bv_to_ut32(RZ_NONNULL const RzBitVector *x)
Definition: bitvector.c:1435
op structure for lshift and rshift (bool -> 's bitv -> 'b bitv -> 's bitv)
RzILOpBitVector * x
index of operand 1
RzILOpBitVector * y
index of operand 2
RzILOpBool * fill_bit
index of fill bit

References rz_il_bool_t::b, rz_il_op_args_shift_t::fill_bit, NULL, rz_bv_dup(), rz_bv_free(), rz_bv_lshift_fill(), rz_bv_to_ut32(), rz_il_bool_free(), rz_il_evaluate_bitv(), rz_il_evaluate_bool(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, shift(), type, rz_il_op_args_shift_t::x, and rz_il_op_args_shift_t::y.

◆ rz_il_handler_shiftr()

void* rz_il_handler_shiftr ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 313 of file theory_bitv.c.

313  {
314  rz_return_val_if_fail(vm && op && type, NULL);
315 
316  RzILOpArgsShiftRight *op_shr = &op->op.shiftr;
317 
318  RzBitVector *bv = rz_il_evaluate_bitv(vm, op_shr->x);
319  RzBitVector *shift = rz_il_evaluate_bitv(vm, op_shr->y);
320  RzILBool *fill_bit = rz_il_evaluate_bool(vm, op_shr->fill_bit);
321 
322  RzBitVector *result = NULL;
323  if (bv && shift && fill_bit) {
324  result = rz_bv_dup(bv);
325  rz_bv_rshift_fill(result, rz_bv_to_ut32(shift), fill_bit->b);
326  }
327 
328  rz_bv_free(shift);
329  rz_bv_free(bv);
330  rz_il_bool_free(fill_bit);
331 
333  return result;
334 }
RZ_API bool rz_bv_rshift_fill(RZ_NONNULL RzBitVector *bv, ut32 size, bool fill_bit)
Definition: bitvector.c:508

References rz_il_bool_t::b, rz_il_op_args_shift_t::fill_bit, NULL, rz_bv_dup(), rz_bv_free(), rz_bv_rshift_fill(), rz_bv_to_ut32(), rz_il_bool_free(), rz_il_evaluate_bitv(), rz_il_evaluate_bool(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, shift(), type, rz_il_op_args_shift_t::x, and rz_il_op_args_shift_t::y.

◆ rz_il_handler_sle()

void* rz_il_handler_sle ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 84 of file theory_bitv.c.

84  {
85  rz_return_val_if_fail(vm && op && type, NULL);
86 
87  RzILOpArgsSle *op_sle = &op->op.sle;
88 
89  RzBitVector *x = rz_il_evaluate_bitv(vm, op_sle->x);
90  RzBitVector *y = rz_il_evaluate_bitv(vm, op_sle->y);
91  RzILBool *result = x && y ? rz_il_bool_new(rz_bv_sle(x, y)) : NULL;
92  rz_bv_free(x);
93  rz_bv_free(y);
94 
96  return result;
97 }
RZ_API bool rz_bv_sle(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:1064

References NULL, rz_bv_free(), rz_bv_sle(), rz_il_bool_new(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BOOL, rz_return_val_if_fail, type, x, rz_il_op_args_cmp_t::x, and rz_il_op_args_cmp_t::y.

◆ rz_il_handler_smod()

void* rz_il_handler_smod ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 276 of file theory_bitv.c.

276  {
277  rz_return_val_if_fail(vm && op && type, NULL);
278 
279  RzILOpArgsSmod *op_smod = &op->op.smod;
280 
281  RzBitVector *x = rz_il_evaluate_bitv(vm, op_smod->x);
282  RzBitVector *y = rz_il_evaluate_bitv(vm, op_smod->y);
283  RzBitVector *result = x && y ? rz_bv_smod(x, y) : NULL;
284  rz_bv_free(x);
285  rz_bv_free(y);
286 
288  return result;
289 }
RZ_API RZ_OWN RzBitVector * rz_bv_smod(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:952

References NULL, rz_bv_free(), rz_bv_smod(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_sub()

void* rz_il_handler_sub ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 190 of file theory_bitv.c.

190  {
191  rz_return_val_if_fail(vm && op && type, NULL);
192 
193  RzILOpArgsSub *op_sub = &op->op.sub;
194 
195  RzBitVector *x = rz_il_evaluate_bitv(vm, op_sub->x);
196  RzBitVector *y = rz_il_evaluate_bitv(vm, op_sub->y);
197  RzBitVector *result = x && y ? rz_bv_sub(x, y, NULL) : NULL;
198  rz_bv_free(x);
199  rz_bv_free(y);
200 
202  return result;
203 }
RZ_API RZ_OWN RzBitVector * rz_bv_sub(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y, RZ_NULLABLE bool *borrow)
Definition: bitvector.c:715

References NULL, rz_bv_free(), rz_bv_sub(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_return_val_if_fail, type, x, rz_il_op_args_alg_log_operations_t::x, and rz_il_op_args_alg_log_operations_t::y.

◆ rz_il_handler_ule()

void* rz_il_handler_ule ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 99 of file theory_bitv.c.

99  {
100  rz_return_val_if_fail(vm && op && type, NULL);
101 
102  RzILOpArgsUle *op_ule = &op->op.ule;
103 
104  RzBitVector *x = rz_il_evaluate_bitv(vm, op_ule->x);
105  RzBitVector *y = rz_il_evaluate_bitv(vm, op_ule->y);
106  RzILBool *result = x && y ? rz_il_bool_new(rz_bv_ule(x, y)) : NULL;
107  rz_bv_free(x);
108  rz_bv_free(y);
109 
111  return result;
112 }
RZ_API bool rz_bv_ule(RZ_NONNULL RzBitVector *x, RZ_NONNULL RzBitVector *y)
Definition: bitvector.c:1052

References NULL, rz_bv_free(), rz_bv_ule(), rz_il_bool_new(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BOOL, rz_return_val_if_fail, type, x, rz_il_op_args_cmp_t::x, and rz_il_op_args_cmp_t::y.