From 8943c0584edc3089df819481e646371ebeae03f7 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 7 Oct 2018 10:10:19 +0000 Subject: [PATCH] + patch by J. Gareth Moreton to support BMI2 instructions + extended avx test generator with the newly added BMI2 instructions git-svn-id: trunk@39875 - --- compiler/i386/i386att.inc | 4 +++ compiler/i386/i386atts.inc | 4 +++ compiler/i386/i386int.inc | 4 +++ compiler/i386/i386nop.inc | 2 +- compiler/i386/i386op.inc | 4 +++ compiler/i386/i386prop.inc | 4 +++ compiler/i386/i386tab.inc | 28 +++++++++++++++++ compiler/i8086/i8086att.inc | 4 +++ compiler/i8086/i8086atts.inc | 4 +++ compiler/i8086/i8086int.inc | 4 +++ compiler/i8086/i8086nop.inc | 2 +- compiler/i8086/i8086op.inc | 4 +++ compiler/i8086/i8086prop.inc | 4 +++ compiler/i8086/i8086tab.inc | 28 +++++++++++++++++ compiler/x86/x86ins.dat | 28 ++++++++++++++--- compiler/x86_64/x8664ats.inc | 4 +++ compiler/x86_64/x8664att.inc | 4 +++ compiler/x86_64/x8664int.inc | 4 +++ compiler/x86_64/x8664nop.inc | 2 +- compiler/x86_64/x8664op.inc | 4 +++ compiler/x86_64/x8664pro.inc | 4 +++ compiler/x86_64/x8664tab.inc | 56 ++++++++++++++++++++++++++++++++++ tests/utils/avx/avxopcodes.pas | 8 +++++ 23 files changed, 207 insertions(+), 7 deletions(-) diff --git a/compiler/i386/i386att.inc b/compiler/i386/i386att.inc index 68ec910597..79bafb9fc7 100644 --- a/compiler/i386/i386att.inc +++ b/compiler/i386/i386att.inc @@ -1010,6 +1010,10 @@ 'andn', 'bextr', 'tzcnt', +'bzhi', +'mulx', +'pdep', +'pext', 'rorx', 'sarx', 'shlx', diff --git a/compiler/i386/i386atts.inc b/compiler/i386/i386atts.inc index 3d9024c499..aa47900ea6 100644 --- a/compiler/i386/i386atts.inc +++ b/compiler/i386/i386atts.inc @@ -1105,6 +1105,10 @@ attsufNONE, attsufNONE, attsufNONE, attsufNONE, +attsufNONE, +attsufNONE, +attsufNONE, +attsufNONE, attsufINT, attsufNONE, attsufNONE, diff --git a/compiler/i386/i386int.inc b/compiler/i386/i386int.inc index 99061e8412..ba72938643 100644 --- a/compiler/i386/i386int.inc +++ b/compiler/i386/i386int.inc @@ -1010,6 +1010,10 @@ 'andn', 'bextr', 'tzcnt', +'bzhi', +'mulx', +'pdep', +'pext', 'rorx', 'sarx', 'shlx', diff --git a/compiler/i386/i386nop.inc b/compiler/i386/i386nop.inc index 9e0fad8df4..d5a1b188d1 100644 --- a/compiler/i386/i386nop.inc +++ b/compiler/i386/i386nop.inc @@ -1,2 +1,2 @@ { don't edit, this file is generated from x86ins.dat } -2117; +2121; diff --git a/compiler/i386/i386op.inc b/compiler/i386/i386op.inc index ebbdd236c8..49a42e9e3c 100644 --- a/compiler/i386/i386op.inc +++ b/compiler/i386/i386op.inc @@ -1010,6 +1010,10 @@ A_VZEROUPPER, A_ANDN, A_BEXTR, A_TZCNT, +A_BZHI, +A_MULX, +A_PDEP, +A_PEXT, A_RORX, A_SARX, A_SHLX, diff --git a/compiler/i386/i386prop.inc b/compiler/i386/i386prop.inc index 1b19212a46..5d10a8251a 100644 --- a/compiler/i386/i386prop.inc +++ b/compiler/i386/i386prop.inc @@ -1010,6 +1010,10 @@ (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Wop2, Ch_WFlags, Ch_Rop1]), +(Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), +(Ch: [Ch_REDX, Ch_Rop1, Ch_Wop2, Ch_Wop3]), +(Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), +(Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Rop1, Ch_Wop2]), (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), diff --git a/compiler/i386/i386tab.inc b/compiler/i386/i386tab.inc index 7f5cd96ab9..4eff319554 100644 --- a/compiler/i386/i386tab.inc +++ b/compiler/i386/i386tab.inc @@ -13615,6 +13615,34 @@ code : #208#219#2#15#188#72; flags : [if_bmi1,if_sm] ), + ( + opcode : A_BZHI; + ops : 3; + optypes : (ot_reg32,ot_rm_gpr or ot_bits32,ot_reg32,ot_none); + code : #242#249#1#245#62#72; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_MULX; + ops : 3; + optypes : (ot_reg32,ot_reg32,ot_rm_gpr or ot_bits32,ot_none); + code : #220#242#249#1#246#61#80; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_PDEP; + ops : 3; + optypes : (ot_reg32,ot_reg32,ot_rm_gpr or ot_bits32,ot_none); + code : #220#242#249#1#245#61#80; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_PEXT; + ops : 3; + optypes : (ot_reg32,ot_reg32,ot_rm_gpr or ot_bits32,ot_none); + code : #219#242#249#1#245#61#80; + flags : [if_bmi2,if_prot] + ), ( opcode : A_RORX; ops : 3; diff --git a/compiler/i8086/i8086att.inc b/compiler/i8086/i8086att.inc index 48122eada8..b108001543 100644 --- a/compiler/i8086/i8086att.inc +++ b/compiler/i8086/i8086att.inc @@ -1010,6 +1010,10 @@ 'andn', 'bextr', 'tzcnt', +'bzhi', +'mulx', +'pdep', +'pext', 'rorx', 'sarx', 'shlx', diff --git a/compiler/i8086/i8086atts.inc b/compiler/i8086/i8086atts.inc index a920ca7ef1..de6aa3124a 100644 --- a/compiler/i8086/i8086atts.inc +++ b/compiler/i8086/i8086atts.inc @@ -1119,6 +1119,10 @@ attsufNONE, attsufNONE, attsufNONE, attsufNONE, +attsufNONE, +attsufNONE, +attsufNONE, +attsufNONE, attsufINT, attsufNONE, attsufNONE, diff --git a/compiler/i8086/i8086int.inc b/compiler/i8086/i8086int.inc index 6aaa02b6c3..1116021c57 100644 --- a/compiler/i8086/i8086int.inc +++ b/compiler/i8086/i8086int.inc @@ -1010,6 +1010,10 @@ 'andn', 'bextr', 'tzcnt', +'bzhi', +'mulx', +'pdep', +'pext', 'rorx', 'sarx', 'shlx', diff --git a/compiler/i8086/i8086nop.inc b/compiler/i8086/i8086nop.inc index 3edc5df1f5..a9d73c00ea 100644 --- a/compiler/i8086/i8086nop.inc +++ b/compiler/i8086/i8086nop.inc @@ -1,2 +1,2 @@ { don't edit, this file is generated from x86ins.dat } -2149; +2153; diff --git a/compiler/i8086/i8086op.inc b/compiler/i8086/i8086op.inc index e72640742e..e0c758f193 100644 --- a/compiler/i8086/i8086op.inc +++ b/compiler/i8086/i8086op.inc @@ -1010,6 +1010,10 @@ A_VZEROUPPER, A_ANDN, A_BEXTR, A_TZCNT, +A_BZHI, +A_MULX, +A_PDEP, +A_PEXT, A_RORX, A_SARX, A_SHLX, diff --git a/compiler/i8086/i8086prop.inc b/compiler/i8086/i8086prop.inc index 8da688f713..45d4712c17 100644 --- a/compiler/i8086/i8086prop.inc +++ b/compiler/i8086/i8086prop.inc @@ -1010,6 +1010,10 @@ (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Wop2, Ch_WFlags, Ch_Rop1]), +(Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), +(Ch: [Ch_REDX, Ch_Rop1, Ch_Wop2, Ch_Wop3]), +(Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), +(Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Rop1, Ch_Wop2]), (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), diff --git a/compiler/i8086/i8086tab.inc b/compiler/i8086/i8086tab.inc index 0e86e7469d..fddf12a7f6 100644 --- a/compiler/i8086/i8086tab.inc +++ b/compiler/i8086/i8086tab.inc @@ -13643,6 +13643,34 @@ code : #208#219#2#15#188#72; flags : [if_bmi1,if_sm] ), + ( + opcode : A_BZHI; + ops : 3; + optypes : (ot_reg32,ot_rm_gpr or ot_bits32,ot_reg32,ot_none); + code : #242#249#1#245#62#72; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_MULX; + ops : 3; + optypes : (ot_reg32,ot_reg32,ot_rm_gpr or ot_bits32,ot_none); + code : #220#242#249#1#246#61#80; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_PDEP; + ops : 3; + optypes : (ot_reg32,ot_reg32,ot_rm_gpr or ot_bits32,ot_none); + code : #220#242#249#1#245#61#80; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_PEXT; + ops : 3; + optypes : (ot_reg32,ot_reg32,ot_rm_gpr or ot_bits32,ot_none); + code : #219#242#249#1#245#61#80; + flags : [if_bmi2,if_prot] + ), ( opcode : A_RORX; ops : 3; diff --git a/compiler/x86/x86ins.dat b/compiler/x86/x86ins.dat index c5dc33b3ad..254249f610 100644 --- a/compiler/x86/x86ins.dat +++ b/compiler/x86/x86ins.dat @@ -5293,22 +5293,42 @@ reg16|32|64,regmem \320\333\2\x0F\xBC\110 BMI1,S ;********** BMI2 *************************************************************** ;******************************************************************************* +[BZHI] +(Ch_Rop1, Ch_Rop2, Ch_Wop3) +reg32,rm32,reg32 \362\371\1\xf5\76\110 BMI2,PROT +reg64,rm64,reg64 \362\363\371\1\xf5\76\110 BMI2,PROT,X86_64 + +[MULX] +(Ch_REDX, Ch_Rop1, Ch_Wop2, Ch_Wop3) +reg32,reg32,rm32 \334\362\371\1\xf6\75\120 BMI2,PROT +reg64,reg64,rm64 \334\362\363\371\1\xf6\75\120 BMI2,PROT,X86_64 + +[PDEP] +(Ch_Rop1, Ch_Rop2, Ch_Wop3) +reg32,reg32,rm32 \334\362\371\1\xf5\75\120 BMI2,PROT +reg64,reg64,rm64 \334\362\363\371\1\xf5\75\120 BMI2,PROT,X86_64 + +[PEXT] +(Ch_Rop1, Ch_Rop2, Ch_Wop3) +reg32,reg32,rm32 \333\362\371\1\xf5\75\120 BMI2,PROT +reg64,reg64,rm64 \333\362\363\371\1\xf5\75\120 BMI2,PROT,X86_64 + [RORX] (Ch_Rop1, Ch_Wop2) -reg32,rm32,imm8 \334\362\372\1\xf0\110\26 BMI2,PROT -reg64,rm64,imm8 \334\362\363\372\1\xf0\110\26 BMI2,PROT,X86_64 +reg32,rm32,imm8 \334\362\372\1\xf0\110\26 BMI2,PROT +reg64,rm64,imm8 \334\362\363\372\1\xf0\110\26 BMI2,PROT,X86_64 [SARX] (Ch_Rop1, Ch_Rop2, Ch_Wop3) reg32,rm32,reg32 \333\362\371\1\xf7\76\110 BMI2,PROT reg64,rm64,reg64 \333\362\363\371\1\xf7\76\110 BMI2,PROT,X86_64 -[SHLX] +[SHLX] ; VEX.NDS.LZ.66.0F38.W0 F7 /r (Ch_Rop1, Ch_Rop2, Ch_Wop3) reg32,rm32,reg32 \361\362\371\1\xf7\76\110 BMI2,PROT reg64,rm64,reg64 \361\362\363\371\1\xf7\76\110 BMI2,PROT,X86_64 -[SHRX] +[SHRX] ; VEX.NDS.LZ.F2.0F38.W0 F7 /r (Ch_Rop1, Ch_Rop2, Ch_Wop3) reg32,rm32,reg32 \334\362\371\1\xf7\76\110 BMI2,PROT reg64,rm64,reg64 \334\362\363\371\1\xf7\76\110 BMI2,PROT,X86_64 diff --git a/compiler/x86_64/x8664ats.inc b/compiler/x86_64/x8664ats.inc index 56551ab634..6b345b5313 100644 --- a/compiler/x86_64/x8664ats.inc +++ b/compiler/x86_64/x8664ats.inc @@ -1101,6 +1101,10 @@ attsufNONE, attsufNONE, attsufNONE, attsufNONE, +attsufNONE, +attsufNONE, +attsufNONE, +attsufNONE, attsufINT, attsufNONE, attsufNONE, diff --git a/compiler/x86_64/x8664att.inc b/compiler/x86_64/x8664att.inc index 5ab54627da..ec07326414 100644 --- a/compiler/x86_64/x8664att.inc +++ b/compiler/x86_64/x8664att.inc @@ -1006,6 +1006,10 @@ 'andn', 'bextr', 'tzcnt', +'bzhi', +'mulx', +'pdep', +'pext', 'rorx', 'sarx', 'shlx', diff --git a/compiler/x86_64/x8664int.inc b/compiler/x86_64/x8664int.inc index a11631c734..6cb5600fa1 100644 --- a/compiler/x86_64/x8664int.inc +++ b/compiler/x86_64/x8664int.inc @@ -1006,6 +1006,10 @@ 'andn', 'bextr', 'tzcnt', +'bzhi', +'mulx', +'pdep', +'pext', 'rorx', 'sarx', 'shlx', diff --git a/compiler/x86_64/x8664nop.inc b/compiler/x86_64/x8664nop.inc index 7cd4db7b89..01643f02f6 100644 --- a/compiler/x86_64/x8664nop.inc +++ b/compiler/x86_64/x8664nop.inc @@ -1,2 +1,2 @@ { don't edit, this file is generated from x86ins.dat } -2170; +2178; diff --git a/compiler/x86_64/x8664op.inc b/compiler/x86_64/x8664op.inc index 367524ba49..900cc53f1e 100644 --- a/compiler/x86_64/x8664op.inc +++ b/compiler/x86_64/x8664op.inc @@ -1006,6 +1006,10 @@ A_VZEROUPPER, A_ANDN, A_BEXTR, A_TZCNT, +A_BZHI, +A_MULX, +A_PDEP, +A_PEXT, A_RORX, A_SARX, A_SHLX, diff --git a/compiler/x86_64/x8664pro.inc b/compiler/x86_64/x8664pro.inc index de9d3ab58b..4a021d7f6d 100644 --- a/compiler/x86_64/x8664pro.inc +++ b/compiler/x86_64/x8664pro.inc @@ -1006,6 +1006,10 @@ (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Wop2, Ch_WFlags, Ch_Rop1]), +(Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), +(Ch: [Ch_REDX, Ch_Rop1, Ch_Wop2, Ch_Wop3]), +(Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), +(Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Rop1, Ch_Wop2]), (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), (Ch: [Ch_Rop1, Ch_Rop2, Ch_Wop3]), diff --git a/compiler/x86_64/x8664tab.inc b/compiler/x86_64/x8664tab.inc index ceeaa126de..70497214bd 100644 --- a/compiler/x86_64/x8664tab.inc +++ b/compiler/x86_64/x8664tab.inc @@ -13958,6 +13958,62 @@ code : #208#219#2#15#188#72; flags : [if_bmi1,if_sm] ), + ( + opcode : A_BZHI; + ops : 3; + optypes : (ot_reg32,ot_rm_gpr or ot_bits32,ot_reg32,ot_none); + code : #242#249#1#245#62#72; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_BZHI; + ops : 3; + optypes : (ot_reg64,ot_rm_gpr or ot_bits64,ot_reg64,ot_none); + code : #242#243#249#1#245#62#72; + flags : [if_bmi2,if_prot,if_x86_64] + ), + ( + opcode : A_MULX; + ops : 3; + optypes : (ot_reg32,ot_reg32,ot_rm_gpr or ot_bits32,ot_none); + code : #220#242#249#1#246#61#80; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_MULX; + ops : 3; + optypes : (ot_reg64,ot_reg64,ot_rm_gpr or ot_bits64,ot_none); + code : #220#242#243#249#1#246#61#80; + flags : [if_bmi2,if_prot,if_x86_64] + ), + ( + opcode : A_PDEP; + ops : 3; + optypes : (ot_reg32,ot_reg32,ot_rm_gpr or ot_bits32,ot_none); + code : #220#242#249#1#245#61#80; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_PDEP; + ops : 3; + optypes : (ot_reg64,ot_reg64,ot_rm_gpr or ot_bits64,ot_none); + code : #220#242#243#249#1#245#61#80; + flags : [if_bmi2,if_prot,if_x86_64] + ), + ( + opcode : A_PEXT; + ops : 3; + optypes : (ot_reg32,ot_reg32,ot_rm_gpr or ot_bits32,ot_none); + code : #219#242#249#1#245#61#80; + flags : [if_bmi2,if_prot] + ), + ( + opcode : A_PEXT; + ops : 3; + optypes : (ot_reg64,ot_reg64,ot_rm_gpr or ot_bits64,ot_none); + code : #219#242#243#249#1#245#61#80; + flags : [if_bmi2,if_prot,if_x86_64] + ), ( opcode : A_RORX; ops : 3; diff --git a/tests/utils/avx/avxopcodes.pas b/tests/utils/avx/avxopcodes.pas index 1d38dfcb9c..8e60032013 100644 --- a/tests/utils/avx/avxopcodes.pas +++ b/tests/utils/avx/avxopcodes.pas @@ -51,6 +51,14 @@ end; procedure TAVXTestGenerator.Init; begin + FOpCodeList.Add('BZHI,1,1,REG32,RM32,REG32,,'); + FOpCodeList.Add('BZHI,1,1,REG64,RM64,REG64,,'); + FOpCodeList.Add('MULX,1,1,REG32,REG32,RM32,,'); + FOpCodeList.Add('MULX,1,1,REG64,REG64,RM64,,'); + FOpCodeList.Add('PDEP,1,1,REG32,REG32,RM32,,'); + FOpCodeList.Add('PDEP,1,1,REG64,REG64,RM64,,'); + FOpCodeList.Add('PEXT,1,1,REG32,REG32,RM32,,'); + FOpCodeList.Add('PEXT,1,1,REG64,REG64,RM64,,'); FOpCodeList.Add('VADDPD,1,1,XMMREG,XMMREG,XMMRM,'); FOpCodeList.Add('VADDPD,1,1,YMMREG,YMMREG,YMMRM,'); FOpCodeList.Add('VADDPS,1,1,XMMREG,XMMREG,XMMRM,');