Skip to content

Commit

Permalink
second pass through new opcodes to eliminate duplicates
Browse files Browse the repository at this point in the history
add definitions for new opcodes in m_int_uop_table and m_fp_uop_table without selecting uops -- still need to confirm what they map to
  • Loading branch information
mgoldstein322 committed Feb 1, 2024
1 parent 7954df1 commit 2cd7ddc
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 16 deletions.
80 changes: 80 additions & 0 deletions def/uoplatency_x86_sapphire_rapids.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
Copyright (c) <2020>, <Georgia Institute of Technology> All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials provided
with the distribution.

Neither the name of the <Georgia Institue of Technology> nor the names of its contributors
may be used to endorse or promote products derived from this software without specific prior
written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/


/*
* The arguments to DEFUOP(opcode, latency) are as follows:
* opcode - opcode name
* latency - opcode latency
*/

DEFUOP( UOP_INV, 1)
DEFUOP( UOP_NOP, 1)
DEFUOP( UOP_CF, 1)
DEFUOP( UOP_CMOV, 1)
DEFUOP( UOP_LDA, 1)
DEFUOP( UOP_IMEM, 1)
DEFUOP( UOP_LD, 1)
DEFUOP( UOP_ST, 1)
DEFUOP( UOP_IADD, 1)
DEFUOP( UOP_IMUL, 3)
DEFUOP( UOP_IDIV, 24)
DEFUOP( UOP_ICMP, 1)
DEFUOP( UOP_LOGIC, 1)
DEFUOP( UOP_SHIFT, 1)
DEFUOP( UOP_BYTE, 1)
DEFUOP( UOP_MM, 1)

DEFUOP( UOP_VSTR, 3)
DEFUOP( UOP_VADD, 1)
DEFUOP( UOP_VFADD, 1) // not used in coffee lake
DEFUOP( UOP_AES, 4)
DEFUOP( UOP_PCLMUL, 7)
DEFUOP( UOP_X87, 3)
DEFUOP( UOP_XSAVE, 107)
DEFUOP( UOP_XSAVEOPT,84)

DEFUOP( UOP_FMEM, 1)

DEFUOP( UOP_LFENCE, 100)
DEFUOP( UOP_FULL_FENCE, 100)
DEFUOP( UOP_ACQ_FENCE, 100)
DEFUOP( UOP_REL_FENCE, 100)

DEFUOP( UOP_FCF, 1)
DEFUOP( UOP_FCVT, 2)
DEFUOP( UOP_FADD, 3)
DEFUOP( UOP_FMUL, 5)
DEFUOP( UOP_FDIV, 15)
DEFUOP( UOP_FCMP, 2)
DEFUOP( UOP_FBIT, 2)
DEFUOP( UOP_FCMOV, 1)

DEFUOP( UOP_SSE, 1)

DEFUOP( UOP_AMX, 100)
5 changes: 5 additions & 0 deletions src/exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ static Uop_LatencyBinding_Init uop_latencybinding_init_x86_coffee_lake[] = {
#include "../def/uoplatency_x86_coffee_lake.def"
};

static Uop_LatencyBinding_Init uop_latencybinding_init_x86_sapphire_rapids[] = {
#define DEFUOP(A, B) {A, #A, B},
#include "../def/uoplatency_x86_sapphire_rapids.def"
};

