From 31d29ee3f8209a43e325cfe0373e9081a263ad36 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 17 Aug 2009 20:15:15 -0700 Subject: [PATCH] X86: Implement the media integer subtract instructions. --- src/arch/x86/isa/decoder/two_byte_opcodes.isa | 32 ++-- .../simd128/integer/arithmetic/subtraction.py | 167 +++++++++++++++++- .../simd64/integer/arithmetic/subtraction.py | 127 ++++++++++++- 3 files changed, 294 insertions(+), 32 deletions(-) diff --git a/src/arch/x86/isa/decoder/two_byte_opcodes.isa b/src/arch/x86/isa/decoder/two_byte_opcodes.isa index df4512b7c..906516b86 100644 --- a/src/arch/x86/isa/decoder/two_byte_opcodes.isa +++ b/src/arch/x86/isa/decoder/two_byte_opcodes.isa @@ -980,8 +980,8 @@ 0x1B: decode LEGACY_DECODEVAL { // no prefix 0x0: decode OPCODE_OP_BOTTOM3 { - 0x0: WarnUnimpl::psubusb_Pq_Qq(); - 0x1: WarnUnimpl::psubusw_Pq_Qq(); + 0x0: PSUBUSB(Pq,Qq); + 0x1: PSUBUSW(Pq,Qq); 0x2: PMINUB(Pq,Qq); 0x3: PAND(Pq,Qq); 0x4: PADDUSB(Pq,Qq); @@ -991,8 +991,8 @@ } // operand size (0x66) 0x1: decode OPCODE_OP_BOTTOM3 { - 0x0: WarnUnimpl::psubusb_Vo_Wo(); - 0x1: WarnUnimpl::psubusw_Vo_Wo(); + 0x0: PSUBUSB(Vo,Wo); + 0x1: PSUBUSW(Vo,Wo); 0x2: PMINUB(Vo,Wo); 0x3: PAND(Vo,Wo); 0x4: PADDUSB(Vo,Wo); @@ -1042,8 +1042,8 @@ 0x1D: decode LEGACY_DECODEVAL { // no prefix 0x0: decode OPCODE_OP_BOTTOM3 { - 0x0: WarnUnimpl::psubsb_Pq_Qq(); - 0x1: WarnUnimpl::psubsw_Pq_Qq(); + 0x0: PSUBSB(Pq,Qq); + 0x1: PSUBSW(Pq,Qq); 0x2: PMINSW(Pq,Qq); 0x3: POR(Pq,Qq); 0x4: PADDSB(Pq,Qq); @@ -1053,8 +1053,8 @@ } // operand size (0x66) 0x1: decode OPCODE_OP_BOTTOM3 { - 0x0: WarnUnimpl::psubsb_Vo_Wo(); - 0x1: WarnUnimpl::psubsw_Vo_Wo(); + 0x0: PSUBSB(Vo,Wo); + 0x1: PSUBSW(Vo,Wo); 0x2: PMINSW(Vo,Wo); 0x3: POR(Vo,Wo); 0x4: PADDSB(Vo,Wo); @@ -1099,10 +1099,10 @@ 0x1F: decode LEGACY_DECODEVAL { // no prefix 0x0: decode OPCODE_OP_BOTTOM3 { - 0x0: WarnUnimpl::psubb_Pq_Qq(); - 0x1: WarnUnimpl::psubw_Pq_Qq(); - 0x2: WarnUnimpl::psubd_Pq_Qq(); - 0x3: WarnUnimpl::psubq_Pq_Qq(); + 0x0: PSUBB(Pq,Qq); + 0x1: PSUBW(Pq,Qq); + 0x2: PSUBD(Pq,Qq); + 0x3: PSUBQ(Pq,Qq); 0x4: PADDB(Pq,Qq); 0x5: PADDW(Pq,Qq); 0x6: PADDD(Pq,Qq); @@ -1110,10 +1110,10 @@ } // operand size (0x66) 0x1: decode OPCODE_OP_BOTTOM3 { - 0x0: WarnUnimpl::psubb_Vo_Wo(); - 0x1: WarnUnimpl::psubw_Vo_Wo(); - 0x2: WarnUnimpl::psubd_Vo_Wo(); - 0x3: WarnUnimpl::psubq_Vo_Wo(); + 0x0: PSUBB(Vo,Wo); + 0x1: PSUBW(Vo,Wo); + 0x2: PSUBD(Vo,Wo); + 0x3: PSUBQ(Vo,Wo); 0x4: PADDB(Vo,Wo); 0x5: PADDW(Vo,Wo); 0x6: PADDD(Vo,Wo); diff --git a/src/arch/x86/isa/insts/simd128/integer/arithmetic/subtraction.py b/src/arch/x86/isa/insts/simd128/integer/arithmetic/subtraction.py index 44781eb55..fdfb08667 100644 --- a/src/arch/x86/isa/insts/simd128/integer/arithmetic/subtraction.py +++ b/src/arch/x86/isa/insts/simd128/integer/arithmetic/subtraction.py @@ -54,12 +54,163 @@ # Authors: Gabe Black microcode = ''' -# PSUBB -# PSUBW -# PSUBD -# PSUBQ -# PSUBSB -# PSUBSW -# PSUBUSB -# PSUBUSW +def macroop PSUBB_XMM_XMM { + msubi xmml, xmml, xmmlm, size=1, ext=0 + msubi xmmh, xmmh, xmmhm, size=1, ext=0 +}; + +def macroop PSUBB_XMM_M { + ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=1, ext=0 + msubi xmmh, xmmh, ufp2, size=1, ext=0 +}; + +def macroop PSUBB_XMM_P { + rdip t7 + ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=1, ext=0 + msubi xmmh, xmmh, ufp2, size=1, ext=0 +}; + +def macroop PSUBW_XMM_XMM { + msubi xmml, xmml, xmmlm, size=2, ext=0 + msubi xmmh, xmmh, xmmhm, size=2, ext=0 +}; + +def macroop PSUBW_XMM_M { + ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=2, ext=0 + msubi xmmh, xmmh, ufp2, size=2, ext=0 +}; + +def macroop PSUBW_XMM_P { + rdip t7 + ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=2, ext=0 + msubi xmmh, xmmh, ufp2, size=2, ext=0 +}; + +def macroop PSUBD_XMM_XMM { + msubi xmml, xmml, xmmlm, size=4, ext=0 + msubi xmmh, xmmh, xmmhm, size=4, ext=0 +}; + +def macroop PSUBD_XMM_M { + ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=4, ext=0 + msubi xmmh, xmmh, ufp2, size=4, ext=0 +}; + +def macroop PSUBD_XMM_P { + rdip t7 + ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=4, ext=0 + msubi xmmh, xmmh, ufp2, size=4, ext=0 +}; + +def macroop PSUBQ_XMM_XMM { + msubi xmml, xmml, xmmlm, size=8, ext=0 + msubi xmmh, xmmh, xmmhm, size=8, ext=0 +}; + +def macroop PSUBQ_XMM_M { + ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=8, ext=0 + msubi xmmh, xmmh, ufp2, size=8, ext=0 +}; + +def macroop PSUBQ_XMM_P { + rdip t7 + ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=8, ext=0 + msubi xmmh, xmmh, ufp2, size=8, ext=0 +}; + +def macroop PSUBSB_XMM_XMM { + msubi xmml, xmml, xmmlm, size=1, ext=4 + msubi xmmh, xmmh, xmmhm, size=1, ext=4 +}; + +def macroop PSUBSB_XMM_M { + ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=1, ext=4 + msubi xmmh, xmmh, ufp2, size=1, ext=4 +}; + +def macroop PSUBSB_XMM_P { + rdip t7 + ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=1, ext=4 + msubi xmmh, xmmh, ufp2, size=1, ext=4 +}; + +def macroop PSUBSW_XMM_XMM { + msubi xmml, xmml, xmmlm, size=2, ext=4 + msubi xmmh, xmmh, xmmhm, size=2, ext=4 +}; + +def macroop PSUBSW_XMM_M { + ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=2, ext=4 + msubi xmmh, xmmh, ufp2, size=2, ext=4 +}; + +def macroop PSUBSW_XMM_P { + rdip t7 + ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=2, ext=4 + msubi xmmh, xmmh, ufp2, size=2, ext=4 +}; + +def macroop PSUBUSB_XMM_XMM { + msubi xmml, xmml, xmmlm, size=1, ext=2 + msubi xmmh, xmmh, xmmhm, size=1, ext=2 +}; + +def macroop PSUBUSB_XMM_M { + ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=1, ext=2 + msubi xmmh, xmmh, ufp2, size=1, ext=2 +}; + +def macroop PSUBUSB_XMM_P { + rdip t7 + ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=1, ext=2 + msubi xmmh, xmmh, ufp2, size=1, ext=2 +}; + +def macroop PSUBUSW_XMM_XMM { + msubi xmml, xmml, xmmlm, size=2, ext=2 + msubi xmmh, xmmh, xmmhm, size=2, ext=2 +}; + +def macroop PSUBUSW_XMM_M { + ldfp ufp1, seg, sib, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, sib, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=2, ext=2 + msubi xmmh, xmmh, ufp2, size=2, ext=2 +}; + +def macroop PSUBUSW_XMM_P { + rdip t7 + ldfp ufp1, seg, riprel, "DISPLACEMENT", dataSize=8 + ldfp ufp2, seg, riprel, "DISPLACEMENT + 8", dataSize=8 + msubi xmml, xmml, ufp1, size=2, ext=2 + msubi xmmh, xmmh, ufp2, size=2, ext=2 +}; ''' diff --git a/src/arch/x86/isa/insts/simd64/integer/arithmetic/subtraction.py b/src/arch/x86/isa/insts/simd64/integer/arithmetic/subtraction.py index 44781eb55..a60c0b1a8 100644 --- a/src/arch/x86/isa/insts/simd64/integer/arithmetic/subtraction.py +++ b/src/arch/x86/isa/insts/simd64/integer/arithmetic/subtraction.py @@ -54,12 +54,123 @@ # Authors: Gabe Black microcode = ''' -# PSUBB -# PSUBW -# PSUBD -# PSUBQ -# PSUBSB -# PSUBSW -# PSUBUSB -# PSUBUSW +def macroop PSUBB_MMX_MMX { + msubi mmx, mmx, mmxm, size=1, ext=0 +}; + +def macroop PSUBB_MMX_M { + ldfp ufp1, seg, sib, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=1, ext=0 +}; + +def macroop PSUBB_MMX_P { + rdip t7 + ldfp ufp1, seg, riprel, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=1, ext=0 +}; + +def macroop PSUBW_MMX_MMX { + msubi mmx, mmx, mmxm, size=2, ext=0 +}; + +def macroop PSUBW_MMX_M { + ldfp ufp1, seg, sib, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=2, ext=0 +}; + +def macroop PSUBW_MMX_P { + rdip t7 + ldfp ufp1, seg, riprel, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=2, ext=0 +}; + +def macroop PSUBD_MMX_MMX { + msubi mmx, mmx, mmxm, size=4, ext=0 +}; + +def macroop PSUBD_MMX_M { + ldfp ufp1, seg, sib, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=4, ext=0 +}; + +def macroop PSUBD_MMX_P { + rdip t7 + ldfp ufp1, seg, riprel, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=4, ext=0 +}; + +def macroop PSUBQ_MMX_MMX { + msubi mmx, mmx, mmxm, size=8, ext=0 +}; + +def macroop PSUBQ_MMX_M { + ldfp ufp1, seg, sib, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=8, ext=0 +}; + +def macroop PSUBQ_MMX_P { + rdip t7 + ldfp ufp1, seg, riprel, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=8, ext=0 +}; + +def macroop PSUBSB_MMX_MMX { + msubi mmx, mmx, mmxm, size=1, ext=4 +}; + +def macroop PSUBSB_MMX_M { + ldfp ufp1, seg, sib, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=1, ext=4 +}; + +def macroop PSUBSB_MMX_P { + rdip t7 + ldfp ufp1, seg, riprel, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=1, ext=4 +}; + +def macroop PSUBSW_MMX_MMX { + msubi mmx, mmx, mmxm, size=2, ext=4 +}; + +def macroop PSUBSW_MMX_M { + ldfp ufp1, seg, sib, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=2, ext=4 +}; + +def macroop PSUBSW_MMX_P { + rdip t7 + ldfp ufp1, seg, riprel, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=2, ext=4 +}; + +def macroop PSUBUSB_MMX_MMX { + msubi mmx, mmx, mmxm, size=1, ext=2 +}; + +def macroop PSUBUSB_MMX_M { + ldfp ufp1, seg, sib, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=1, ext=2 +}; + +def macroop PSUBUSB_MMX_P { + rdip t7 + ldfp ufp1, seg, riprel, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=1, ext=2 +}; + +def macroop PSUBUSW_MMX_MMX { + msubi mmx, mmx, mmxm, size=2, ext=2 +}; + +def macroop PSUBUSW_MMX_M { + ldfp ufp1, seg, sib, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=2, ext=2 +}; + +def macroop PSUBUSW_MMX_P { + rdip t7 + ldfp ufp1, seg, riprel, disp, dataSize=8 + msubi mmx, mmx, ufp1, size=2, ext=2 +}; ''' -- 2.30.2