Tong Shen has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/39615 )
Change subject: arch-x86: implement POPCNT instruction.
......................................................................
arch-x86: implement POPCNT instruction.
Change-Id: Id6ddc1245c81a17720885f9038d55d0811ef7f4d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39615
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/arch/x86/decoder_tables.cc
M src/arch/x86/isa/decoder/two_byte_opcodes.isa
M src/arch/x86/isa/insts/general_purpose/compare_and_test/bit_scan.py
M src/arch/x86/isa/microops/regop.isa
4 files changed, 31 insertions(+), 4 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/x86/decoder_tables.cc b/src/arch/x86/decoder_tables.cc
index 7ee5e01..db749cf 100644
--- a/src/arch/x86/decoder_tables.cc
+++ b/src/arch/x86/decoder_tables.cc
@@ -115,7 +115,7 @@
/* 8 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
/* 9 */ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1,
/* A */ 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1,
-/* B */ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1,
+/* B */ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1,
/* C */ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
/* D */ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1,
/* E */ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1,
@@ -234,7 +234,7 @@
/* 8 */ ZW, ZW, ZW, ZW, ZW, ZW, ZW, ZW, ZW, ZW, ZW, ZW, ZW, ZW, ZW, ZW,
/* 9 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
/* A */ 0 , 0 , 0 , 0 , BY, 0 , 0 , 0 , 0 , 0 , 0 , 0 , BY, 0 , 0 , 0 ,
-/* B */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , ZW, 0 , BY, 0 , 0 , 0 , 0 , 0 ,
+/* B */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , BY, 0 , 0 , 0 , 0 , 0 ,
/* C */ 0 , 0 , BY, 0 , BY, BY, BY, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
/* D */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
/* E */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
diff --git a/src/arch/x86/isa/decoder/two_byte_opcodes.isa
b/src/arch/x86/isa/decoder/two_byte_opcodes.isa
index f70e7bd..fe8a2bc 100644
--- a/src/arch/x86/isa/decoder/two_byte_opcodes.isa
+++ b/src/arch/x86/isa/decoder/two_byte_opcodes.isa
@@ -754,8 +754,7 @@
}
0x17: decode OPCODE_OP_BOTTOM3 {
0x0: decode LEGACY_REP {
- 0x0: WarnUnimpl::jmpe_Jz();
- 0x1: WarnUnimpl::popcnt_Gv_Ev();
+ 0x1: POPCNT(Gv,Ev);
}
//0x1: group10_UD2();
0x1: UD2();
diff --git
a/src/arch/x86/isa/insts/general_purpose/compare_and_test/bit_scan.py
b/src/arch/x86/isa/insts/general_purpose/compare_and_test/bit_scan.py
index a755d25..05bd3c4 100644
--- a/src/arch/x86/isa/insts/general_purpose/compare_and_test/bit_scan.py
+++ b/src/arch/x86/isa/insts/general_purpose/compare_and_test/bit_scan.py
@@ -350,4 +350,19 @@
end:
fault "NoFault"
};
+
+def macroop POPCNT_R_R {
+ popcnt reg, regm, reg, dataSize=8
+};
+
+def macroop POPCNT_R_M {
+ ld t1, seg, sib, disp
+ popcnt reg, t1, reg, dataSize=8
+};
+
+def macroop POPCNT_R_P {
+ rdip t7
+ ld t1, seg, riprel, disp
+ popcnt reg, t1, reg, dataSize=8
+};
'''
diff --git a/src/arch/x86/isa/microops/regop.isa
b/src/arch/x86/isa/microops/regop.isa
index c465dcc..570c084 100644
--- a/src/arch/x86/isa/microops/regop.isa
+++ b/src/arch/x86/isa/microops/regop.isa
@@ -1764,4 +1764,17 @@
code = '''
DestReg = X86ISA::convX87TagsToXTags(FTW);
'''
+
+ class Popcnt(RegOp):
+ code = '''
+ DestReg =
+ merge(DestReg, __builtin_popcountl(psrc1), dataSize);
+ '''
+ flag_code = '''
+ ccFlagBits = ccFlagBits & ~(SFBit | AFBit | ZFBit | PFBit);
+ if (findZero(dataSize * 8, SrcReg1)) {
+ ccFlagBits = ccFlagBits | ZFBit;
+ }
+ cfofBits = cfofBits & ~(OFBit | CFBit);
+ '''
}};
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39615
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Id6ddc1245c81a17720885f9038d55d0811ef7f4d
Gerrit-Change-Number: 39615
Gerrit-PatchSet: 4
Gerrit-Owner: Tong Shen <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Tong Shen <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s