Signed-off-by: Chao Liu <chao....@yeah.net> --- target/riscv/helper.h | 13 ++++++++++++ target/riscv/op_helper.c | 46 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+)
diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 451261ce5a..667da16988 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -1281,3 +1281,16 @@ DEF_HELPER_4(vgmul_vv, void, ptr, ptr, env, i32) DEF_HELPER_5(vsm4k_vi, void, ptr, ptr, i32, env, i32) DEF_HELPER_4(vsm4r_vv, void, ptr, ptr, env, i32) DEF_HELPER_4(vsm4r_vs, void, ptr, ptr, env, i32) + +DEF_HELPER_1(print1, void, ptr) +DEF_HELPER_2(print2, void, ptr, tl) +DEF_HELPER_3(print3, void, ptr, tl, tl) +DEF_HELPER_4(print4, void, ptr, tl, tl, tl) +DEF_HELPER_5(print5, void, ptr, tl, tl, tl, tl) +DEF_HELPER_6(print6, void, ptr, tl, tl, tl, tl, tl) +DEF_HELPER_7(print7, void, ptr, tl, tl, tl, tl, tl, tl) + +#define gen_helper_print(num, fmt, ...) do { \ + assert(num >= 1 && num <= 7); \ + gen_helper_print##num(tcg_constant_ptr((uintptr_t)fmt), __VA_ARGS__); \ +} while(0) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index eddedacf4b..f45e1b9a50 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -564,3 +564,49 @@ target_ulong helper_hyp_hlvx_wu(CPURISCVState *env, target_ulong addr) } #endif /* !CONFIG_USER_ONLY */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" + +void helper_print1(void *fmt) +{ + printf((const char *)fmt); +} + +void helper_print2(void *fmt, target_ulong arg2) +{ + printf((const char *)fmt, arg2); +} + +void helper_print3(void *fmt, target_ulong arg2, target_ulong arg3) +{ + printf((const char *)fmt, arg2, arg3); +} + +void helper_print4(void *fmt, target_ulong arg2, target_ulong arg3, + target_ulong arg4) +{ + printf((const char *)fmt, arg2, arg3, arg4); +} + +void helper_print5(void *fmt, target_ulong arg2, target_ulong arg3, + target_ulong arg4, target_ulong arg5) +{ + printf((const char *)fmt, arg2, arg3, arg4, arg5); +} + +void helper_print6(void *fmt, target_ulong arg2, target_ulong arg3, + target_ulong arg4, target_ulong arg5, target_ulong arg6) +{ + printf((const char *)fmt, arg2, arg3, arg4, arg5, arg6); +} + +void helper_print7(void *fmt, target_ulong arg2, target_ulong arg3, + target_ulong arg4, target_ulong arg5, target_ulong arg6, + target_ulong arg7) +{ + printf((const char *)fmt, arg2, arg3, arg4, arg5, arg6, arg7); +} + +#pragma GCC diagnostic pop + -- 2.40.1