On 27/9/26 10:59, Richard Henderson wrote:
Signed-off-by: Richard Henderson <[email protected]>
---
include/tcg/tcg-op-common.h | 2 --
include/tcg/tcg-op-def.h.inc | 1 +
tcg/tcg-op.c | 49 ++++++++++++++----------------------
3 files changed, 20 insertions(+), 32 deletions(-)
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 6414b3b627c..4c51428f935 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -786,6 +786,25 @@ void tcg_gen_rotr(TCGType type, TCGTemp *dst, TCGTemp
*src1, TCGTemp *src2)
}
}
+void tcg_gen_rotri(TCGType type, TCGTemp *dst, TCGTemp *src1, int64_t src2)
+{
+ int width = tcg_type_size(type) * 8;
tcg_type_bits()
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
+
+ tcg_debug_assert(src2 >= 0 && src2 < width);
+ if (src2 == 0) {
+ tcg_gen_mov(type, dst, src1);
+ } else if (tcg_op_supported(INDEX_op_rotr, type, 0)) {
+ tcg_gen_op_ttt(INDEX_op_rotr, type, dst, src1,
+ tcg_constant_internal(type, src2));
+ } else if (tcg_op_supported(INDEX_op_rotl, type, 0)) {
+ tcg_gen_op_ttt(INDEX_op_rotl, type, dst, src1,
+ tcg_constant_internal(type, width - src2));
+ } else {
+ /* Do not recurse with the rotri simplification. */
+ tcg_gen_op_ttti(INDEX_op_extract2, type, dst, src1, src1, src2);
+ }
+}