static Uop_LatencyBinding_Init uop_latencybinding_init_ptx[] = {
#define DEFUOP(A, B) {A, #A, B},
#include "../def/uoplatency_ptx580.def"
Expand Down
1 change: 1 addition & 0 deletions src/global_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ typedef enum uop_latency_map { // enum for x86 latency maps - Michael
LATENCY_SKYLAKE,
LATENCY_SKYLAKE_X,
LATENCY_COFFEE_LAKE,
LATENCY_SAPPHIRE_RAPIDS,
NUM_LATENCY_MAPS
} latency_map;

Expand Down
14 changes: 7 additions & 7 deletions src/trace_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ typedef enum CPU_OPCODE_ENUM_ {
XED_CATEGORY_AVX512_4VNNIW,
XED_CATEGORY_AVX512_BITALG,
XED_CATEGORY_AVX512_VBMI,
XED_CATEGORY_AVX512_VP2INTERSECT, //new
XED_CATEGORY_AVX512_VP2INTERSECT,
XED_CATEGORY_AVX_IFMA, //new
XED_CATEGORY_BINARY,
XED_CATEGORY_BITBYTE,
Expand All @@ -306,7 +306,7 @@ typedef enum CPU_OPCODE_ENUM_ {
XED_CATEGORY_BROADCAST,
XED_CATEGORY_CALL,
XED_CATEGORY_CET,
XED_CATEGORY_CLDEMOTE, //new
XED_CATEGORY_CLDEMOTE,
XED_CATEGORY_CLFLUSHOPT,
XED_CATEGORY_CLWB,
XED_CATEGORY_CLZERO,
Expand All @@ -317,7 +317,7 @@ typedef enum CPU_OPCODE_ENUM_ {
XED_CATEGORY_CONVERT,
XED_CATEGORY_DATAXFER,
XED_CATEGORY_DECIMAL,
XED_CATEGORY_ENQCMD, //new
XED_CATEGORY_ENQCMD,
XED_CATEGORY_EXPAND,
XED_CATEGORY_FCMOV,
XED_CATEGORY_FLAGOP,
Expand All @@ -339,7 +339,7 @@ typedef enum CPU_OPCODE_ENUM_ {
XED_CATEGORY_LZCNT,
XED_CATEGORY_MISC,
XED_CATEGORY_MMX,
XED_CATEGORY_MOVDIR, //new
XED_CATEGORY_MOVDIR,
XED_CATEGORY_MPX,
XED_CATEGORY_MSRLIST, //new
XED_CATEGORY_NOP,
Expand All @@ -353,7 +353,7 @@ typedef enum CPU_OPCODE_ENUM_ {
XED_CATEGORY_PTWRITE, //changed from XED_CATEGORY_PT?
XED_CATEGORY_PUSH,
XED_CATEGORY_RDPID,
XED_CATEGORY_RDPRU, //new
XED_CATEGORY_RDPRU,
XED_CATEGORY_RDRAND,
XED_CATEGORY_RDSEED,
XED_CATEGORY_RDWRFSGS,
Expand Down Expand Up @@ -383,10 +383,10 @@ typedef enum CPU_OPCODE_ENUM_ {
XED_CATEGORY_VBMI2,
XED_CATEGORY_VEX, //new
XED_CATEGORY_VFMA,
XED_CATEGORY_VIA_PADLOCK, //new
XED_CATEGORY_VIA_PADLOCK,
XED_CATEGORY_VPCLMULQDQ,
XED_CATEGORY_VTX,
XED_CATEGORY_WAITPKG, //new
XED_CATEGORY_WAITPKG,
XED_CATEGORY_WIDENOP,
XED_CATEGORY_WRMSRNS, //new
XED_CATEGORY_X87_ALU,
Expand Down
50 changes: 41 additions & 9 deletions src/trace_read_cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,8 @@ void cpu_decoder_c::init_pin_convert(void) {
m_int_uop_table[XED_CATEGORY_3DNOW] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_ADOX_ADCX] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_AES] = UOP_AES;
m_int_uop_table[XED_CATEGORY_AMX_TILE] = UOP_AMX; // new
m_int_uop_table[XED_CATEGORY_APX] = ; //new
m_int_uop_table[XED_CATEGORY_AVX] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_AVX2] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_AVX2GATHER] = UOP_VADD;
Expand All @@ -1264,6 +1266,7 @@ void cpu_decoder_c::init_pin_convert(void) {
m_int_uop_table[XED_CATEGORY_AVX512_BITALG] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_AVX512_VBMI] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_AVX512_VP2INTERSECT] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_AVX_IFMA] = ; //new
m_int_uop_table[XED_CATEGORY_BINARY] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_BITBYTE] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_BLEND] = UOP_IADD;
Expand All @@ -1289,21 +1292,28 @@ void cpu_decoder_c::init_pin_convert(void) {
m_int_uop_table[XED_CATEGORY_FLAGOP] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_FMA4] =
UOP_FMUL; // fused floating multply and add
m_int_uop_table[XED_CATEGORY_FP16] = ; //new
m_int_uop_table[XED_CATEGORY_GATHER] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_GFNI] = UOP_IMUL;
m_int_uop_table[XED_CATEGORY_HRESET] = ; //new
m_int_uop_table[XED_CATEGORY_IFMA] = UOP_IMUL;
m_int_uop_table[XED_CATEGORY_INTERRUPT] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_IO] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_IOSTRINGOP] = UOP_IMUL;
m_int_uop_table[XED_CATEGORY_KEYLOCKER] = ; //new
m_int_uop_table[XED_CATEGORY_KEYLOCKER_WIDE] = ; //new
m_int_uop_table[XED_CATEGORY_KMASK] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_LEGACY] = ; //new
m_int_uop_table[XED_CATEGORY_LOGICAL] = UOP_LOGIC;
m_int_uop_table[XED_CATEGORY_LOGICAL_FP] = UOP_LOGIC;
m_int_uop_table[XED_CATEGORY_LZCNT] = UOP_LOGIC;
m_int_uop_table[XED_CATEGORY_MISC] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_MMX] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_MOVDIR] = UOP_FADD;
m_int_uop_table[XED_CATEGORY_MPX] = UOP_FADD;
m_int_uop_table[XED_CATEGORY_MSRLIST] = ; //new
m_int_uop_table[XED_CATEGORY_NOP] = UOP_NOP;
m_int_uop_table[XED_CATEGORY_PBNDKB] = ; //new
m_int_uop_table[XED_CATEGORY_PCLMULQDQ] = UOP_PCLMUL;
m_int_uop_table[XED_CATEGORY_PCONFIG] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_PKU] = UOP_IADD;
Expand All @@ -1322,29 +1332,35 @@ void cpu_decoder_c::init_pin_convert(void) {
m_int_uop_table[XED_CATEGORY_SCATTER] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_SEGOP] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_SEMAPHORE] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_SETCC] = UOP_IADD; // new
m_int_uop_table[XED_CATEGORY_SGX] = UOP_IADD; // new
m_int_uop_table[XED_CATEGORY_SHA] = UOP_IADD; // new
m_int_uop_table[XED_CATEGORY_SERIALIZE] = ; //new
m_int_uop_table[XED_CATEGORY_SETCC] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_SGX] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_SHA] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_SHA512] = ; //new
m_int_uop_table[XED_CATEGORY_SHIFT] = UOP_SHIFT;
m_int_uop_table[XED_CATEGORY_SMAP] = UOP_IADD; // new
m_int_uop_table[XED_CATEGORY_SMAP] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_SSE] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_STRINGOP] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_STTNI] = UOP_VSTR;
m_int_uop_table[XED_CATEGORY_SYSCALL] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_SYSRET] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_SYSTEM] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_TBM] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_TSX_LDTRK] = ; //new
m_int_uop_table[XED_CATEGORY_UINTR] = ; //new
m_int_uop_table[XED_CATEGORY_UNCOND_BR] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_VAES] = UOP_AES; // new
m_int_uop_table[XED_CATEGORY_VAES] = UOP_AES;
m_int_uop_table[XED_CATEGORY_VBMI2] = UOP_VADD;
m_int_uop_table{XED_CATEGORY_VEX} = ; //new
m_int_uop_table[XED_CATEGORY_VFMA] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_VIA_PADLOCK] = UOP_AES; // new
m_int_uop_table[XED_CATEGORY_VPCLMULQDQ] = UOP_PCLMUL; // new
m_int_uop_table[XED_CATEGORY_VIA_PADLOCK] = UOP_AES;
m_int_uop_table[XED_CATEGORY_VPCLMULQDQ] = UOP_PCLMUL;
m_int_uop_table[XED_CATEGORY_VTX] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_WAITPKG] = UOP_IADD; // new
m_int_uop_table[XED_CATEGORY_WAITPKG] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_WIDENOP] = UOP_IADD;
m_int_uop_table[XED_CATEGORY_WRMSRNS] = ; //new
m_int_uop_table[XED_CATEGORY_X87_ALU] = UOP_X87;
m_int_uop_table[XED_CATEGORY_XOP] = UOP_VADD; // new
m_int_uop_table[XED_CATEGORY_XOP] = UOP_VADD;
m_int_uop_table[XED_CATEGORY_XSAVE] = UOP_XSAVE;
m_int_uop_table[XED_CATEGORY_XSAVEOPT] = UOP_XSAVEOPT;
m_int_uop_table[TR_MUL] = UOP_IMUL;
Expand All @@ -1361,6 +1377,8 @@ void cpu_decoder_c::init_pin_convert(void) {
m_fp_uop_table[XED_CATEGORY_3DNOW] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_ADOX_ADCX] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_AES] = UOP_AES;
m_fp_uop_table[XED_CATEGORY_AMX_TILE] = ; //new
m_fp_uop_table[XED_CATEGORY_APX] = ; //new
m_fp_uop_table[XED_CATEGORY_AVX] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_AVX2] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_AVX2GATHER] = UOP_FADD;
Expand All @@ -1370,6 +1388,7 @@ void cpu_decoder_c::init_pin_convert(void) {
m_fp_uop_table[XED_CATEGORY_AVX512_BITALG] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_AVX512_VBMI] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_AVX512_VP2INTERSECT] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_AVX_IFMA] = ; //new
m_fp_uop_table[XED_CATEGORY_BINARY] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_BITBYTE] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_BLEND] = UOP_FADD;
Expand All @@ -1395,21 +1414,28 @@ void cpu_decoder_c::init_pin_convert(void) {
m_fp_uop_table[XED_CATEGORY_FLAGOP] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_FMA4] =
UOP_FMUL; // fused floating multply and add
m_fp_uop_table[XED_CATEGORY_FP16] = ; //new
m_fp_uop_table[XED_CATEGORY_GATHER] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_GFNI] = UOP_FMUL;
m_fp_uop_table[XED_CATEGORY_HRESET] = ; //new
m_fp_uop_table[XED_CATEGORY_IFMA] = UOP_FMUL;
m_fp_uop_table[XED_CATEGORY_INTERRUPT] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_IO] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_IOSTRINGOP] = UOP_FMUL;
m_fp_uop_table[XED_CATEGORY_KEYLOCKER] = ; //new
m_fp_uop_table[XED_CATEGORY_KEYLOCKER_WIDE] = ; //new
m_fp_uop_table[XED_CATEGORY_KMASK] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_LEGACY] = ; //new
m_fp_uop_table[XED_CATEGORY_LOGICAL] = UOP_LOGIC;
m_fp_uop_table[XED_CATEGORY_LOGICAL_FP] = UOP_LOGIC;
m_fp_uop_table[XED_CATEGORY_LZCNT] = UOP_LOGIC;
m_fp_uop_table[XED_CATEGORY_MISC] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_MMX] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_MOVDIR] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_MPX] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_MSRLIST] = ; //new
m_fp_uop_table[XED_CATEGORY_NOP] = UOP_NOP;
m_fp_uop_table[XED_CATEGORY_PBNDKB] = ; //new
m_fp_uop_table[XED_CATEGORY_PCLMULQDQ] = UOP_PCLMUL;
m_fp_uop_table[XED_CATEGORY_PCONFIG] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_PKU] = UOP_FADD;
Expand All @@ -1428,9 +1454,11 @@ void cpu_decoder_c::init_pin_convert(void) {
m_fp_uop_table[XED_CATEGORY_SCATTER] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_SEGOP] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_SEMAPHORE] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_SERIALIZE] = ; //new
m_fp_uop_table[XED_CATEGORY_SETCC] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_SGX] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_SHA] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_SHA512] = ; //new
m_fp_uop_table[XED_CATEGORY_SHIFT] = UOP_SHIFT;
m_fp_uop_table[XED_CATEGORY_SMAP] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_SSE] = UOP_FADD;
Expand All @@ -1440,15 +1468,19 @@ void cpu_decoder_c::init_pin_convert(void) {
m_fp_uop_table[XED_CATEGORY_SYSRET] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_SYSTEM] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_TBM] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_TSX_LDTRK] = ; //new
m_fp_uop_table[XED_CATEGORY_UINTR] = ; //new
m_fp_uop_table[XED_CATEGORY_UNCOND_BR] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_VAES] = UOP_AES;
m_fp_uop_table[XED_CATEGORY_VBMI2] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_VEX] = ; //new
m_fp_uop_table[XED_CATEGORY_VFMA] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_VIA_PADLOCK] = UOP_AES;
m_fp_uop_table[XED_CATEGORY_VPCLMULQDQ] = UOP_PCLMUL;
m_fp_uop_table[XED_CATEGORY_VTX] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_WAITPKG] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_WIDENOP] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_WRMSRNS] = ; //new
m_fp_uop_table[XED_CATEGORY_X87_ALU] = UOP_X87;
m_fp_uop_table[XED_CATEGORY_XOP] = UOP_FADD;
m_fp_uop_table[XED_CATEGORY_XSAVE] = UOP_XSAVE;
Expand Down

0 comments on commit 2cd7ddc

Please sign in to comment.