[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v2 15/39] target/i386: introduce function ck_cpu
From: |
Jan Bobek |
Subject: |
[Qemu-devel] [RFC PATCH v2 15/39] target/i386: introduce function ck_cpuid |
Date: |
Sat, 10 Aug 2019 00:12:31 -0400 |
Introduce a helper function to take care of instruction CPUID checks.
Signed-off-by: Jan Bobek <address@hidden>
---
target/i386/translate.c | 45 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/target/i386/translate.c b/target/i386/translate.c
index 03b49411e5..508d584584 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -4500,6 +4500,51 @@ static void gen_sse(CPUX86State *env, DisasContext *s,
int b)
#define tcg_gen_gvec_cmpgt(vece, dofs, aofs, bofs, oprsz, maxsz) \
tcg_gen_gvec_cmp(TCG_COND_GT, vece, dofs, aofs, bofs, oprsz, maxsz)
+enum {
+ CK_CPUID_MMX = 1,
+ CK_CPUID_3DNOW,
+ CK_CPUID_SSE,
+ CK_CPUID_SSE2,
+ CK_CPUID_SSE3,
+ CK_CPUID_SSSE3,
+ CK_CPUID_SSE4_1,
+ CK_CPUID_SSE4_2,
+ CK_CPUID_SSE4A,
+ CK_CPUID_AVX,
+ CK_CPUID_AVX2,
+};
+
+static int ck_cpuid(CPUX86State *env, DisasContext *s, int ck_cpuid_feat)
+{
+ switch (ck_cpuid_feat) {
+ case CK_CPUID_MMX:
+ return !(s->cpuid_features & CPUID_MMX)
+ || !(s->cpuid_ext2_features & CPUID_EXT2_MMX);
+ case CK_CPUID_3DNOW:
+ return !(s->cpuid_ext2_features & CPUID_EXT2_3DNOW);
+ case CK_CPUID_SSE:
+ return !(s->cpuid_features & CPUID_SSE);
+ case CK_CPUID_SSE2:
+ return !(s->cpuid_features & CPUID_SSE2);
+ case CK_CPUID_SSE3:
+ return !(s->cpuid_ext_features & CPUID_EXT_SSE3);
+ case CK_CPUID_SSSE3:
+ return !(s->cpuid_ext_features & CPUID_EXT_SSSE3);
+ case CK_CPUID_SSE4_1:
+ return !(s->cpuid_ext_features & CPUID_EXT_SSE41);
+ case CK_CPUID_SSE4_2:
+ return !(s->cpuid_ext_features & CPUID_EXT_SSE42);
+ case CK_CPUID_SSE4A:
+ return !(s->cpuid_ext3_features & CPUID_EXT3_SSE4A);
+ case CK_CPUID_AVX:
+ return !(s->cpuid_ext_features & CPUID_EXT_AVX);
+ case CK_CPUID_AVX2:
+ return !(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_AVX2);
+ default:
+ g_assert_not_reached();
+ }
+}
+
static void gen_sse_ng(CPUX86State *env, DisasContext *s, int b)
{
enum {
--
2.20.1
- Re: [Qemu-devel] [RFC PATCH v2 04/39] target/i386: use dflag from DisasContext, (continued)
- [Qemu-devel] [RFC PATCH v2 07/39] target/i386: use pc_start from DisasContext, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 11/39] target/i386: introduce gen_(ld, st)d_env_A0, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 13/39] target/i386: disable unused function warning temporarily, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 14/39] target/i386: introduce mnemonic aliases for several gvec operations, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 12/39] target/i386: introduce gen_sse_ng, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 15/39] target/i386: introduce function ck_cpuid,
Jan Bobek <=
- [Qemu-devel] [RFC PATCH v2 16/39] target/i386: introduce instruction operand infrastructure, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 17/39] target/i386: introduce helpers for decoding modrm fields, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 18/39] target/i386: introduce modifier for direct-only operand decoding, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 20/39] target/i386: introduce generic load-store operand, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 22/39] target/i386: introduce code generators, Jan Bobek, 2019/08/10
- [Qemu-devel] [RFC PATCH v2 19/39] target/i386: introduce generic operand alias, Jan Bobek, 2019/08/10