[llvm] [RISCV] Add contraints for SpacemiT X60 AI Dot Insts (PR #174364)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 4 22:31:42 PST 2026


https://github.com/LiqinWeng created https://github.com/llvm/llvm-project/pull/174364

Spec: https://developer.spacemit.com/documentation?token=BWbGwbx7liGW21kq9lucSA6Vnpb#2.1

>From dd66df49a640f48dfcd499c9081f4c95363465ce Mon Sep 17 00:00:00 2001
From: wengliqin <liqin.weng at spacemit.com>
Date: Mon, 5 Jan 2026 14:22:46 +0800
Subject: [PATCH] [RISCV] Add contraints for SpacemiT X60 AI Dot Insts

Spec: https://developer.spacemit.com/documentation?token=BWbGwbx7liGW21kq9lucSA6Vnpb#2.1
---
 .gitignore                                    |   3 +
 .../Target/RISCV/AsmParser/RISCVAsmParser.cpp |  58 ++++++-
 .../RISCV/RISCVInstrFormatsSpacemitV.td       | 101 +++++++++++
 .../Target/RISCV/RISCVInstrInfoXSpacemiT.td   | 160 ++++--------------
 llvm/test/MC/RISCV/xsmtvdot-invalid.s         |  81 ++++-----
 llvm/test/MC/RISCV/xsmtvdot-valid.s           | 160 +++++++++---------
 6 files changed, 300 insertions(+), 263 deletions(-)
 create mode 100644 llvm/lib/Target/RISCV/RISCVInstrFormatsSpacemitV.td

diff --git a/.gitignore b/.gitignore
index 43b551ad2d133..0ce2e5c0141f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -81,3 +81,6 @@ pythonenv*
 /clang/utils/analyzer/projects/*/RefScanBuildResults
 # automodapi puts generated documentation files here.
 /lldb/docs/python_api/
+
+# Snyk Security Extension - AI Rules (auto-generated)
+.github/instructions/snyk_rules.instructions.md
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 9bb3724c96c11..8b2a3f5f3808d 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -352,6 +352,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
 
   struct RegOp {
     MCRegister Reg;
+    std::optional<std::pair<MCRegister, unsigned>> RegPairNum;
     bool IsGPRAsFPR;
   };
 
@@ -1092,10 +1093,13 @@ struct RISCVOperand final : public MCParsedAsmOperand {
   }
 
   static std::unique_ptr<RISCVOperand>
-  createReg(MCRegister Reg, SMLoc S, SMLoc E, bool IsGPRAsFPR = false) {
+  createReg(MCRegister Reg, SMLoc S, SMLoc E, bool IsGPRAsFPR = false,
+            std::optional<std::pair<MCRegister, unsigned>> RegPairNum =
+                std::nullopt) {
     auto Op = std::make_unique<RISCVOperand>(KindTy::Register);
     Op->Reg.Reg = Reg;
     Op->Reg.IsGPRAsFPR = IsGPRAsFPR;
+    Op->Reg.RegPairNum = RegPairNum;
     Op->StartLoc = S;
     Op->EndLoc = E;
     return Op;
@@ -1316,6 +1320,15 @@ static MCRegister convertVRToVRMx(const MCRegisterInfo &RI, MCRegister Reg,
                                 &RISCVMCRegisterClasses[RegClassID]);
 }
 
+static int getLMUL(unsigned Kind) {
+  if (Kind == MCK_VRM2)
+    return 2;
+  else if (Kind == MCK_VRM4)
+    return 4;
+  else
+    return 8;
+}
+
 unsigned RISCVAsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
                                                     unsigned Kind) {
   RISCVOperand &Op = static_cast<RISCVOperand &>(AsmOp);
@@ -1367,7 +1380,14 @@ unsigned RISCVAsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
   // As the parser couldn't differentiate an VRM2/VRM4/VRM8 from an VR, coerce
   // the register from VR to VRM2/VRM4/VRM8 if necessary.
   if (IsRegVR && (Kind == MCK_VRM2 || Kind == MCK_VRM4 || Kind == MCK_VRM8)) {
+    // The dest reg requires multiple registers to be combined to complete the
+    // instruction operation. In this case, it is necessary to retain the
+    // register num ​​of the dest register before the conversion to ensure
+    // that 'the destination vector register group cannot overlap the source
+    // vector register group'
     Op.Reg.Reg = convertVRToVRMx(*getContext().getRegisterInfo(), Reg, Kind);
+    auto DstGroup = std::make_pair(Reg, getLMUL(Kind));
+    Op.Reg.RegPairNum.emplace(DstGroup);
     if (!Op.Reg.Reg)
       return Match_InvalidOperand;
     return Match_Success;
@@ -3775,6 +3795,15 @@ std::unique_ptr<RISCVOperand> RISCVAsmParser::defaultFRMArgLegacyOp() const {
                                     llvm::SMLoc());
 }
 
+static MCRegister getBeforeConvertRegNum(MCParsedAsmOperand &Operand,
+                                         MCRegister defaultReg) {
+  RISCVOperand &Op = static_cast<RISCVOperand &>(Operand);
+  if (Op.Reg.RegPairNum.has_value()) {
+    return Op.Reg.RegPairNum.value().first;
+  }
+  return defaultReg;
+}
+
 bool RISCVAsmParser::validateInstruction(MCInst &Inst,
                                          OperandVector &Operands) {
   unsigned Opcode = Inst.getOpcode();
@@ -3836,6 +3865,14 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
   }
 
   MCRegister DestReg = Inst.getOperand(0).getReg();
+  MCParsedAsmOperand &Vd = *Operands[1];
+  RISCVOperand &Dst = static_cast<RISCVOperand &>(Vd);
+  unsigned Lmul = 1;
+  if (Dst.Reg.RegPairNum.has_value()) {
+    DestReg = Dst.Reg.RegPairNum.value().first;
+    Lmul = Dst.Reg.RegPairNum.value().second;
+  }
+
   unsigned Offset = 0;
   int TiedOp = MCID.getOperandConstraint(1, MCOI::TIED_TO);
   if (TiedOp == 0)
@@ -3844,16 +3881,21 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
   // Operands[1] will be the first operand, DestReg.
   SMLoc Loc = Operands[1]->getStartLoc();
   if (MCID.TSFlags & RISCVII::VS2Constraint) {
-    MCRegister CheckReg = Inst.getOperand(Offset + 1).getReg();
-    if (DestReg == CheckReg)
-      return Error(Loc, "the destination vector register group cannot overlap"
-                        " the source vector register group");
+    MCRegister CheckReg = getBeforeConvertRegNum(
+        *Operands[2], Inst.getOperand(Offset + 1).getReg());
+    for (unsigned i = 0; i < Lmul; i++) {
+      if ((DestReg + i) == CheckReg)
+        return Error(Loc, "the destination vector register group cannot overlap"
+                          " the source vector register group");
+    }
   }
   if ((MCID.TSFlags & RISCVII::VS1Constraint) && Inst.getOperand(Offset + 2).isReg()) {
     MCRegister CheckReg = Inst.getOperand(Offset + 2).getReg();
-    if (DestReg == CheckReg)
-      return Error(Loc, "the destination vector register group cannot overlap"
-                        " the source vector register group");
+    for (unsigned i = 0; i < Lmul; i++) {
+      if ((DestReg + i) == CheckReg)
+        return Error(Loc, "the destination vector register group cannot overlap"
+                          " the source vector register group");
+    }
   }
   if ((MCID.TSFlags & RISCVII::VMConstraint) && (DestReg == RISCV::V0)) {
     // vadc, vsbc are special cases. These instructions have no mask register.
diff --git a/llvm/lib/Target/RISCV/RISCVInstrFormatsSpacemitV.td b/llvm/lib/Target/RISCV/RISCVInstrFormatsSpacemitV.td
new file mode 100644
index 0000000000000..9c3774f3b54a9
--- /dev/null
+++ b/llvm/lib/Target/RISCV/RISCVInstrFormatsSpacemitV.td
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+//  This file describes the RISCV SPACEMIT RVV extension instruction formats.
+//
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+// RISCV SPACEMIT RVV class templates
+//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
+// Operand definitions.
+//===----------------------------------------------------------------------===//
+
+class SMTVDotOpcode<bits<7> val> { bits<7> Value = val; }
+def OPMMA : SMTVDotOpcode<0b1110001>;
+def OPMMA_SLIDE : SMTVDotOpcode<0b1110011>;
+
+//===----------------------------------------------------------------------===//
+// Vector Dot-Product Sign Encoding
+// Defines the signed/unsigned mixing modes for vector dot-product operations.
+// Encoding format: [1:0] bits
+//   00: UU (Unsigned x Unsigned)
+//   01: US (Unsigned x Signed)
+//   10: SU (Signed x Unsigned)
+//   11: SS (Signed x Signed)
+//===----------------------------------------------------------------------===//
+
+class VTypeEncode<bits<2> encoding, string name> {
+  bits<2> Encoding = encoding;
+  string Name = name;
+}
+defvar VTypeEncodes = [VTypeEncode<0b00, "u">,
+                       VTypeEncode<0b01, "us">,
+                       VTypeEncode<0b10, "su">,
+                       VTypeEncode<0b11, "">];
+
+//===----------------------------------------------------------------------===//
+// Vector Dot-Product Sliding Window Modes
+// Encoding format: [1:0] bits
+//   00: Slide1 (1-element sliding stride)
+//   01: Slide2 (2-element sliding stride)
+//   10: Slide3 (3-element sliding stride)
+//   11: Reserved
+//
+// Used in sliding-window dot-product operations:
+//   vd = vs1 • vs2.slide{1|2|3}  // • = dot product
+//===----------------------------------------------------------------------===//
+class SlideEncode<bits<2> encoding, string name> {
+  bits<2> Encoding = encoding;
+  string Name = name;
+}
+
+defvar SlideEncodes = [SlideEncode<0b00, "1">,
+                       SlideEncode<0b01, "2">,
+                       SlideEncode<0b10, "3">];
+
+//===----------------------------------------------------------------------===//
+// Instruction formats
+//===----------------------------------------------------------------------===//
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
+  // Base vector dot product (no slide) format.
+  class SMTVMADot<bits<2> sign, string opcodestr, bit EarlyClobber = 0>
+      : RVInst<(outs VRM2:$vd_wb), (ins VRM2:$vd, VR:$vs1, VR:$vs2),
+               opcodestr, "$vd, $vs1, $vs2", [], InstFormatR> {
+    bits<5> vd;
+    bits<5> vs1;
+    bits<5> vs2;
+
+    let Inst{31-25} = OPMMA.Value;
+    let Inst{24-20} = vs2;
+    let Inst{19-15} = vs1;
+    let Inst{14} = 0b0;
+    let Inst{13-12} = sign;
+    let Inst{11-7} = vd;
+    let Inst{6-0} = OPC_CUSTOM_1.Value;
+    let Constraints =
+        !if(EarlyClobber, "@earlyclobber $vd_wb, $vd = $vd_wb", "$vd = $vd_wb");
+  }
+
+  // Sliding-window vector dot product format.
+  class SMTVMADotSlide<bits<2> funct2, bits<2> sign, string opcodestr,
+                       bit EarlyClobber = 0>
+      : RVInst<(outs VRM2:$vd_wb), (ins VRM2:$vd, VRM2:$vs1, VR:$vs2),
+               opcodestr, "$vd, $vs1, $vs2", [], InstFormatR> {
+    bits<5> vd;
+    bits<5> vs1;
+    bits<5> vs2;
+
+    let Inst{31-25} = OPMMA_SLIDE.Value;
+    let Inst{24-20} = vs2;
+    let Inst{19-16} = vs1{4-1};
+    let Inst{15-14} = funct2;
+    let Inst{13-12} = sign;
+    let Inst{11-7} = vd;
+    let Inst{6-0} = OPC_CUSTOM_1.Value;
+    let Constraints =
+        !if(EarlyClobber, "@earlyclobber $vd_wb, $vd = $vd_wb", "$vd = $vd_wb");
+  }
+}
+
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXSpacemiT.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXSpacemiT.td
index 0f9b795069b98..4a12fda4a6baa 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXSpacemiT.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXSpacemiT.td
@@ -10,132 +10,40 @@
 //
 //===----------------------------------------------------------------------===//
 
-//===----------------------------------------------------------------------===//
-// Operand definitions.
-//===----------------------------------------------------------------------===//
-
-class SMTVDotOpcode<bits<7> val> {
-  bits<7> Value = val;
-}
-
-class SMTVEncoding2<bits<2> val> {
-  bits<2> Value = val;
-}
-
-def OPMMA       : SMTVDotOpcode<0b1110001>;
-def OPMMA_SLIDE : SMTVDotOpcode<0b1110011>;
-
-//===----------------------------------------------------------------------===//
-// Vector Dot-Product Sign Encoding
-// Defines the signed/unsigned mixing modes for vector dot-product operations.
-// Encoding format: [1:0] bits
-//   00: UU (Unsigned x Unsigned)
-//   01: US (Unsigned x Signed)
-//   10: SU (Signed x Unsigned)
-//   11: SS (Signed x Signed)
-//===----------------------------------------------------------------------===//
-def SMT_VDot_UU        : SMTVEncoding2<0b00>;
-def SMT_VDot_US        : SMTVEncoding2<0b01>;
-def SMT_VDot_SU        : SMTVEncoding2<0b10>;
-def SMT_VDot_SS        : SMTVEncoding2<0b11>;
-
-//===----------------------------------------------------------------------===//
-// Vector Dot-Product Sliding Window Modes
-// Encoding format: [1:0] bits
-//   00: Slide1 (1-element sliding stride)
-//   01: Slide2 (2-element sliding stride)
-//   10: Slide3 (3-element sliding stride)
-//   11: Reserved
-//
-// Used in sliding-window dot-product operations:
-//   vd = vs1 • vs2.slide{1|2|3}  // • = dot product
-//===----------------------------------------------------------------------===//
-def SMT_VDot_Slide1 : SMTVEncoding2<0b00>;
-def SMT_VDot_Slide2 : SMTVEncoding2<0b01>;
-def SMT_VDot_Slide3 : SMTVEncoding2<0b10>;
-
-//===----------------------------------------------------------------------===//
-// Instruction formats
-//===----------------------------------------------------------------------===//
-
-let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
-// Base vector dot product (no slide) format.
-class RVInstSMTVDot<SMTVEncoding2 sign, string opcodestr>
-    : RVInst<(outs VRM2:$vd), (ins VR:$vs1, VR:$vs2), opcodestr,
-             "$vd, $vs1, $vs2", [], InstFormatR> {
-  bits<5> vd;
-  bits<5> vs1;
-  bits<5> vs2;
-
-  let Inst{31-25} = OPMMA.Value;
-  let Inst{24-20} = vs2;
-  let Inst{19-15} = vs1;
-  let Inst{14} = 0b0;
-  let Inst{13-12} = sign.Value;
-  let Inst{11-8} = vd{4-1};
-  let Inst{7} = 0b0;
-  let Inst{6-0} = OPC_CUSTOM_1.Value;
-}
-
-// Sliding-window vector dot product format.
-class RVInstSMTVDotSlide<SMTVEncoding2 funct2, SMTVEncoding2 sign, string opcodestr>
-    : RVInst<(outs VRM2:$vd), (ins VRM2:$vs1, VR:$vs2), opcodestr,
-             "$vd, $vs1, $vs2", [], InstFormatR> {
-  bits<5> vd;
-  bits<5> vs1;
-  bits<5> vs2;
-
-  let Inst{31-25} = OPMMA_SLIDE.Value;
-  let Inst{24-20} = vs2;
-  let Inst{19-16} = vs1{4-1};
-  let Inst{15-14} = funct2.Value;
-  let Inst{13-12} = sign.Value;
-  let Inst{11-8} = vd{4-1};
-  let Inst{7} = 0b0;
-  let Inst{6-0} = OPC_CUSTOM_1.Value;
-}
-}
-
-//===----------------------------------------------------------------------===//
-// Instructions
-//===----------------------------------------------------------------------===//
+include "RISCVInstrFormatsSpacemitV.td"
 
 let DecoderNamespace = "XSMT" in {
-
-let Predicates = [HasVendorXSMTVDot], ElementsDependOn = EltDepsVL in {
-// Base vector dot product (no slide) instructions
-// NOTE: Destination registers (vd) MUST be even-numbered (v0, v2, ..., v30)
-//       due to hardware alignment constraints. Using odd registers may cause undefined behavior.
-def SMT_VMADOT   : RVInstSMTVDot<SMT_VDot_SS, "smt.vmadot">;
-def SMT_VMADOTU  : RVInstSMTVDot<SMT_VDot_UU, "smt.vmadotu">;
-def SMT_VMADOTSU : RVInstSMTVDot<SMT_VDot_SU, "smt.vmadotsu">;
-def SMT_VMADOTUS : RVInstSMTVDot<SMT_VDot_US, "smt.vmadotus">;
-
-//===----------------------------------------------------------------------===//
-// Sliding-window Vector Dot Product Instructions
-//
-// The numeric suffix (1, 2, 3) specifies the stride of the sliding window:
-//   1: Window slides by 1 element per operation
-//   2: Window slides by 2 elements per operation
-//   3: Window slides by 3 elements per operation
-//
-// These instructions compute dot products with overlapping operand windows
-// where the window position increments by <N> elements between computations.
-//===----------------------------------------------------------------------===//
-// NOTE: Destination registers (vd) and first source register (vs1) MUST be
-//       even-numbered (v0, v2, ..., v30) due to hardware alignment constraints.
-//       Using odd registers may cause undefined behavior.
-def SMT_VMADOT1   : RVInstSMTVDotSlide<SMT_VDot_Slide1, SMT_VDot_SS, "smt.vmadot1">;
-def SMT_VMADOT1U  : RVInstSMTVDotSlide<SMT_VDot_Slide1, SMT_VDot_UU, "smt.vmadot1u">;
-def SMT_VMADOT1SU : RVInstSMTVDotSlide<SMT_VDot_Slide1, SMT_VDot_SU, "smt.vmadot1su">;
-def SMT_VMADOT1US : RVInstSMTVDotSlide<SMT_VDot_Slide1, SMT_VDot_US, "smt.vmadot1us">;
-def SMT_VMADOT2   : RVInstSMTVDotSlide<SMT_VDot_Slide2, SMT_VDot_SS, "smt.vmadot2">;
-def SMT_VMADOT2U  : RVInstSMTVDotSlide<SMT_VDot_Slide2, SMT_VDot_UU, "smt.vmadot2u">;
-def SMT_VMADOT2SU : RVInstSMTVDotSlide<SMT_VDot_Slide2, SMT_VDot_SU, "smt.vmadot2su">;
-def SMT_VMADOT2US : RVInstSMTVDotSlide<SMT_VDot_Slide2, SMT_VDot_US, "smt.vmadot2us">;
-def SMT_VMADOT3   : RVInstSMTVDotSlide<SMT_VDot_Slide3, SMT_VDot_SS, "smt.vmadot3">;
-def SMT_VMADOT3U  : RVInstSMTVDotSlide<SMT_VDot_Slide3, SMT_VDot_UU, "smt.vmadot3u">;
-def SMT_VMADOT3SU : RVInstSMTVDotSlide<SMT_VDot_Slide3, SMT_VDot_SU, "smt.vmadot3su">;
-def SMT_VMADOT3US : RVInstSMTVDotSlide<SMT_VDot_Slide3, SMT_VDot_US, "smt.vmadot3us">;
+  let Predicates = [HasVendorXSMTVDot, IsRV64], ElementsDependOn = EltDepsNone,
+      RVVConstraint = WidenVNoMask, DestEEW = EEWSEWx4 in {
+    // Base vector dot product (no slide) instructions
+    // NOTE: Destination registers (vd) MUST be even-numbered (v0, v2, ..., v30)
+    //       due to the number of elements processed requires a pair of register operations.
+    // Using odd registers may cause undefined behavior.
+
+    foreach a = VTypeEncodes in
+      def SMT_VMADOT#!toupper(a.Name) :
+            SMTVMADot<a.Encoding, "smt.vmadot"#a.Name>, Sched<[]>;
+
+    //===----------------------------------------------------------------------===//
+    // Sliding-window Vector Dot Product Instructions
+    //
+    // The numeric suffix (1, 2, 3) specifies the stride of the sliding window:
+    //   1: Window slides by 1 element per operation
+    //   2: Window slides by 2 elements per operation
+    //   3: Window slides by 3 elements per operation
+    //
+    // These instructions compute dot products with overlapping operand windows
+    // where the window position increments by <N> elements between
+    // computations.
+    //===----------------------------------------------------------------------===//
+    // NOTE: Destination registers (vd) and first source register (vs1) MUST be
+    //       even-numbered (v0, v2, ..., v30) due to the number of elements processed
+    //       requires a pair of register operations.
+    //       Using odd registers may cause undefined behavior.
+
+    foreach a = SlideEncodes in
+      foreach b = VTypeEncodes in
+        def SMT_VMADOT#!toupper(a.Name)#!toupper(b.Name) :
+            SMTVMADotSlide<a.Encoding, b.Encoding, "smt.vmadot"#a.Name#b.Name>, Sched<[]>;
+  }
 }
-} // DecoderNamespace = "XSMT"
diff --git a/llvm/test/MC/RISCV/xsmtvdot-invalid.s b/llvm/test/MC/RISCV/xsmtvdot-invalid.s
index e4c48c5702888..5b778f3c655d7 100644
--- a/llvm/test/MC/RISCV/xsmtvdot-invalid.s
+++ b/llvm/test/MC/RISCV/xsmtvdot-invalid.s
@@ -1,52 +1,37 @@
-# RUN: not llvm-mc -triple riscv32 -mattr=+xsmtvdot < %s 2>&1 \
-# RUN:     | FileCheck %s
 # RUN: not llvm-mc -triple riscv64 -mattr=+xsmtvdot < %s 2>&1 \
 # RUN:     | FileCheck %s
 
 # NoSlide
-smt.vmadot   v1, v2, v2 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
-smt.vmadotu  v1, v2, v2 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
-smt.vmadotsu v1, v2, v2 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
-smt.vmadotus v1, v2, v2 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
-
-# Slide = 1
-smt.vmadot1   v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot1u  v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot1su v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot1us v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot1   v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot1u  v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot1su v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot1us v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot1   v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot1u  v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot1su v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot1us v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-
-# Slide = 2
-smt.vmadot2   v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot2u  v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot2su v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot2us v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot2   v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot2u  v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot2su v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot2us v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot2   v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot2u  v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot2su v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot2us v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-
-# Slide = 3
-smt.vmadot3   v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot3u  v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot3su v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot3us v1, v2, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot3   v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot3u  v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot3su v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot3us v2, v1, v2 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
-smt.vmadot3   v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot3u  v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot3su v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
-smt.vmadot3us v1, v3, v2 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
+smt.vmadot   v1, v2, v4
+// CHECK: :[[@LINE-1]]:14: error: invalid operand for instruction
+
+smt.vmadot   v2, v2, v4
+// CHECK: :[[@LINE-1]]:14: error: the destination vector register group cannot overlap the source vector register group
+
+smt.vmadot   v4, v2, v4
+// CHECK: :[[@LINE-1]]:14: error: the destination vector register group cannot overlap the source vector register group
+
+smt.vmadot   v2, v3, v4
+// CHECK: :[[@LINE-1]]:14: error: the destination vector register group cannot overlap the source vector register group
+
+smt.vmadot   v2, v4, v3
+// CHECK: :[[@LINE-1]]:14: error: the destination vector register group cannot overlap the source vector register group
+
+# slide
+smt.vmadot1   v1, v2, v2
+// CHECK: :[[@LINE-1]]:15: error: invalid operand for instruction
+
+smt.vmadot1   v2, v5, v4
+// CHECK: :[[@LINE-1]]:19: error: invalid operand for instruction
+
+smt.vmadot1   v2, v2, v4
+// CHECK: :[[@LINE-1]]:15: error: the destination vector register group cannot overlap the source vector register group
+
+smt.vmadot1   v2, v4, v2
+// CHECK: :[[@LINE-1]]:15: error: the destination vector register group cannot overlap the source vector register group
+
+smt.vmadot1   v0, v1, v2
+// CHECK: :[[@LINE-1]]:19: error: invalid operand for instruction
+
+smt.vmadot1   v0, v2, v1
+// CHECK: :[[@LINE-1]]:15: error: the destination vector register group cannot overlap the source vector register group
diff --git a/llvm/test/MC/RISCV/xsmtvdot-valid.s b/llvm/test/MC/RISCV/xsmtvdot-valid.s
index 18df55d21d93a..92a9fbd2f1623 100644
--- a/llvm/test/MC/RISCV/xsmtvdot-valid.s
+++ b/llvm/test/MC/RISCV/xsmtvdot-valid.s
@@ -1,114 +1,112 @@
-# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+xsmtvdot %s \
-# RUN:        | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
-# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+xsmtvdot %s \
-# RUN:        | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
-# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
-# RUN:        | FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -show-encoding -mcpu=spacemit-x60 %s \
+# RUN:        | FileCheck %s --check-prefixes=CHECK-ENC
+
 # RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
 # RUN:        | FileCheck %s --check-prefix=CHECK-ERROR
-# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+xsmtvdot %s \
-# RUN:        | llvm-objdump -d  --mattr=+xsmtvdot - \
-# RUN:        | FileCheck %s --check-prefix=CHECK-INST
-# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+xsmtvdot %s \
-# RUN:        | llvm-objdump -d  --mattr=+xsmtvdot - \
+
+# RUN: llvm-mc -triple=riscv64 -filetype=obj -mcpu=spacemit-x60 %s \
+# RUN:        | llvm-objdump -d  --mcpu=spacemit-x60 - \
 # RUN:        | FileCheck %s --check-prefix=CHECK-INST
-# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+xsmtvdot %s \
-# RUN:        | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
 # RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+xsmtvdot %s \
 # RUN:        | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
 
-# CHECK-INST: smt.vmadot  v16, v0, v8
-# CHECK-ENCODING: [0x2b,0x38,0x80,0xe2]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e280382b <unknown>
+
+// CHECK-ENC:   encoding: [0x2b,0x38,0x80,0xe2]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot  v16, v0, v8
+// CHECK-UNKNOWN: e280382b     	<unknown>
 smt.vmadot   v16, v0, v8
 
-# CHECK-INST: smt.vmadotu v18, v1, v9
-# CHECK-ENCODING: [0x2b,0x89,0x90,0xe2]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e290892b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x89,0x90,0xe2]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadotu	v18, v1, v9 
+// CHECK-UNKNOWN: e290892b     	<unknown>
 smt.vmadotu  v18, v1, v9
 
-# CHECK-INST: smt.vmadotsu        v20, v2, v10
-# CHECK-ENCODING: [0x2b,0x2a,0xa1,0xe2]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e2a12a2b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x2a,0xa1,0xe2]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadotsu	v20, v2, v10
+// CHECK-UNKNOWN: e2a12a2b     	<unknown>
 smt.vmadotsu v20, v2, v10
 
-# CHECK-INST: smt.vmadotus        v22, v3, v11
-# CHECK-ENCODING: [0x2b,0x9b,0xb1,0xe2]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e2b19b2b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x9b,0xb1,0xe2]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadotus	v22, v3, v11
+// CHECK-UNKNOWN: e2b19b2b     	<unknown>
 smt.vmadotus v22, v3, v11
 
-# CHECK-INST: smt.vmadot1 v24, v16, v12
-# CHECK-ENCODING: [0x2b,0x3c,0xc8,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e6c83c2b <unknown>
+
+// CHECK-ENC:   encoding: [0x2b,0x3c,0xc8,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot1	v24, v16, v12
+// CHECK-UNKNOWN: e6c83c2b     	<unknown>
 smt.vmadot1   v24, v16, v12
 
-# CHECK-INST: smt.vmadot1u        v26, v18, v13
-# CHECK-ENCODING: [0x2b,0x0d,0xd9,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e6d90d2b <unknown>
+
+// CHECK-ENC:   encoding: [0x2b,0x0d,0xd9,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot1u	v26, v18, v13
+// CHECK-UNKNOWN: e6d90d2b     	<unknown>
 smt.vmadot1u  v26, v18, v13
 
-# CHECK-INST: smt.vmadot1su       v28, v20, v14
-# CHECK-ENCODING: [0x2b,0x2e,0xea,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e6ea2e2b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x2e,0xea,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot1su	v28, v20, v14
+// CHECK-UNKNOWN: e6ea2e2b     	<unknown>
 smt.vmadot1su v28, v20, v14
 
-# CHECK-INST: smt.vmadot1us       v30, v22, v15
-# CHECK-ENCODING: [0x2b,0x1f,0xfb,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e6fb1f2b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x1f,0xfb,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot1us	v30, v22, v15
+// CHECK-UNKNOWN: e6fb1f2b     	<unknown>
 smt.vmadot1us v30, v22, v15
 
-# CHECK-INST: smt.vmadot2 v0, v24, v4
-# CHECK-ENCODING: [0x2b,0x70,0x4c,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e64c702b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x70,0x4c,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot2	v0, v24, v4
+// CHECK-UNKNOWN: e64c702b     	<unknown>
 smt.vmadot2   v0, v24, v4
 
-# CHECK-INST: smt.vmadot2u        v2, v26, v5
-# CHECK-ENCODING: [0x2b,0x41,0x5d,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e65d412b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x41,0x5d,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot2u	v2, v26, v5
+// CHECK-UNKNOWN: e65d412b     	<unknown>
 smt.vmadot2u  v2, v26, v5
 
-# CHECK-INST: smt.vmadot2su       v4, v28, v6
-# CHECK-ENCODING: [0x2b,0x62,0x6e,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e66e622b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x62,0x6e,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot2su	v4, v28, v6
+// CHECK-UNKNOWN: e66e622b     	<unknown>
 smt.vmadot2su v4, v28, v6
 
-# CHECK-INST: smt.vmadot2us       v6, v30, v7
-# CHECK-ENCODING: [0x2b,0x53,0x7f,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e67f532b <unknown>
-smt.vmadot2us v6, v30, v7
-
-# CHECK-INST: smt.vmadot3 v8, v0, v8
-# CHECK-ENCODING: [0x2b,0xb4,0x80,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e680b42b <unknown>
-smt.vmadot3   v8, v0, v8
-
-# CHECK-INST: smt.vmadot3u        v10, v2, v9
-# CHECK-ENCODING: [0x2b,0x85,0x91,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e691852b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x53,0x8f,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot2us	v6, v30, v8
+// CHECK-UNKNOWN: e68f532b     	<unknown>
+smt.vmadot2us v6, v30, v8
+
+// CHECK-ENC:   encoding: [0x2b,0xb1,0x80,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot3	v2, v0, v8 
+// CHECK-UNKNOWN: e680b12b     	<unknown>
+smt.vmadot3   v2, v0, v8
+
+// CHECK-ENC:   encoding: [0x2b,0x85,0x91,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot3u	v10, v2, v9
+// CHECK-UNKNOWN: e691852b     	<unknown>
 smt.vmadot3u  v10, v2, v9
 
-# CHECK-INST: smt.vmadot3su       v12, v4, v10
-# CHECK-ENCODING: [0x2b,0xa6,0xa2,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e6a2a62b <unknown>
+
+// CHECK-ENC:   encoding: [0x2b,0xa6,0xa2,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST:  smt.vmadot3su	v12, v4, v10
+// CHECK-UNKNOWN: e6a2a62b     	<unknown>
 smt.vmadot3su v12, v4, v10
 
-# CHECK-INST: smt.vmadot3us       v14, v6, v11
-# CHECK-ENCODING: [0x2b,0x97,0xb3,0xe6]
-# CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension){{$}}
-# CHECK-UNKNOWN: e6b3972b <unknown>
+// CHECK-ENC:   encoding: [0x2b,0x97,0xb3,0xe6]
+// CHECK-ERROR: instruction requires the following: 'XSMTVDot' (SpacemiT Vector Dot Product Extension)
+// CHECK-INST: smt.vmadot3us	v14, v6, v11
+// CHECK-UNKNOWN: e6b3972b     	<unknown>
 smt.vmadot3us v14, v6, v11



More information about the llvm-commits mailing list