diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td @@ -114,11 +114,11 @@ defm : FPFMADynFrmAlias_m; let SchedRW = [WriteFALU64, ReadFALU64, ReadFALU64] in { -defm FADD_D : FPALU_rr_frm_m<0b0000001, "fadd.d", DINX>; +defm FADD_D : FPALU_rr_frm_m<0b0000001, "fadd.d", DINX, /*Commutable*/1>; defm FSUB_D : FPALU_rr_frm_m<0b0000101, "fsub.d", DINX>; } let SchedRW = [WriteFMul64, ReadFMul64, ReadFMul64] in -defm FMUL_D : FPALU_rr_frm_m<0b0001001, "fmul.d", DINX>; +defm FMUL_D : FPALU_rr_frm_m<0b0001001, "fmul.d", DINX, /*Commutable*/1>; let SchedRW = [WriteFDiv64, ReadFDiv64, ReadFDiv64] in defm FDIV_D : FPALU_rr_frm_m<0b0001101, "fdiv.d", DINX>; @@ -140,8 +140,8 @@ } let SchedRW = [WriteFMinMax64, ReadFMinMax64, ReadFMinMax64] in { -defm FMIN_D : FPALU_rr_m<0b0010101, 0b000, "fmin.d", DINX>; -defm FMAX_D : FPALU_rr_m<0b0010101, 0b001, "fmax.d", DINX>; +defm FMIN_D : FPALU_rr_m<0b0010101, 0b000, "fmin.d", DINX, /*Commutable*/1>; +defm FMAX_D : FPALU_rr_m<0b0010101, 0b001, "fmax.d", DINX, /*Commutable*/1>; } defm FCVT_S_D : FPUnaryOp_r_frm_m<0b0100000, 0b00001, FDINX, "fcvt.s.d">, @@ -152,7 +152,7 @@ Sched<[WriteFCvtF32ToF64, ReadFCvtF32ToF64]>; let SchedRW = [WriteFCmp64, ReadFCmp64, ReadFCmp64] in { -defm FEQ_D : FPCmp_rr_m<0b1010001, 0b010, "feq.d", DINX>; +defm FEQ_D : FPCmp_rr_m<0b1010001, 0b010, "feq.d", DINX, /*Commutable*/1>; defm FLT_D : FPCmp_rr_m<0b1010001, 0b001, "flt.d", DINX>; defm FLE_D : FPCmp_rr_m<0b1010001, 0b000, "fle.d", DINX>; } diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td @@ -187,28 +187,32 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0, mayRaiseFPException = 1 in class FPALU_rr funct7, bits<3> funct3, string opcodestr, - DAGOperand rty> + DAGOperand rty, bit Commutable> : RVInstR; + (ins rty:$rs1, rty:$rs2), opcodestr, "$rd, $rs1, $rs2"> { + let isCommutable = Commutable; +} multiclass FPALU_rr_m funct7, bits<3> funct3, string opcodestr, - list Exts> { + list Exts, bit Commutable = 0> { foreach Ext = Exts in let Predicates = Ext.Predicates, DecoderNamespace = Ext.Space in - def Ext.Suffix : FPALU_rr; + def Ext.Suffix : FPALU_rr; } let hasSideEffects = 0, mayLoad = 0, mayStore = 0, mayRaiseFPException = 1, UseNamedOperandTable = 1, hasPostISelHook = 1 in -class FPALU_rr_frm funct7, string opcodestr, DAGOperand rty> +class FPALU_rr_frm funct7, string opcodestr, DAGOperand rty, + bit Commutable> : RVInstRFrm; - + "$rd, $rs1, $rs2, $frm"> { + let isCommutable = Commutable; +} multiclass FPALU_rr_frm_m funct7, string opcodestr, - list Exts> { + list Exts, bit Commutable = 0> { foreach Ext = Exts in let Predicates = Ext.Predicates, DecoderNamespace = Ext.Space in - def Ext.Suffix : FPALU_rr_frm; + def Ext.Suffix : FPALU_rr_frm; } class FPALUDynFrmAlias funct7, bits<3> funct3, string opcodestr, - DAGOperand rty> + DAGOperand rty, bit Commutable> : RVInstR; + (ins rty:$rs1, rty:$rs2), opcodestr, "$rd, $rs1, $rs2"> { + let isCommutable = Commutable; +} multiclass FPCmp_rr_m funct7, bits<3> funct3, string opcodestr, - list Exts> { + list Exts, bit Commutable = 0> { foreach Ext = Exts in let Predicates = Ext.Predicates, DecoderNamespace = Ext.Space in - def Ext.Suffix : FPCmp_rr; + def Ext.Suffix : FPCmp_rr; } //===----------------------------------------------------------------------===// @@ -305,11 +311,11 @@ defm : FPFMADynFrmAlias_m; let SchedRW = [WriteFALU32, ReadFALU32, ReadFALU32] in { -defm FADD_S : FPALU_rr_frm_m<0b0000000, "fadd.s", FINX>; +defm FADD_S : FPALU_rr_frm_m<0b0000000, "fadd.s", FINX, /*Commutable*/1>; defm FSUB_S : FPALU_rr_frm_m<0b0000100, "fsub.s", FINX>; } let SchedRW = [WriteFMul32, ReadFMul32, ReadFMul32] in -defm FMUL_S : FPALU_rr_frm_m<0b0001000, "fmul.s", FINX>; +defm FMUL_S : FPALU_rr_frm_m<0b0001000, "fmul.s", FINX, /*Commutable*/1>; let SchedRW = [WriteFDiv32, ReadFDiv32, ReadFDiv32] in defm FDIV_S : FPALU_rr_frm_m<0b0001100, "fdiv.s", FINX>; @@ -331,8 +337,8 @@ } let SchedRW = [WriteFMinMax32, ReadFMinMax32, ReadFMinMax32] in { -defm FMIN_S : FPALU_rr_m<0b0010100, 0b000, "fmin.s", FINX>; -defm FMAX_S : FPALU_rr_m<0b0010100, 0b001, "fmax.s", FINX>; +defm FMIN_S : FPALU_rr_m<0b0010100, 0b000, "fmin.s", FINX, /*Commutable*/1>; +defm FMAX_S : FPALU_rr_m<0b0010100, 0b001, "fmax.s", FINX, /*Commutable*/1>; } defm FCVT_W_S : FPUnaryOp_r_frm_m<0b1100000, 0b00000, XFINX, "fcvt.w.s">, @@ -348,7 +354,7 @@ Sched<[WriteFMovF32ToI32, ReadFMovF32ToI32]>; let SchedRW = [WriteFCmp32, ReadFCmp32, ReadFCmp32] in { -defm FEQ_S : FPCmp_rr_m<0b1010000, 0b010, "feq.s", FINX>; +defm FEQ_S : FPCmp_rr_m<0b1010000, 0b010, "feq.s", FINX, /*Commutable*/1>; defm FLT_S : FPCmp_rr_m<0b1010000, 0b001, "flt.s", FINX>; defm FLE_S : FPCmp_rr_m<0b1010000, 0b000, "fle.s", FINX>; } diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td @@ -109,11 +109,11 @@ defm : FPFMADynFrmAlias_m; let SchedRW = [WriteFALU16, ReadFALU16, ReadFALU16] in { -defm FADD_H : FPALU_rr_frm_m<0b0000010, "fadd.h", HINX>; +defm FADD_H : FPALU_rr_frm_m<0b0000010, "fadd.h", HINX, /*Commutable*/1>; defm FSUB_H : FPALU_rr_frm_m<0b0000110, "fsub.h", HINX>; } let SchedRW = [WriteFMul16, ReadFMul16, ReadFMul16] in -defm FMUL_H : FPALU_rr_frm_m<0b0001010, "fmul.h", HINX>; +defm FMUL_H : FPALU_rr_frm_m<0b0001010, "fmul.h", HINX, /*Commutable*/1>; let SchedRW = [WriteFDiv16, ReadFDiv16, ReadFDiv16] in defm FDIV_H : FPALU_rr_frm_m<0b0001110, "fdiv.h", HINX>; @@ -135,8 +135,8 @@ } let SchedRW = [WriteFMinMax16, ReadFMinMax16, ReadFMinMax16] in { -defm FMIN_H : FPALU_rr_m<0b0010110, 0b000, "fmin.h", HINX>; -defm FMAX_H : FPALU_rr_m<0b0010110, 0b001, "fmax.h", HINX>; +defm FMIN_H : FPALU_rr_m<0b0010110, 0b000, "fmin.h", HINX, /*Commutable*/1>; +defm FMAX_H : FPALU_rr_m<0b0010110, 0b001, "fmax.h", HINX, /*Commutable*/1>; } defm FCVT_W_H : FPUnaryOp_r_frm_m<0b1100010, 0b00000, XHINX, "fcvt.w.h">,