[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 27/31] tcg: Add TCG_CALL_RET_BY_VEC
From: |
Richard Henderson |
Subject: |
[PATCH 27/31] tcg: Add TCG_CALL_RET_BY_VEC |
Date: |
Thu, 20 Oct 2022 21:52:38 +1000 |
This will be used by _WIN64 to return i128. Not yet used,
because allocation is not yet enabled. Since this is for
exactly one backend, go ahead and make the few changes needed.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/tcg-internal.h | 1 +
tcg/tcg.c | 17 +++++++++++++++++
tcg/i386/tcg-target.c.inc | 16 +++++++++++++++-
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h
index 1fe7bd7d5d..44ef51ca30 100644
--- a/tcg/tcg-internal.h
+++ b/tcg/tcg-internal.h
@@ -38,6 +38,7 @@ typedef enum {
TCG_CALL_RET_NORMAL, /* by registers */
TCG_CALL_RET_NORMAL_4, /* for i128, by 4 registers */
TCG_CALL_RET_BY_REF, /* for i128, by reference as first arg */
+ TCG_CALL_RET_BY_VEC, /* for i128, by vector register */
} TCGCallReturnKind;
typedef enum {
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 47f1f906fd..2c7eece27f 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -768,6 +768,8 @@ static void init_call_layout(TCGHelperInfo *info)
cum.reg_slot = 1;
}
break;
+ case TCG_CALL_RET_BY_VEC:
+ break;
default:
g_assert_not_reached();
}
@@ -4683,6 +4685,21 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op)
}
break;
+ case TCG_CALL_RET_BY_VEC:
+ {
+ TCGTemp *ts = arg_temp(op->args[0]);
+
+ tcg_debug_assert(ts->type == TCG_TYPE_I128);
+ if (!ts->mem_allocated) {
+ temp_allocate_frame(s, ts);
+ }
+ tcg_out_st(s, TCG_TYPE_V128,
+ tcg_target_call_oarg_reg(TCG_CALL_RET_BY_VEC, 0),
+ ts->mem_base->reg, ts->mem_offset + i * 4);
+ ts->val_type = TEMP_VAL_MEM;
+ }
+ break;
+
default:
g_assert_not_reached();
}
diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc
index 82c8491152..3b4b66c224 100644
--- a/tcg/i386/tcg-target.c.inc
+++ b/tcg/i386/tcg-target.c.inc
@@ -120,6 +120,13 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind
kind, int slot)
return TCG_REG_EDX;
}
break;
+#ifdef _WIN64
+ case TCG_CALL_RET_BY_VEC:
+ if (slot == 0) {
+ return TCG_REG_XMM0;
+ }
+ break;
+#endif
default:
break;
}
@@ -1194,9 +1201,16 @@ static void tcg_out_st(TCGContext *s, TCGType type,
TCGReg arg,
* The gvec infrastructure is asserts that v128 vector loads
* and stores use a 16-byte aligned offset. Validate that the
* final pointer is aligned by using an insn that will SIGSEGV.
+ *
+ * This specific instance is also used by TCG_CALL_RET_BY_VEC,
+ * for _WIN64, which must have SSE2 but may not have AVX.
*/
tcg_debug_assert(arg >= 16);
- tcg_out_vex_modrm_offset(s, OPC_MOVDQA_WxVx, arg, 0, arg1, arg2);
+ if (have_avx1) {
+ tcg_out_vex_modrm_offset(s, OPC_MOVDQA_WxVx, arg, 0, arg1, arg2);
+ } else {
+ tcg_out_modrm_offset(s, OPC_MOVDQA_WxVx, arg, arg1, arg2);
+ }
break;
case TCG_TYPE_V256:
/*
--
2.34.1
- Re: [PATCH 12/31] tcg: Move TCG_TYPE_COUNT outside enum, (continued)
- [PATCH 16/31] tcg: Replace TCG_TARGET_EXTEND_ARGS with TCG_TARGET_CALL_ARG_I32, Richard Henderson, 2022/10/20
- [PATCH 20/31] tcg: Add TCGHelperInfo argument to tcg_out_call, Richard Henderson, 2022/10/20
- [PATCH 25/31] tcg: Add TCG_CALL_{RET,ARG}_BY_REF, Richard Henderson, 2022/10/20
- [PATCH 01/31] tcg: Tidy tcg_reg_alloc_op, Richard Henderson, 2022/10/20
- [PATCH 21/31] tcg: Define TCG_TYPE_I128 and related helper macros, Richard Henderson, 2022/10/20
- [PATCH 02/31] tcg: Introduce paired register allocation, Richard Henderson, 2022/10/20
- [PATCH 19/31] tcg: Move ffi_cif pointer into TCGHelperInfo, Richard Henderson, 2022/10/20
- [PATCH 23/31] tcg: Allocate objects contiguously in temp_allocate_frame, Richard Henderson, 2022/10/20
- [PATCH 18/31] tcg: Reorg function calls, Richard Henderson, 2022/10/20
- [PATCH 27/31] tcg: Add TCG_CALL_RET_BY_VEC,
Richard Henderson <=
- [PATCH 24/31] tcg: Introduce tcg_out_addi_ptr, Richard Henderson, 2022/10/20
- [PATCH 31/31] tcg: Add tcg_gen_extr_i128_i64, tcg_gen_concat_i64_i128, Richard Henderson, 2022/10/20
- [PATCH 17/31] tcg: Use TCG_CALL_ARG_EVEN for TCI special case, Richard Henderson, 2022/10/20
- [PATCH 22/31] tcg: Add TCG_CALL_{RET,ARG}_NORMAL_4, Richard Henderson, 2022/10/20
- [PATCH 30/31] tcg: Add temp allocation for TCGv_i128, Richard Henderson, 2022/10/20
- [PATCH 03/31] tcg/s390x: Use register pair allocation for div and mulu2, Richard Henderson, 2022/10/20
- [PATCH 08/31] target/sparc: Avoid TCGV_{LOW,HIGH}, Richard Henderson, 2022/10/20
- [PATCH 28/31] include/qemu/int128: Use Int128 structure for TCI, Richard Henderson, 2022/10/20
- [PATCH 06/31] tcg: Remove TCG_TARGET_STACK_GROWSUP, Richard Henderson, 2022/10/20