Index: lib/Target/Mips/MipsInstrInfo.td =================================================================== --- lib/Target/Mips/MipsInstrInfo.td +++ lib/Target/Mips/MipsInstrInfo.td @@ -705,6 +705,13 @@ let ParserMatchClass = ConstantUImm5ReportUImm6AsmOperandClass; } +foreach I = {1, 2, 3, 4} in + def uimm # I # _ptr : Operand { + let PrintMethod = "printUImm<" # I # ">"; + let ParserMatchClass = + !cast("ConstantUImm" # I # "AsmOperandClass"); + } + // Signed operands foreach I = {4} in def simm # I : Operand { Index: lib/Target/Mips/MipsMSAInstrInfo.td =================================================================== --- lib/Target/Mips/MipsMSAInstrInfo.td +++ lib/Target/Mips/MipsMSAInstrInfo.td @@ -65,19 +65,11 @@ def immZExt1Ptr : ImmLeaf(Imm);}]>; def immZExt2Ptr : ImmLeaf(Imm);}]>; +def immZExt3Ptr : ImmLeaf(Imm);}]>; def immZExt4Ptr : ImmLeaf(Imm);}]>; -def immZExt6Ptr : ImmLeaf(Imm);}]>; // Operands -def uimm4_ptr : Operand { - let PrintMethod = "printUImm<8>"; -} - -def uimm6_ptr : Operand { - let PrintMethod = "printUImm<8>"; -} - def simm5 : Operand; def vsplat_uimm1 : Operand { @@ -1225,13 +1217,13 @@ } class MSA_COPY_DESC_BASE { dag OutOperandList = (outs ROD:$rd); - dag InOperandList = (ins ROWS:$ws, uimm4_ptr:$n); + dag InOperandList = (ins ROWS:$ws, ImmOp:$n); string AsmString = !strconcat(instr_asm, "\t$rd, $ws[$n]"); - list Pattern = [(set ROD:$rd, (OpNode (VecTy ROWS:$ws), immZExt4Ptr:$n))]; + list Pattern = [(set ROD:$rd, (OpNode (VecTy ROWS:$ws), Imm:$n))]; InstrItinClass Itinerary = itin; } @@ -1249,9 +1241,10 @@ } class MSA_COPY_PSEUDO_BASE : - MSAPseudo<(outs RCD:$wd), (ins RCWS:$ws, uimm4_ptr:$n), - [(set RCD:$wd, (OpNode (VecTy RCWS:$ws), immZExt4Ptr:$n))]> { + Operand ImmOp, ImmLeaf Imm, RegisterClass RCD, + RegisterClass RCWS> : + MSAPseudo<(outs RCD:$wd), (ins RCWS:$ws, ImmOp:$n), + [(set RCD:$wd, (OpNode (VecTy RCWS:$ws), Imm:$n))]> { bit usesCustomInserter = 1; } @@ -1433,23 +1426,22 @@ } class MSA_INSERT_DESC_BASE { dag OutOperandList = (outs ROWD:$wd); - dag InOperandList = (ins ROWD:$wd_in, ROS:$rs, uimm6_ptr:$n); + dag InOperandList = (ins ROWD:$wd_in, ROS:$rs, ImmOp:$n); string AsmString = !strconcat(instr_asm, "\t$wd[$n], $rs"); - list Pattern = [(set ROWD:$wd, (OpNode ROWD:$wd_in, - ROS:$rs, - immZExt6Ptr:$n))]; + list Pattern = [(set ROWD:$wd, (OpNode ROWD:$wd_in, ROS:$rs, Imm:$n))]; InstrItinClass Itinerary = itin; string Constraints = "$wd = $wd_in"; } class MSA_INSERT_PSEUDO_BASE : - MSAPseudo<(outs ROWD:$wd), (ins ROWD:$wd_in, uimm6_ptr:$n, ROFS:$fs), - [(set ROWD:$wd, (OpNode (Ty ROWD:$wd_in), ROFS:$fs, - immZExt6Ptr:$n))]> { + Operand ImmOp, ImmLeaf Imm, RegisterOperand ROWD, + RegisterOperand ROFS> : + MSAPseudo<(outs ROWD:$wd), (ins ROWD:$wd_in, ImmOp:$n, ROFS:$fs), + [(set ROWD:$wd, (OpNode (Ty ROWD:$wd_in), ROFS:$fs, Imm:$n))]> { bit usesCustomInserter = 1; string Constraints = "$wd = $wd_in"; } @@ -1867,24 +1859,33 @@ vsplati64_uimm5, MSA128DOpnd>; class COPY_S_B_DESC : MSA_COPY_DESC_BASE<"copy_s.b", vextract_sext_i8, v16i8, - GPR32Opnd, MSA128BOpnd>; + uimm4_ptr, immZExt4Ptr, GPR32Opnd, + MSA128BOpnd>; class COPY_S_H_DESC : MSA_COPY_DESC_BASE<"copy_s.h", vextract_sext_i16, v8i16, - GPR32Opnd, MSA128HOpnd>; + uimm3_ptr, immZExt3Ptr, GPR32Opnd, + MSA128HOpnd>; class COPY_S_W_DESC : MSA_COPY_DESC_BASE<"copy_s.w", vextract_sext_i32, v4i32, - GPR32Opnd, MSA128WOpnd>; + uimm2_ptr, immZExt2Ptr, GPR32Opnd, + MSA128WOpnd>; class COPY_S_D_DESC : MSA_COPY_DESC_BASE<"copy_s.d", vextract_sext_i64, v2i64, - GPR64Opnd, MSA128DOpnd>; + uimm1_ptr, immZExt1Ptr, GPR64Opnd, + MSA128DOpnd>; class COPY_U_B_DESC : MSA_COPY_DESC_BASE<"copy_u.b", vextract_zext_i8, v16i8, - GPR32Opnd, MSA128BOpnd>; + uimm4_ptr, immZExt4Ptr, GPR32Opnd, + MSA128BOpnd>; class COPY_U_H_DESC : MSA_COPY_DESC_BASE<"copy_u.h", vextract_zext_i16, v8i16, - GPR32Opnd, MSA128HOpnd>; + uimm3_ptr, immZExt3Ptr, GPR32Opnd, + MSA128HOpnd>; class COPY_U_W_DESC : MSA_COPY_DESC_BASE<"copy_u.w", vextract_zext_i32, v4i32, - GPR32Opnd, MSA128WOpnd>; + uimm2_ptr, immZExt2Ptr, GPR32Opnd, + MSA128WOpnd>; -class COPY_FW_PSEUDO_DESC : MSA_COPY_PSEUDO_BASE; -class COPY_FD_PSEUDO_DESC : MSA_COPY_PSEUDO_BASE; class CTCMSA_DESC { @@ -2249,14 +2250,14 @@ class ILVR_W_DESC : MSA_3R_DESC_BASE<"ilvr.w", MipsILVR, MSA128WOpnd>; class ILVR_D_DESC : MSA_3R_DESC_BASE<"ilvr.d", MipsILVR, MSA128DOpnd>; -class INSERT_B_DESC : MSA_INSERT_DESC_BASE<"insert.b", vinsert_v16i8, - MSA128BOpnd, GPR32Opnd>; -class INSERT_H_DESC : MSA_INSERT_DESC_BASE<"insert.h", vinsert_v8i16, - MSA128HOpnd, GPR32Opnd>; -class INSERT_W_DESC : MSA_INSERT_DESC_BASE<"insert.w", vinsert_v4i32, - MSA128WOpnd, GPR32Opnd>; -class INSERT_D_DESC : MSA_INSERT_DESC_BASE<"insert.d", vinsert_v2i64, - MSA128DOpnd, GPR64Opnd>; +class INSERT_B_DESC : MSA_INSERT_DESC_BASE<"insert.b", vinsert_v16i8, uimm4, + immZExt4Ptr, MSA128BOpnd, GPR32Opnd>; +class INSERT_H_DESC : MSA_INSERT_DESC_BASE<"insert.h", vinsert_v8i16, uimm3, + immZExt3Ptr, MSA128HOpnd, GPR32Opnd>; +class INSERT_W_DESC : MSA_INSERT_DESC_BASE<"insert.w", vinsert_v4i32, uimm2, + immZExt2Ptr, MSA128WOpnd, GPR32Opnd>; +class INSERT_D_DESC : MSA_INSERT_DESC_BASE<"insert.d", vinsert_v2i64, uimm1, + immZExt1Ptr, MSA128DOpnd, GPR64Opnd>; class INSERT_B_VIDX_PSEUDO_DESC : MSA_INSERT_VIDX_PSEUDO_BASE; @@ -2268,8 +2269,10 @@ MSA_INSERT_VIDX_PSEUDO_BASE; class INSERT_FW_PSEUDO_DESC : MSA_INSERT_PSEUDO_BASE; class INSERT_FD_PSEUDO_DESC : MSA_INSERT_PSEUDO_BASE; class INSERT_FW_VIDX_PSEUDO_DESC : Index: test/MC/Mips/msa/invalid.s =================================================================== --- test/MC/Mips/msa/invalid.s +++ test/MC/Mips/msa/invalid.s @@ -5,6 +5,28 @@ # RUN: FileCheck %s < %t1 .set noat + copy_s.b $2, $w9[-1] # CHECK: :[[@LINE]]:22: error: expected 4-bit unsigned immediate + copy_s.b $2, $w9[16] # CHECK: :[[@LINE]]:22: error: expected 4-bit unsigned immediate + copy_s.h $2, $w9[-1] # CHECK: :[[@LINE]]:22: error: expected 3-bit unsigned immediate + copy_s.h $2, $w9[8] # CHECK: :[[@LINE]]:22: error: expected 3-bit unsigned immediate + copy_s.w $2, $w9[-1] # CHECK: :[[@LINE]]:22: error: expected 2-bit unsigned immediate + copy_s.w $2, $w9[4] # CHECK: :[[@LINE]]:22: error: expected 2-bit unsigned immediate + copy_s.d $2, $w9[-1] # CHECK: :[[@LINE]]:22: error: expected 1-bit unsigned immediate + copy_s.d $2, $w9[2] # CHECK: :[[@LINE]]:22: error: expected 1-bit unsigned immediate + copy_u.b $2, $w9[-1] # CHECK: :[[@LINE]]:22: error: expected 4-bit unsigned immediate + copy_u.b $2, $w9[16] # CHECK: :[[@LINE]]:22: error: expected 4-bit unsigned immediate + copy_u.h $2, $w9[-1] # CHECK: :[[@LINE]]:22: error: expected 3-bit unsigned immediate + copy_u.h $2, $w9[8] # CHECK: :[[@LINE]]:22: error: expected 3-bit unsigned immediate + copy_u.w $2, $w9[-1] # CHECK: :[[@LINE]]:22: error: expected 2-bit unsigned immediate + copy_u.w $2, $w9[4] # CHECK: :[[@LINE]]:22: error: expected 2-bit unsigned immediate + insert.b $w9[-1], $2 # CHECK: :[[@LINE]]:18: error: expected 4-bit unsigned immediate + insert.b $w9[16], $2 # CHECK: :[[@LINE]]:18: error: expected 4-bit unsigned immediate + insert.h $w9[-1], $2 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate + insert.h $w9[8], $2 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate + insert.w $w9[-1], $2 # CHECK: :[[@LINE]]:18: error: expected 2-bit unsigned immediate + insert.w $w9[4], $2 # CHECK: :[[@LINE]]:18: error: expected 2-bit unsigned immediate + insert.d $w9[-1], $2 # CHECK: :[[@LINE]]:18: error: expected 1-bit unsigned immediate + insert.d $w9[2], $2 # CHECK: :[[@LINE]]:18: error: expected 1-bit unsigned immediate insve.b $w25[-1], $w9[0] # CHECK: :[[@LINE]]:18: error: expected 4-bit unsigned immediate insve.b $w25[16], $w9[0] # CHECK: :[[@LINE]]:18: error: expected 4-bit unsigned immediate insve.h $w24[-1], $w2[0] # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate