[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v10 21/31] tcg/loongarch64: Implement tcg_out_call
From: |
WANG Xuerui |
Subject: |
[PATCH v10 21/31] tcg/loongarch64: Implement tcg_out_call |
Date: |
Wed, 15 Dec 2021 20:51:26 +0800 |
Signed-off-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/loongarch64/tcg-target.c.inc | 34 ++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
index 23c151f473..151d3308ea 100644
--- a/tcg/loongarch64/tcg-target.c.inc
+++ b/tcg/loongarch64/tcg-target.c.inc
@@ -532,6 +532,39 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond,
TCGReg arg1,
tcg_out32(s, encode_djsk16_insn(op, arg1, arg2, 0));
}
+static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool
tail)
+{
+ TCGReg link = tail ? TCG_REG_ZERO : TCG_REG_RA;
+ ptrdiff_t offset = tcg_pcrel_diff(s, arg);
+
+ tcg_debug_assert((offset & 3) == 0);
+ if (offset == sextreg(offset, 0, 28)) {
+ /* short jump: +/- 256MiB */
+ if (tail) {
+ tcg_out_opc_b(s, offset >> 2);
+ } else {
+ tcg_out_opc_bl(s, offset >> 2);
+ }
+ } else if (offset == sextreg(offset, 0, 38)) {
+ /* long jump: +/- 256GiB */
+ tcg_target_long lo = sextreg(offset, 0, 18);
+ tcg_target_long hi = offset - lo;
+ tcg_out_opc_pcaddu18i(s, TCG_REG_TMP0, hi >> 18);
+ tcg_out_opc_jirl(s, link, TCG_REG_TMP0, lo >> 2);
+ } else {
+ /* far jump: 64-bit */
+ tcg_target_long lo = sextreg((tcg_target_long)arg, 0, 18);
+ tcg_target_long hi = (tcg_target_long)arg - lo;
+ tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP0, hi);
+ tcg_out_opc_jirl(s, link, TCG_REG_TMP0, lo >> 2);
+ }
+}
+
+static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg)
+{
+ tcg_out_call_int(s, arg, false);
+}
+
/*
* Entry-points
*/
@@ -882,6 +915,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */
case INDEX_op_mov_i64:
+ case INDEX_op_call: /* Always emitted via tcg_out_call. */
default:
g_assert_not_reached();
}
--
2.34.0
- [PATCH v10 10/31] tcg/loongarch64: Implement goto_ptr, (continued)
- [PATCH v10 10/31] tcg/loongarch64: Implement goto_ptr, WANG Xuerui, 2021/12/15
- [PATCH v10 06/31] tcg/loongarch64: Define the operand constraints, WANG Xuerui, 2021/12/15
- [PATCH v10 07/31] tcg/loongarch64: Implement necessary relocation operations, WANG Xuerui, 2021/12/15
- [PATCH v10 08/31] tcg/loongarch64: Implement the memory barrier op, WANG Xuerui, 2021/12/15
- [PATCH v10 11/31] tcg/loongarch64: Implement sign-/zero-extension ops, WANG Xuerui, 2021/12/15
- [PATCH v10 18/31] tcg/loongarch64: Implement mul/mulsh/muluh/div/divu/rem/remu ops, WANG Xuerui, 2021/12/15
- [PATCH v10 16/31] tcg/loongarch64: Implement shl/shr/sar/rotl/rotr ops, WANG Xuerui, 2021/12/15
- [PATCH v10 26/31] tcg/loongarch64: Implement tcg_target_init, WANG Xuerui, 2021/12/15
- [PATCH v10 17/31] tcg/loongarch64: Implement add/sub ops, WANG Xuerui, 2021/12/15
- [PATCH v10 20/31] tcg/loongarch64: Implement setcond ops, WANG Xuerui, 2021/12/15
- [PATCH v10 21/31] tcg/loongarch64: Implement tcg_out_call,
WANG Xuerui <=
- [PATCH v10 23/31] tcg/loongarch64: Add softmmu load/store helpers, implement qemu_ld/qemu_st ops, WANG Xuerui, 2021/12/15
- [PATCH v10 25/31] tcg/loongarch64: Implement exit_tb/goto_tb, WANG Xuerui, 2021/12/15
- [PATCH v10 19/31] tcg/loongarch64: Implement br/brcond ops, WANG Xuerui, 2021/12/15
- [PATCH v10 28/31] common-user: Add safe syscall handling for loongarch64 hosts, WANG Xuerui, 2021/12/15
- [PATCH v10 30/31] configure, meson.build: Mark support for loongarch64 hosts, WANG Xuerui, 2021/12/15
- [PATCH v10 31/31] tests/docker: Add gentoo-loongarch64-cross image and run cross builds in GitLab, WANG Xuerui, 2021/12/15
- [PATCH v10 29/31] linux-user: Implement CPU-specific signal handler for loongarch64 hosts, WANG Xuerui, 2021/12/15
- [PATCH v10 27/31] tcg/loongarch64: Register the JIT, WANG Xuerui, 2021/12/15
- [PATCH v10 14/31] tcg/loongarch64: Implement bswap{16,32,64} ops, WANG Xuerui, 2021/12/15