From bfaf1aea95a3bebeac739d8e86029aa8f8b16626 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Fri, 20 Dec 2024 16:55:49 -0500 Subject: [PATCH] clang: Switch 32bit register to register opcode to alternative 03f1 add esi, ecx 2bf3 sub esi, ebx 0ac8 or cl, al 23cd and ecx, ebp 3ac3 cmp al, bl 32d0 xor dl, al 13c9 adc ecx, ecx 1bd6 sbb edx, esi --- llvm/lib/Target/X86/X86InstrArithmetic.td | 48 +++++++++++------------ llvm/lib/Target/X86/X86InstrUtils.td | 36 +++++++++++++++++ 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/llvm/lib/Target/X86/X86InstrArithmetic.td b/llvm/lib/Target/X86/X86InstrArithmetic.td index 16ca2882a84daf0..11fac4fe721fafe 100644 --- a/llvm/lib/Target/X86/X86InstrArithmetic.td +++ b/llvm/lib/Target/X86/X86InstrArithmetic.td @@ -626,10 +626,10 @@ multiclass ArithBinOp_RF BaseOpc, bits<8> BaseOpc2, bits<8> BaseOpc4, let isCommutable = CommutableRR, isConvertibleToThreeAddress = ConvertibleToThreeAddressRR in { let Predicates = [NoNDD] in { - def 8rr : BinOpRR_RF; - def 16rr : BinOpRR_RF, OpSize16; - def 32rr : BinOpRR_RF, OpSize32; - def 64rr : BinOpRR_RF; + def 8rr : BW1_BinOpRR_RF; + def 16rr : BW1_BinOpRR_RF, OpSize16; + def 32rr : BW1_BinOpRR_RF, OpSize32; + def 64rr : BW1_BinOpRR_RF; } let Predicates = [HasNDD, In64BitMode] in { def 8rr_ND : BinOpRR_RF; @@ -653,10 +653,10 @@ multiclass ArithBinOp_RF BaseOpc, bits<8> BaseOpc2, bits<8> BaseOpc4, } } - def 8rr_REV : BinOpRR_RF_Rev; - def 16rr_REV : BinOpRR_RF_Rev, OpSize16; - def 32rr_REV : BinOpRR_RF_Rev, OpSize32; - def 64rr_REV : BinOpRR_RF_Rev; + def 8rr_REV : BW1_BinOpRR_RF_Rev; + def 16rr_REV : BW1_BinOpRR_RF_Rev, OpSize16; + def 32rr_REV : BW1_BinOpRR_RF_Rev, OpSize32; + def 64rr_REV : BW1_BinOpRR_RF_Rev; let Predicates = [In64BitMode] in { def 8rr_EVEX_REV : BinOpRR_RF_Rev, PL; def 16rr_EVEX_REV : BinOpRR_RF_Rev, PL, PD; @@ -844,11 +844,11 @@ multiclass ArithBinOp_RFF BaseOpc, bits<8> BaseOpc2, bits<8> BaseOpc4, bit ConvertibleToThreeAddress> { let isCommutable = CommutableRR in { let Predicates = [NoNDD] in { - def 8rr : BinOpRRF_RF; + def 8rr : BW1_BinOpRRF_RF; let isConvertibleToThreeAddress = ConvertibleToThreeAddress in { - def 16rr : BinOpRRF_RF, OpSize16; - def 32rr : BinOpRRF_RF, OpSize32; - def 64rr : BinOpRRF_RF; + def 16rr : BW1_BinOpRRF_RF, OpSize16; + def 32rr : BW1_BinOpRRF_RF, OpSize32; + def 64rr : BW1_BinOpRRF_RF; } } let Predicates = [HasNDD, In64BitMode] in { @@ -868,10 +868,10 @@ multiclass ArithBinOp_RFF BaseOpc, bits<8> BaseOpc2, bits<8> BaseOpc4, def 64rr_EVEX : BinOpRRF_RF, PL; } - def 8rr_REV : BinOpRRF_RF_Rev; - def 16rr_REV : BinOpRRF_RF_Rev, OpSize16; - def 32rr_REV : BinOpRRF_RF_Rev, OpSize32; - def 64rr_REV : BinOpRRF_RF_Rev; + def 8rr_REV : BW1_BinOpRRF_RF_Rev; + def 16rr_REV : BW1_BinOpRRF_RF_Rev, OpSize16; + def 32rr_REV : BW1_BinOpRRF_RF_Rev, OpSize32; + def 64rr_REV : BW1_BinOpRRF_RF_Rev; let Predicates = [In64BitMode] in { def 8rr_ND_REV : BinOpRRF_RF_Rev; def 16rr_ND_REV : BinOpRRF_RF_Rev, PD; @@ -1009,18 +1009,18 @@ multiclass ArithBinOp_F BaseOpc, bits<8> BaseOpc2, bits<8> BaseOpc4, SDNode opnode, bit CommutableRR, bit ConvertibleToThreeAddress> { let isCommutable = CommutableRR in { - def 8rr : BinOpRR_F; + def 8rr : BW1_BinOpRR_F; let isConvertibleToThreeAddress = ConvertibleToThreeAddress in { - def 16rr : BinOpRR_F, OpSize16; - def 32rr : BinOpRR_F, OpSize32; - def 64rr : BinOpRR_F; + def 16rr : BW1_BinOpRR_F, OpSize16; + def 32rr : BW1_BinOpRR_F, OpSize32; + def 64rr : BW1_BinOpRR_F; } // isConvertibleToThreeAddress } // isCommutable - def 8rr_REV : BinOpRR_F_Rev; - def 16rr_REV : BinOpRR_F_Rev, OpSize16; - def 32rr_REV : BinOpRR_F_Rev, OpSize32; - def 64rr_REV : BinOpRR_F_Rev; + def 8rr_REV : BW1_BinOpRR_F_Rev; + def 16rr_REV : BW1_BinOpRR_F_Rev, OpSize16; + def 32rr_REV : BW1_BinOpRR_F_Rev, OpSize32; + def 64rr_REV : BW1_BinOpRR_F_Rev; def 8rm : BinOpRM_F; def 16rm : BinOpRM_F, OpSize16; diff --git a/llvm/lib/Target/X86/X86InstrUtils.td b/llvm/lib/Target/X86/X86InstrUtils.td index ab171ac79fb377e..0775716a78e6e7b 100644 --- a/llvm/lib/Target/X86/X86InstrUtils.td +++ b/llvm/lib/Target/X86/X86InstrUtils.td @@ -984,6 +984,16 @@ class BinOpRR_F_Rev o, string m, X86TypeInfo t> : BinOpRR_F, DisassembleOnly { let Form = MRMSrcReg; } +class BW1_BinOpRR_F o, string m, X86TypeInfo t, SDPatternOperator node> + : BinOpRR, + DefEFLAGS { + let Form = MRMSrcReg; +} +class BW1_BinOpRR_F_Rev o, string m, X86TypeInfo t> + : BinOpRR_F, DisassembleOnly { + let Form = MRMDestReg; +} // BinOpRR_R - Instructions that read "reg, reg" and write "reg". class BinOpRR_R o, string m, X86TypeInfo t, bit ndd = 0> : BinOpRR o, string m, X86TypeInfo t, bit ndd = 0> : BinOpRR_RF, DisassembleOnly { let Form = MRMSrcReg; } + +class BW1_BinOpRR_RF o, string m, X86TypeInfo t, SDPatternOperator node, bit ndd = 0> + : BinOpRR, DefEFLAGS, NDD { + let Form = MRMSrcReg; +} +class BW1_BinOpRR_RF_Rev o, string m, X86TypeInfo t, bit ndd = 0> + : BinOpRR_RF, DisassembleOnly { + let Form = MRMDestReg; +} + // BinOpRRF_RF - Instructions that read "reg, reg", write "reg" and read/write // EFLAGS. class BinOpRRF_RF o, string m, X86TypeInfo t, SDPatternOperator node = null_frag, bit ndd = 0> @@ -1019,6 +1042,19 @@ class BinOpRRF_RF_Rev o, string m, X86TypeInfo t, bit ndd = 0> let Form = MRMSrcReg; } +class BW1_BinOpRRF_RF o, string m, X86TypeInfo t, SDPatternOperator node = null_frag, bit ndd = 0> + : BinOpRR, DefEFLAGS, UseEFLAGS, NDD { + let SchedRW = [WriteADC]; + let Form = MRMSrcReg; +} +class BW1_BinOpRRF_RF_Rev o, string m, X86TypeInfo t, bit ndd = 0> + : BinOpRRF_RF, DisassembleOnly { + let Form = MRMDestReg; +} + // BinOpRM - Instructions that read "reg, [mem]". class BinOpRM o, string m, string args, X86TypeInfo t, dag out, list p> : ITy