Skip to content

Commit

Permalink
fix rotate functions for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
damienmaier committed Feb 4, 2024
1 parent 6b413c8 commit 22c49dc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
27 changes: 27 additions & 0 deletions accel/tcg/tcg-runtime-sym-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,31 @@ target_ulong get_pc(CPUArchState *env)
cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);

return pc;
}

void *sym_rotate_left(void *arg1_expr, void *arg2_expr) {
/* The implementation follows the alternative implementation of
* tcg_gen_rotl_i64 in tcg-op.c (which handles architectures that don't
* support rotl directly). */

uint8_t bits = _sym_bits_helper(arg1_expr);
return _sym_build_or(
_sym_build_shift_left(arg1_expr, arg2_expr),
_sym_build_logical_shift_right(
arg1_expr,
_sym_build_sub(_sym_build_integer(bits, bits), arg2_expr)));
}

void *sym_rotate_right(void *arg1_expr, void *arg2_expr) {

/* The implementation follows the alternative implementation of
* tcg_gen_rotr_i64 in tcg-op.c (which handles architectures that don't
* support rotr directly). */

uint8_t bits = _sym_bits_helper(arg1_expr);
return _sym_build_or(
_sym_build_logical_shift_right(arg1_expr, arg2_expr),
_sym_build_shift_left(
arg1_expr,
_sym_build_sub(_sym_build_integer(bits, bits), arg2_expr)));
}
4 changes: 3 additions & 1 deletion accel/tcg/tcg-runtime-sym-common.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
void *build_and_push_path_constraint(CPUArchState *env, void *arg1_expr, void *arg2_expr, uint32_t comparison_operator, uint8_t is_taken);
target_ulong get_pc(CPUArchState *env);
target_ulong get_pc(CPUArchState *env);
void *sym_rotate_left(void *arg1_expr, void *arg2_expr);
void *sym_rotate_right(void *arg1_expr, void *arg2_expr);
8 changes: 4 additions & 4 deletions accel/tcg/tcg-runtime-sym-vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ void *HELPER(sym_arithmetic_shift_right_vec)(void *arg1, void *arg1_expr, void *

void *
HELPER(sym_rotate_left_vec)(void *arg1, void *arg1_expr, void *arg2, void *arg2_expr, uint64_t size, uint64_t vece) {
return build_expression_for_vector_vector_op(arg1, arg1_expr, arg2, arg2_expr, size, vece, _sym_build_rotate_left);
return build_expression_for_vector_vector_op(arg1, arg1_expr, arg2, arg2_expr, size, vece, sym_rotate_left);
}

void *
HELPER(sym_rotate_right_vec)(void *arg1, void *arg1_expr, void *arg2, void *arg2_expr, uint64_t size, uint64_t vece) {
return build_expression_for_vector_vector_op(arg1, arg1_expr, arg2, arg2_expr, size, vece, _sym_build_rotate_right);
return build_expression_for_vector_vector_op(arg1, arg1_expr, arg2, arg2_expr, size, vece,sym_rotate_right);
}

void *HELPER(sym_shift_left_vec_int32)(void *arg1, void *arg1_expr, uint32_t arg2, void *arg2_expr, uint64_t size,
Expand All @@ -279,12 +279,12 @@ HELPER(sym_arithmetic_shift_right_vec_int32)(void *arg1, void *arg1_expr, uint32

void *HELPER(sym_rotate_left_vec_int32)(void *arg1, void *arg1_expr, uint32_t arg2, void *arg2_expr, uint64_t size,
uint64_t vece) {
return build_expression_for_vector_int32_op(arg1, arg1_expr, arg2, arg2_expr, size, vece, _sym_build_rotate_left);
return build_expression_for_vector_int32_op(arg1, arg1_expr, arg2, arg2_expr, size, vece,sym_rotate_left);
}

void *HELPER(sym_rotate_right_vec_int32)(void *arg1, void *arg1_expr, uint32_t arg2, void *arg2_expr, uint64_t size,
uint64_t vece) {
return build_expression_for_vector_int32_op(arg1, arg1_expr, arg2, arg2_expr, size, vece, _sym_build_rotate_right);
return build_expression_for_vector_int32_op(arg1, arg1_expr, arg2, arg2_expr, size, vece, sym_rotate_right);
}

/*
Expand Down

0 comments on commit 22c49dc

Please sign in to comment.