• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版993508e43e6d180e9ba9b747a9657eac69aec5bb (tree)
时间2017-01-11 01:49:59
作者Richard Henderson <rth@twid...>
CommiterRichard Henderson

Log Message

tcg/i386: Handle ctpop opcode

Signed-off-by: Richard Henderson <rth@twiddle.net>

更改概述

差异

--- a/tcg/i386/tcg-target.h
+++ b/tcg/i386/tcg-target.h
@@ -76,6 +76,7 @@ typedef enum {
7676 #endif
7777
7878 extern bool have_bmi1;
79+extern bool have_popcnt;
7980
8081 /* optional instructions */
8182 #define TCG_TARGET_HAS_div2_i32 1
@@ -95,7 +96,7 @@ extern bool have_bmi1;
9596 #define TCG_TARGET_HAS_nor_i32 0
9697 #define TCG_TARGET_HAS_clz_i32 1
9798 #define TCG_TARGET_HAS_ctz_i32 1
98-#define TCG_TARGET_HAS_ctpop_i32 0
99+#define TCG_TARGET_HAS_ctpop_i32 have_popcnt
99100 #define TCG_TARGET_HAS_deposit_i32 1
100101 #define TCG_TARGET_HAS_extract_i32 1
101102 #define TCG_TARGET_HAS_sextract_i32 1
@@ -130,7 +131,7 @@ extern bool have_bmi1;
130131 #define TCG_TARGET_HAS_nor_i64 0
131132 #define TCG_TARGET_HAS_clz_i64 1
132133 #define TCG_TARGET_HAS_ctz_i64 1
133-#define TCG_TARGET_HAS_ctpop_i64 0
134+#define TCG_TARGET_HAS_ctpop_i64 have_popcnt
134135 #define TCG_TARGET_HAS_deposit_i64 1
135136 #define TCG_TARGET_HAS_extract_i64 1
136137 #define TCG_TARGET_HAS_sextract_i64 0
--- a/tcg/i386/tcg-target.inc.c
+++ b/tcg/i386/tcg-target.inc.c
@@ -130,9 +130,10 @@ static bool have_movbe;
130130 # define have_movbe 0
131131 #endif
132132
133-/* We need this symbol in tcg-target.h, and we can't properly conditionalize
133+/* We need these symbols in tcg-target.h, and we can't properly conditionalize
134134 it there. Therefore we always define the variable. */
135135 bool have_bmi1;
136+bool have_popcnt;
136137
137138 #if defined(CONFIG_CPUID_H) && defined(bit_BMI2)
138139 static bool have_bmi2;
@@ -337,6 +338,7 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type,
337338 #define OPC_MOVZBL (0xb6 | P_EXT)
338339 #define OPC_MOVZWL (0xb7 | P_EXT)
339340 #define OPC_POP_r32 (0x58)
341+#define OPC_POPCNT (0xb8 | P_EXT | P_SIMDF3)
340342 #define OPC_PUSH_r32 (0x50)
341343 #define OPC_PUSH_Iv (0x68)
342344 #define OPC_PUSH_Ib (0x6a)
@@ -2083,6 +2085,9 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
20832085 OP_32_64(clz):
20842086 tcg_out_clz(s, rexw, args[0], args[1], args[2], const_args[2]);
20852087 break;
2088+ OP_32_64(ctpop):
2089+ tcg_out_modrm(s, OPC_POPCNT + rexw, a0, a1);
2090+ break;
20862091
20872092 case INDEX_op_brcond_i32:
20882093 tcg_out_brcond32(s, a2, a0, a1, const_args[1], arg_label(args[3]), 0);
@@ -2398,6 +2403,8 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op)
23982403 case INDEX_op_extract_i32:
23992404 case INDEX_op_extract_i64:
24002405 case INDEX_op_sextract_i32:
2406+ case INDEX_op_ctpop_i32:
2407+ case INDEX_op_ctpop_i64:
24012408 return &r_r;
24022409
24032410 case INDEX_op_deposit_i32:
@@ -2602,6 +2609,9 @@ static void tcg_target_init(TCGContext *s)
26022609 need to probe for it. */
26032610 have_movbe = (c & bit_MOVBE) != 0;
26042611 #endif
2612+#ifdef bit_POPCNT
2613+ have_popcnt = (c & bit_POPCNT) != 0;
2614+#endif
26052615 }
26062616
26072617 if (max >= 7) {