diff --git a/llvm/lib/Target/LoongArch/LoongArchInstrFormats.td b/llvm/lib/Target/LoongArch/LoongArchInstrFormats.td index 7c01776646e90..175a03e1d970d 100644 --- a/llvm/lib/Target/LoongArch/LoongArchInstrFormats.td +++ b/llvm/lib/Target/LoongArch/LoongArchInstrFormats.td @@ -16,7 +16,8 @@ // //===----------------------------------------------------------------------===// -class LAInst pattern = []> +class LAInst pattern = []> : Instruction { field bits<32> Inst; // SoftFail is a field the disassembler can use to provide a way for @@ -29,22 +30,23 @@ class LAInst pattern = []> let Size = 4; let OutOperandList = outs; let InOperandList = ins; - let AsmString = asmstr; + let AsmString = opcstr # "\t" # opnstr; let Pattern = pattern; } // Pseudo instructions -class Pseudo pattern = [], string asmstr = ""> - : LAInst { +class Pseudo pattern = [], string opcstr = "", + string opnstr = ""> + : LAInst { let isPseudo = 1; let isCodeGenOnly = 1; } // 2R-type // -class Fmt2R op, dag outs, dag ins, string asmstr, +class Fmt2R op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<5> rj; bits<5> rd; @@ -56,9 +58,9 @@ class Fmt2R op, dag outs, dag ins, string asmstr, // 3R-type // // -class Fmt3R op, dag outs, dag ins, string asmstr, +class Fmt3R op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<5> rk; bits<5> rj; bits<5> rd; @@ -69,9 +71,9 @@ class Fmt3R op, dag outs, dag ins, string asmstr, let Inst{4-0} = rd; } -class Fmt3FR op, dag outs, dag ins, string asmstr, +class Fmt3FR op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<5> fk; bits<5> fj; bits<5> fd; @@ -84,9 +86,9 @@ class Fmt3FR op, dag outs, dag ins, string asmstr, // 4R-type // -class Fmt4R op, dag outs, dag ins, string asmstr, +class Fmt4R op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<5> ra; bits<5> rk; bits<5> rj; @@ -101,9 +103,9 @@ class Fmt4R op, dag outs, dag ins, string asmstr, // 3RI2-type // -class Fmt3RI2 op, dag outs, dag ins, string asmstr, +class Fmt3RI2 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<2> imm2; bits<5> rk; bits<5> rj; @@ -118,9 +120,9 @@ class Fmt3RI2 op, dag outs, dag ins, string asmstr, // 3RI3-type // -class Fmt3RI3 op, dag outs, dag ins, string asmstr, +class Fmt3RI3 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<3> imm3; bits<5> rk; bits<5> rj; @@ -135,9 +137,9 @@ class Fmt3RI3 op, dag outs, dag ins, string asmstr, // 2RI5-type // -class Fmt2RI5 op, dag outs, dag ins, string asmstr, +class Fmt2RI5 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<5> imm5; bits<5> rj; bits<5> rd; @@ -150,9 +152,9 @@ class Fmt2RI5 op, dag outs, dag ins, string asmstr, // 2RI6-type // -class Fmt2RI6 op, dag outs, dag ins, string asmstr, +class Fmt2RI6 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<6> imm6; bits<5> rj; bits<5> rd; @@ -165,9 +167,9 @@ class Fmt2RI6 op, dag outs, dag ins, string asmstr, // 2RI8-type // -class Fmt2RI8 op, dag outs, dag ins, string asmstr, +class Fmt2RI8 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<8> imm8; bits<5> rj; bits<5> rd; @@ -180,9 +182,9 @@ class Fmt2RI8 op, dag outs, dag ins, string asmstr, // 2RI12-type // -class Fmt2RI12 op, dag outs, dag ins, string asmstr, +class Fmt2RI12 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<12> imm12; bits<5> rj; bits<5> rd; @@ -195,9 +197,9 @@ class Fmt2RI12 op, dag outs, dag ins, string asmstr, // 2RI14-type // -class Fmt2RI14 op, dag outs, dag ins, string asmstr, +class Fmt2RI14 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<14> imm14; bits<5> rj; bits<5> rd; @@ -210,9 +212,9 @@ class Fmt2RI14 op, dag outs, dag ins, string asmstr, // 2RI16-type // -class Fmt2RI16 op, dag outs, dag ins, string asmstr, +class Fmt2RI16 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<16> imm16; bits<5> rj; bits<5> rd; @@ -225,9 +227,9 @@ class Fmt2RI16 op, dag outs, dag ins, string asmstr, // 1RI20-type // -class Fmt1RI20 op, dag outs, dag ins, string asmstr, +class Fmt1RI20 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<20> imm20; bits<5> rd; @@ -238,9 +240,9 @@ class Fmt1RI20 op, dag outs, dag ins, string asmstr, // 1RI21-type // -class Fmt1RI21 op, dag outs, dag ins, string asmstr, +class Fmt1RI21 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<21> imm21; bits<5> rj; @@ -252,9 +254,9 @@ class Fmt1RI21 op, dag outs, dag ins, string asmstr, // I15-type // -class FmtI15 op, dag outs, dag ins, string asmstr, +class FmtI15 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<15> imm15; let Inst{31-15} = op; @@ -263,9 +265,9 @@ class FmtI15 op, dag outs, dag ins, string asmstr, // I26-type // -class FmtI26 op, dag outs, dag ins, string asmstr, +class FmtI26 op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<26> imm26; let Inst{31-26} = op; @@ -275,9 +277,9 @@ class FmtI26 op, dag outs, dag ins, string asmstr, // FmtBSTR_W // -class FmtBSTR_W op, dag outs, dag ins, string asmstr, +class FmtBSTR_W op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<5> msbw; bits<5> lsbw; bits<5> rj; @@ -293,9 +295,9 @@ class FmtBSTR_W op, dag outs, dag ins, string asmstr, // FmtBSTR_D // -class FmtBSTR_D op, dag outs, dag ins, string asmstr, +class FmtBSTR_D op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<6> msbd; bits<6> lsbd; bits<5> rj; @@ -310,9 +312,9 @@ class FmtBSTR_D op, dag outs, dag ins, string asmstr, // FmtASRT // -class FmtASRT op, dag outs, dag ins, string asmstr, +class FmtASRT op, dag outs, dag ins, string opcstr, string opnstr, list pattern = []> - : LAInst { + : LAInst { bits<5> rk; bits<5> rj; @@ -324,9 +326,9 @@ class FmtASRT op, dag outs, dag ins, string asmstr, // FmtPRELD // < 0b0010101011 | I12 | rj | I5> -class FmtPRELD pattern = []> - : LAInst { + : LAInst { bits<12> imm12; bits<5> rj; bits<5> imm5; @@ -339,9 +341,9 @@ class FmtPRELD -class FmtPRELDX pattern = []> - : LAInst { + : LAInst { bits<5> rk; bits<5> rj; bits<5> imm5; diff --git a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.td b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.td index 755e4389d839e..e718ebe9db3b1 100644 --- a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.td +++ b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.td @@ -116,98 +116,91 @@ include "LoongArchInstrFormats.td" // Instruction Class Templates //===----------------------------------------------------------------------===// class ALU_3R op, string opstr> - : Fmt3R; + : Fmt3R; class ALU_2R op, string opstr> - : Fmt2R; + : Fmt2R; class ALU_3RI2 op, string opstr, Operand ImmOpnd> - : Fmt3RI2; + : Fmt3RI2; class ALU_3RI3 op, string opstr, Operand ImmOpnd> - : Fmt3RI3; + : Fmt3RI3; class ALU_2RI5 op, string opstr, Operand ImmOpnd> - : Fmt2RI5; + : Fmt2RI5; class ALU_2RI6 op, string opstr, Operand ImmOpnd> - : Fmt2RI6; + : Fmt2RI6; class ALU_2RI12 op, string opstr, Operand ImmOpnd> - : Fmt2RI12; + : Fmt2RI12; class ALU_2RI16 op, string opstr, Operand ImmOpnd> - : Fmt2RI16; + : Fmt2RI16; class ALU_1RI20 op, string opstr, Operand ImmOpnd> - : Fmt1RI20; + : Fmt1RI20; class MISC_I15 op, string opstr> - : FmtI15; + : FmtI15; class RDTIME_2R op, string opstr> - : Fmt2R; + : Fmt2R; class BrCC_2RI16 op, string opstr> - : Fmt2RI16 { + : Fmt2RI16 { let isBranch = 1; let isTerminator = 1; } class BrCCZ_1RI21 op, string opstr> - : Fmt1RI21 { + : Fmt1RI21 { let isBranch = 1; let isTerminator = 1; } class Br_I26 op, string opstr> - : FmtI26 { + : FmtI26 { let isBranch = 1; let isTerminator = 1; } let mayLoad = 1 in { class LOAD_3R op, string opstr> - : Fmt3R; + : Fmt3R; class LOAD_2RI12 op, string opstr> - : Fmt2RI12; + : Fmt2RI12; class LOAD_2RI14 op, string opstr> - : Fmt2RI14; + : Fmt2RI14; } // mayLoad = 1 let mayStore = 1 in { class STORE_3R op, string opstr> - : Fmt3R; + : Fmt3R; class STORE_2RI12 op, string opstr> - : Fmt2RI12; + : Fmt2RI12; class STORE_2RI14 op, string opstr> - : Fmt2RI14; + : Fmt2RI14; } // mayStore = 1 let mayLoad = 1, mayStore = 1 in class AM_3R op, string opstr> - : Fmt3R; + : Fmt3R; let mayLoad = 1 in class LLBase op, string opstr> - : Fmt2RI14; + : Fmt2RI14; let mayStore = 1, Constraints = "$rd = $dst" in class SCBase op, string opstr> : Fmt2RI14; + opstr, "$rd, $rj, $imm14">; //===----------------------------------------------------------------------===// // Instructions @@ -268,11 +261,11 @@ def BITREV_W : ALU_2R<0b0000000000000000010100, "bitrev.w">; let Constraints = "$rd = $dst" in { def BSTRINS_W : FmtBSTR_W<0b000000000110, (outs GPR:$dst), (ins GPR:$rd, GPR:$rj, uimm5:$msbw, uimm5:$lsbw), - "bstrins.w\t$rd, $rj, $msbw, $lsbw">; + "bstrins.w", "$rd, $rj, $msbw, $lsbw">; } def BSTRPICK_W : FmtBSTR_W<0b000000000111, (outs GPR:$rd), (ins GPR:$rj, uimm5:$msbw, uimm5:$lsbw), - "bstrpick.w\t$rd, $rj, $msbw, $lsbw">; + "bstrpick.w", "$rd, $rj, $msbw, $lsbw">; def MASKEQZ : ALU_3R<0b00000000000100110, "maskeqz">; def MASKNEZ : ALU_3R<0b00000000000100111, "masknez">; @@ -288,10 +281,10 @@ def BNEZ : BrCCZ_1RI21<0b010001, "bnez">; def B : Br_I26<0b010100, "b">; let isCall = 1 in -def BL : FmtI26<0b010101, (outs), (ins simm26_lsl2:$imm26), "bl\t$imm26">; +def BL : FmtI26<0b010101, (outs), (ins simm26_lsl2:$imm26), "bl", "$imm26">; def JIRL : Fmt2RI16<0b010011, (outs GPR:$rd), - (ins GPR:$rj, simm16_lsl2:$imm16), - "jirl\t$rd, $rj, $imm16">; + (ins GPR:$rj, simm16_lsl2:$imm16), "jirl", + "$rd, $rj, $imm16">; // Common Memory Access Instructions def LD_B : LOAD_2RI12<0b0010100000, "ld.b">; @@ -302,8 +295,8 @@ def LD_HU : LOAD_2RI12<0b0010101001, "ld.hu">; def ST_B : STORE_2RI12<0b0010100100, "st.b">; def ST_H : STORE_2RI12<0b0010100101, "st.h">; def ST_W : STORE_2RI12<0b0010100110, "st.w">; -def PRELD : FmtPRELD<(outs), (ins uimm5:$imm5, GPR:$rj, simm12:$imm12), - "preld\t$imm5, $rj, $imm12">; +def PRELD : FmtPRELD<(outs), (ins uimm5:$imm5, GPR:$rj, simm12:$imm12), "preld", + "$imm5, $rj, $imm12">; // Atomic Memory Access Instructions def LL_W : LLBase<0b00100000, "ll.w">; @@ -333,8 +326,8 @@ def ALSL_WU : ALU_3RI2<0b000000000000011, "alsl.wu", uimm2_plus1>; def ALSL_D : ALU_3RI2<0b000000000010110, "alsl.d", uimm2_plus1>; let Constraints = "$rd = $dst" in { def LU32I_D : Fmt1RI20<0b0001011, (outs GPR:$dst), - (ins GPR:$rd, simm20:$imm20), - "lu32i.d\t$rd, $imm20">; + (ins GPR:$rd, simm20:$imm20), "lu32i.d", + "$rd, $imm20">; } def LU52I_D : ALU_2RI12<0b0000001100, "lu52i.d", simm12>; def PCADDU18I : ALU_1RI20<0b0001111, "pcaddu18i", simm20>; @@ -374,11 +367,11 @@ def BITREV_D : ALU_2R<0b0000000000000000010101, "bitrev.d">; let Constraints = "$rd = $dst" in { def BSTRINS_D : FmtBSTR_D<0b0000000010, (outs GPR:$dst), (ins GPR:$rd, GPR:$rj, uimm6:$msbd, uimm6:$lsbd), - "bstrins.d\t$rd, $rj, $msbd, $lsbd">; + "bstrins.d", "$rd, $rj, $msbd, $lsbd">; } def BSTRPICK_D : FmtBSTR_D<0b0000000011, (outs GPR:$rd), (ins GPR:$rj, uimm6:$msbd, uimm6:$lsbd), - "bstrpick.d\t$rd, $rj, $msbd, $lsbd">; + "bstrpick.d", "$rd, $rj, $msbd, $lsbd">; // Common Memory Access Instructions for 64-bits def LD_WU : LOAD_2RI12<0b0010101010, "ld.wu">; @@ -398,8 +391,8 @@ def LDPTR_W : LOAD_2RI14<0b00100100, "ldptr.w">; def LDPTR_D : LOAD_2RI14<0b00100110, "ldptr.d">; def STPTR_W : STORE_2RI14<0b00100101, "stptr.w">; def STPTR_D : STORE_2RI14<0b00100111, "stptr.d">; -def PRELDX : FmtPRELDX<(outs), (ins uimm5:$imm5, GPR:$rj, GPR:$rk), - "preldx\t$imm5, $rj, $rk">; +def PRELDX : FmtPRELDX<(outs), (ins uimm5:$imm5, GPR:$rj, GPR:$rk), "preldx", + "$imm5, $rj, $rk">; // Bound Check Memory Access Instructions def LDGT_B : LOAD_3R<0b00111000011110000, "ldgt.b">; @@ -471,9 +464,9 @@ def CRCC_W_D_W : ALU_3R<0b00000000001001111, "crcc.w.d.w">; // Other Miscellaneous Instructions for 64-bits def ASRTLE_D : FmtASRT<0b00000000000000010, (outs), (ins GPR:$rj, GPR:$rk), - "asrtle.d\t$rj, $rk">; + "asrtle.d", "$rj, $rk">; def ASRTGT_D : FmtASRT<0b00000000000000011, (outs), (ins GPR:$rj, GPR:$rk), - "asrtgt.d\t$rj, $rk">; + "asrtgt.d", "$rj, $rk">; def RDTIME_D : RDTIME_2R<0b0000000000000000011010, "rdtime.d">; } // Predicates = [IsLA64]