Skip to content

[RISCV] Move checking for constant 3/4 for XTHeadMemPair to the instruction matching stage. #136165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Apr 17, 2025

This removes a special case from processInstruction and removes an untested range diagnostic we would print if the constant didn't fit in 3 bits.

…ching stage.

This removes a special case from processInstruction and removes an
untested range diagnostic we would print if the constant didn't
fit in 3 bits.
@topperc topperc changed the title [RISCV] Move checking for [Cconstant 3/4 for XTHeadMemPair to the instruction matching stage. [RISCV] Move checking for constant 3/4 for XTHeadMemPair to the instruction matching stage. Apr 17, 2025
@llvmbot llvmbot added backend:RISC-V mc Machine (object) code labels Apr 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 17, 2025

@llvm/pr-subscribers-backend-risc-v

@llvm/pr-subscribers-mc

Author: Craig Topper (topperc)

Changes

This removes a special case from processInstruction and removes an untested range diagnostic we would print if the constant didn't fit in 3 bits.


Full diff: https://github.com/llvm/llvm-project/pull/136165.diff

5 Files Affected:

  • (modified) llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp (+8-13)
  • (modified) llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h (+2)
  • (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.cpp (+6)
  • (modified) llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td (+33-9)
  • (modified) llvm/test/MC/RISCV/rv32xtheadmempair-invalid.s (+2-2)
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index f8df7ee4c5019..d0a561656fa56 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -932,6 +932,14 @@ struct RISCVOperand final : public MCParsedAsmOperand {
     return isUImmPred([](int64_t Imm) { return 0 == Imm; });
   }
 
+  bool isImmThree() const {
+    return isUImmPred([](int64_t Imm) { return 3 == Imm; });
+  }
+
+  bool isImmFour() const {
+    return isUImmPred([](int64_t Imm) { return 4 == Imm; });
+  }
+
   bool isSImm5Plus1() const {
     return isSImmPred(
         [](int64_t Imm) { return Imm != INT64_MIN && isInt<5>(Imm - 1); });
@@ -3660,19 +3668,6 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
     }
   }
 
-  bool IsTHeadMemPair32 = (Opcode == RISCV::TH_LWD ||
-                           Opcode == RISCV::TH_LWUD || Opcode == RISCV::TH_SWD);
-  bool IsTHeadMemPair64 = (Opcode == RISCV::TH_LDD || Opcode == RISCV::TH_SDD);
-  // The last operand of XTHeadMemPair instructions must be constant 3 or 4
-  // depending on the data width.
-  if (IsTHeadMemPair32 && Inst.getOperand(4).getImm() != 3) {
-    SMLoc Loc = Operands.back()->getStartLoc();
-    return Error(Loc, "operand must be constant 3");
-  } else if (IsTHeadMemPair64 && Inst.getOperand(4).getImm() != 4) {
-    SMLoc Loc = Operands.back()->getStartLoc();
-    return Error(Loc, "operand must be constant 4");
-  }
-
   const MCInstrDesc &MCID = MII.get(Opcode);
   if (!(MCID.TSFlags & RISCVII::ConstraintMask))
     return false;
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
index 84a23de6b1995..6ef94fb5e93da 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
@@ -329,6 +329,8 @@ enum OperandType : unsigned {
   OPERAND_UIMM48,
   OPERAND_UIMM64,
   OPERAND_ZERO,
+  OPERAND_THREE,
+  OPERAND_FOUR,
   OPERAND_SIMM5,
   OPERAND_SIMM5_NONZERO,
   OPERAND_SIMM5_PLUS1,
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 5d661a3438b1c..04ad56ea83230 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -2645,6 +2645,12 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
         case RISCVOp::OPERAND_ZERO:
           Ok = Imm == 0;
           break;
+        case RISCVOp::OPERAND_THREE:
+          Ok = Imm == 3;
+          break;
+        case RISCVOp::OPERAND_FOUR:
+          Ok = Imm == 4;
+          break;
           // clang-format off
         CASE_OPERAND_SIMM(5)
         CASE_OPERAND_SIMM(6)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td
index f69b24ae7d9c5..b1cd2202b9be8 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td
@@ -34,6 +34,30 @@ def th_swd : SDNode<"RISCVISD::TH_SWD", SDT_StorePair,
 def th_sdd : SDNode<"RISCVISD::TH_SDD", SDT_StorePair,
                     [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
 
+def ImmThreeAsmOperand : AsmOperandClass {
+  let Name = "ImmThree";
+  let RenderMethod = "addImmOperands";
+  let DiagnosticType = !strconcat("Invalid", Name);
+  let DiagnosticString = "operand must be constant 3";
+}
+
+def immthree : RISCVOp {
+  let ParserMatchClass = ImmThreeAsmOperand;
+  let OperandType = "OPERAND_THREE";
+}
+
+def ImmFourAsmOperand : AsmOperandClass {
+  let Name = "ImmFour";
+  let RenderMethod = "addImmOperands";
+  let DiagnosticType = !strconcat("Invalid", Name);
+  let DiagnosticString = "operand must be constant 4";
+}
+
+def immfour : RISCVOp {
+  let ParserMatchClass = ImmFourAsmOperand;
+  let OperandType = "OPERAND_FOUR";
+}
+
 //===----------------------------------------------------------------------===//
 // Instruction class templates
 //===----------------------------------------------------------------------===//
@@ -131,10 +155,10 @@ class THMulAccumulate_rr<bits<7> funct7, string opcodestr>
 }
 
 let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
-class THLoadPair<bits<5> funct5, string opcodestr>
+class THLoadPair<bits<5> funct5, string opcodestr, Operand consttype>
   : RVInstRBase<0b100, OPC_CUSTOM_0,
                 (outs GPR:$rd, GPR:$rs2),
-                (ins GPR:$rs1, uimm2:$uimm2, uimm7:$const3or4),
+                (ins GPR:$rs1, uimm2:$uimm2, consttype:$const3or4),
                  opcodestr, "$rd, $rs2, (${rs1}), $uimm2, $const3or4"> {
   bits<2> uimm2;
   let Inst{31-27} = funct5;
@@ -144,9 +168,9 @@ class THLoadPair<bits<5> funct5, string opcodestr>
 }
 
 let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
-class THStorePair<bits<5> funct5, string opcodestr>
+class THStorePair<bits<5> funct5, string opcodestr, Operand consttype>
   : RVInstRBase<0b101, OPC_CUSTOM_0, (outs),
-              (ins GPR:$rd, GPR:$rs2, GPR:$rs1, uimm2:$uimm2, uimm7:$const3or4),
+              (ins GPR:$rd, GPR:$rs2, GPR:$rs1, uimm2:$uimm2, consttype:$const3or4),
               opcodestr, "$rd, $rs2, (${rs1}), $uimm2, $const3or4"> {
   bits<2> uimm2;
   let Inst{31-27} = funct5;
@@ -290,19 +314,19 @@ def TH_MULSW : THMulAccumulate_rr<0b0010011, "th.mulsw">;
 } // Predicates = [HasVendorXTHeadMac, IsRV64]
 
 let Predicates = [HasVendorXTHeadMemPair] in {
-def TH_LWUD : THLoadPair<0b11110, "th.lwud">,
+def TH_LWUD : THLoadPair<0b11110, "th.lwud", immthree>,
               Sched<[WriteLDW, WriteLDW, ReadMemBase]>;
-def TH_SWD  : THStorePair<0b11100, "th.swd">,
+def TH_SWD  : THStorePair<0b11100, "th.swd", immthree>,
               Sched<[WriteSTW, WriteSTW, ReadStoreData, ReadMemBase]>;
 let IsSignExtendingOpW = 1 in
-def TH_LWD  : THLoadPair<0b11100, "th.lwd">,
+def TH_LWD  : THLoadPair<0b11100, "th.lwd", immthree>,
               Sched<[WriteLDW, WriteLDW, ReadMemBase]>;
 }
 
 let Predicates = [HasVendorXTHeadMemPair, IsRV64] in {
-def TH_LDD : THLoadPair<0b11111, "th.ldd">,
+def TH_LDD : THLoadPair<0b11111, "th.ldd", immfour>,
              Sched<[WriteLDD, WriteLDD, ReadMemBase]>;
-def TH_SDD : THStorePair<0b11111, "th.sdd">,
+def TH_SDD : THStorePair<0b11111, "th.sdd", immfour>,
              Sched<[WriteSTD, WriteSTD, ReadStoreData, ReadMemBase]>;
 }
 
diff --git a/llvm/test/MC/RISCV/rv32xtheadmempair-invalid.s b/llvm/test/MC/RISCV/rv32xtheadmempair-invalid.s
index 9124218c1f8f5..a9223ae128a40 100644
--- a/llvm/test/MC/RISCV/rv32xtheadmempair-invalid.s
+++ b/llvm/test/MC/RISCV/rv32xtheadmempair-invalid.s
@@ -2,10 +2,10 @@
 
 th.ldd t0, t1, (t2), 5, 4   # CHECK: [[@LINE]]:22: error: invalid operand for instruction
 th.ldd t0, t1, (t2)         # CHECK: [[@LINE]]:1: error: too few operands for instruction
-th.ldd t0, t1, (t2), 3, 5   # CHECK: [[@LINE]]:1: error: instruction requires the following: RV64I Base Instruction Set{{$}}
+th.ldd t0, t1, (t2), 3, 5   # CHECK: [[@LINE]]:25: error: invalid operand for instruction
 th.sdd a0, a1, (a2), 5, 4   # CHECK: [[@LINE]]:22: error: invalid operand for instruction
 th.sdd a0, a1, (a2)         # CHECK: [[@LINE]]:1: error: too few operands for instruction
-th.sdd a0, a1, (a2), 3, 5   # CHECK: [[@LINE]]:1: error: instruction requires the following: RV64I Base Instruction Set{{$}}
+th.sdd a0, a1, (a2), 3, 5   # CHECK: [[@LINE]]:25: error: invalid operand for instruction
 th.lwud t0, t1, (t2), 5, 4  # CHECK: [[@LINE]]:23: error: immediate must be an integer in the range [0, 3]
 th.lwud t0, t1, (t2)        # CHECK: [[@LINE]]:1: error: too few operands for instruction
 th.lwud t0, t1, (t2), 3, 5  # CHECK: [[@LINE]]:26: error: operand must be constant 3

Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@topperc topperc merged commit 23324b8 into llvm:main Apr 18, 2025
14 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 18, 2025

LLVM Buildbot has detected a new failure on builder ml-opt-devrel-x86-64 running on ml-opt-devrel-x86-64-b2 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/175/builds/17108

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: MC/RISCV/rv64xtheadmempair-invalid.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
not /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair < /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s 2>&1 | /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s # RUN: at line 1
+ not /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair
+ /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s
/b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s:18:36: error: CHECK: expected string not found in input
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                   ^
<stdin>:43:49: note: scanning from here
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:43:49: note: with "@LINE" equal to "18"
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:47:45: note: possible intended match here
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                            ^

Input file: <stdin>
Check file: /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           38: th.swd t3, t4, (t5), 5, 4 # CHECK: [[@LINE]]:22: error: immediate must be an integer in the range [0, 3] 
           39:  ^ 
           40: <stdin>:16:1: error: too few operands for instruction 
           41: th.swd t3, t4, (t5) # CHECK: [[@LINE]]:1: error: too few operands for instruction 
           42: ^ 
           43: <stdin>:17:25: error: operand must be constant 3 
check:18'0                                                     X error: no match found
check:18'1                                                       with "@LINE" equal to "18"
           44: th.swd t3, t4, (t5), 3, 5 # CHECK: [[@LINE]]:25: error: operand must be constant 3 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           45:  ^ 
check:18'0     ~~~
           46: <stdin>:18:25: error: operand must be constant 4 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           47: th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:18'2                                                 ?                                            possible intended match
           48:  ^ 
check:18'0     ~~~
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 18, 2025

LLVM Buildbot has detected a new failure on builder ml-opt-rel-x86-64 running on ml-opt-rel-x86-64-b1 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/185/builds/16901

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: MC/RISCV/rv64xtheadmempair-invalid.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
not /b/ml-opt-rel-x86-64-b1/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair < /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s 2>&1 | /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s # RUN: at line 1
+ not /b/ml-opt-rel-x86-64-b1/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair
+ /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s
/b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s:18:36: error: CHECK: expected string not found in input
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                   ^
<stdin>:43:49: note: scanning from here
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:43:49: note: with "@LINE" equal to "18"
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:47:45: note: possible intended match here
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                            ^

Input file: <stdin>
Check file: /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           38: th.swd t3, t4, (t5), 5, 4 # CHECK: [[@LINE]]:22: error: immediate must be an integer in the range [0, 3] 
           39:  ^ 
           40: <stdin>:16:1: error: too few operands for instruction 
           41: th.swd t3, t4, (t5) # CHECK: [[@LINE]]:1: error: too few operands for instruction 
           42: ^ 
           43: <stdin>:17:25: error: operand must be constant 3 
check:18'0                                                     X error: no match found
check:18'1                                                       with "@LINE" equal to "18"
           44: th.swd t3, t4, (t5), 3, 5 # CHECK: [[@LINE]]:25: error: operand must be constant 3 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           45:  ^ 
check:18'0     ~~~
           46: <stdin>:18:25: error: operand must be constant 4 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           47: th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:18'2                                                 ?                                            possible intended match
           48:  ^ 
check:18'0     ~~~
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 18, 2025

LLVM Buildbot has detected a new failure on builder ml-opt-dev-x86-64 running on ml-opt-dev-x86-64-b2 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/137/builds/17144

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: MC/RISCV/rv64xtheadmempair-invalid.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
not /b/ml-opt-dev-x86-64-b1/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair < /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s 2>&1 | /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s # RUN: at line 1
+ not /b/ml-opt-dev-x86-64-b1/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair
+ /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s:18:36: error: CHECK: expected string not found in input
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                   ^
<stdin>:43:49: note: scanning from here
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:43:49: note: with "@LINE" equal to "18"
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:47:45: note: possible intended match here
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                            ^

Input file: <stdin>
Check file: /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           38: th.swd t3, t4, (t5), 5, 4 # CHECK: [[@LINE]]:22: error: immediate must be an integer in the range [0, 3] 
           39:  ^ 
           40: <stdin>:16:1: error: too few operands for instruction 
           41: th.swd t3, t4, (t5) # CHECK: [[@LINE]]:1: error: too few operands for instruction 
           42: ^ 
           43: <stdin>:17:25: error: operand must be constant 3 
check:18'0                                                     X error: no match found
check:18'1                                                       with "@LINE" equal to "18"
           44: th.swd t3, t4, (t5), 3, 5 # CHECK: [[@LINE]]:25: error: operand must be constant 3 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           45:  ^ 
check:18'0     ~~~
           46: <stdin>:18:25: error: operand must be constant 4 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           47: th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:18'2                                                 ?                                            possible intended match
           48:  ^ 
check:18'0     ~~~
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 18, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/29213

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: MC/RISCV/rv64xtheadmempair-invalid.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
not /build/buildbot/premerge-monolithic-linux/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair < /build/buildbot/premerge-monolithic-linux/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s 2>&1 | /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s # RUN: at line 1
+ not /build/buildbot/premerge-monolithic-linux/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s:18:36: error: CHECK: expected string not found in input
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                   ^
<stdin>:43:49: note: scanning from here
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:43:49: note: with "@LINE" equal to "18"
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:47:45: note: possible intended match here
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                            ^

Input file: <stdin>
Check file: /build/buildbot/premerge-monolithic-linux/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           38: th.swd t3, t4, (t5), 5, 4 # CHECK: [[@LINE]]:22: error: immediate must be an integer in the range [0, 3] 
           39:  ^ 
           40: <stdin>:16:1: error: too few operands for instruction 
           41: th.swd t3, t4, (t5) # CHECK: [[@LINE]]:1: error: too few operands for instruction 
           42: ^ 
           43: <stdin>:17:25: error: operand must be constant 3 
check:18'0                                                     X error: no match found
check:18'1                                                       with "@LINE" equal to "18"
           44: th.swd t3, t4, (t5), 3, 5 # CHECK: [[@LINE]]:25: error: operand must be constant 3 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           45:  ^ 
check:18'0     ~~~
           46: <stdin>:18:25: error: operand must be constant 4 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           47: th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:18'2                                                 ?                                            possible intended match
           48:  ^ 
check:18'0     ~~~
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 18, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-ubuntu-fast running on as-builder-4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/33/builds/15085

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: MC/RISCV/rv64xtheadmempair-invalid.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
not /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair < /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s 2>&1 | /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s # RUN: at line 1
+ not /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair
+ /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s
/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s:18:36: error: CHECK: expected string not found in input
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                   ^
<stdin>:43:49: note: scanning from here
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:43:49: note: with "@LINE" equal to "18"
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:47:45: note: possible intended match here
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                            ^

Input file: <stdin>
Check file: /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           38: th.swd t3, t4, (t5), 5, 4 # CHECK: [[@LINE]]:22: error: immediate must be an integer in the range [0, 3] 
           39:  ^ 
           40: <stdin>:16:1: error: too few operands for instruction 
           41: th.swd t3, t4, (t5) # CHECK: [[@LINE]]:1: error: too few operands for instruction 
           42: ^ 
           43: <stdin>:17:25: error: operand must be constant 3 
check:18'0                                                     X error: no match found
check:18'1                                                       with "@LINE" equal to "18"
           44: th.swd t3, t4, (t5), 3, 5 # CHECK: [[@LINE]]:25: error: operand must be constant 3 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           45:  ^ 
check:18'0     ~~~
           46: <stdin>:18:25: error: operand must be constant 4 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           47: th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:18'2                                                 ?                                            possible intended match
           48:  ^ 
check:18'0     ~~~
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 18, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-expensive-checks-debian running on gribozavr4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/17579

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: MC/RISCV/rv64xtheadmempair-invalid.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
not /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair < /b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s 2>&1 | /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bin/FileCheck /b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s # RUN: at line 1
+ not /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair
+ /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bin/FileCheck /b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s
/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s:18:36: error: CHECK: expected string not found in input
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                   ^
<stdin>:43:49: note: scanning from here
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:43:49: note: with "@LINE" equal to "18"
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:47:45: note: possible intended match here
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                            ^

Input file: <stdin>
Check file: /b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           38: th.swd t3, t4, (t5), 5, 4 # CHECK: [[@LINE]]:22: error: immediate must be an integer in the range [0, 3] 
           39:  ^ 
           40: <stdin>:16:1: error: too few operands for instruction 
           41: th.swd t3, t4, (t5) # CHECK: [[@LINE]]:1: error: too few operands for instruction 
           42: ^ 
           43: <stdin>:17:25: error: operand must be constant 3 
check:18'0                                                     X error: no match found
check:18'1                                                       with "@LINE" equal to "18"
           44: th.swd t3, t4, (t5), 3, 5 # CHECK: [[@LINE]]:25: error: operand must be constant 3 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           45:  ^ 
check:18'0     ~~~
           46: <stdin>:18:25: error: operand must be constant 4 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           47: th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:18'2                                                 ?                                            possible intended match
           48:  ^ 
check:18'0     ~~~
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 18, 2025

LLVM Buildbot has detected a new failure on builder clang-x86_64-debian-fast running on gribozavr4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/23766

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: MC/RISCV/rv64xtheadmempair-invalid.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
not /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair < /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s 2>&1 | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s # RUN: at line 1
+ not /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s
/b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s:18:36: error: CHECK: expected string not found in input
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                   ^
<stdin>:43:49: note: scanning from here
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:43:49: note: with "@LINE" equal to "18"
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:47:45: note: possible intended match here
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                            ^

Input file: <stdin>
Check file: /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           38: th.swd t3, t4, (t5), 5, 4 # CHECK: [[@LINE]]:22: error: immediate must be an integer in the range [0, 3] 
           39:  ^ 
           40: <stdin>:16:1: error: too few operands for instruction 
           41: th.swd t3, t4, (t5) # CHECK: [[@LINE]]:1: error: too few operands for instruction 
           42: ^ 
           43: <stdin>:17:25: error: operand must be constant 3 
check:18'0                                                     X error: no match found
check:18'1                                                       with "@LINE" equal to "18"
           44: th.swd t3, t4, (t5), 3, 5 # CHECK: [[@LINE]]:25: error: operand must be constant 3 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           45:  ^ 
check:18'0     ~~~
           46: <stdin>:18:25: error: operand must be constant 4 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           47: th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:18'2                                                 ?                                            possible intended match
           48:  ^ 
check:18'0     ~~~
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 18, 2025

LLVM Buildbot has detected a new failure on builder llvm-x86_64-debian-dylib running on gribozavr4 while building llvm at step 7 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/25073

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM :: MC/RISCV/rv64xtheadmempair-invalid.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
not /b/1/llvm-x86_64-debian-dylib/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair < /b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s 2>&1 | /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck /b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s # RUN: at line 1
+ not /b/1/llvm-x86_64-debian-dylib/build/bin/llvm-mc -triple riscv64 -mattr=+xtheadmempair
+ /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck /b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s
/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s:18:36: error: CHECK: expected string not found in input
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                   ^
<stdin>:43:49: note: scanning from here
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:43:49: note: with "@LINE" equal to "18"
<stdin>:17:25: error: operand must be constant 3
                                                ^
<stdin>:47:45: note: possible intended match here
th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap
                                            ^

Input file: <stdin>
Check file: /b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/test/MC/RISCV/rv64xtheadmempair-invalid.s

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
           38: th.swd t3, t4, (t5), 5, 4 # CHECK: [[@LINE]]:22: error: immediate must be an integer in the range [0, 3] 
           39:  ^ 
           40: <stdin>:16:1: error: too few operands for instruction 
           41: th.swd t3, t4, (t5) # CHECK: [[@LINE]]:1: error: too few operands for instruction 
           42: ^ 
           43: <stdin>:17:25: error: operand must be constant 3 
check:18'0                                                     X error: no match found
check:18'1                                                       with "@LINE" equal to "18"
           44: th.swd t3, t4, (t5), 3, 5 # CHECK: [[@LINE]]:25: error: operand must be constant 3 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           45:  ^ 
check:18'0     ~~~
           46: <stdin>:18:25: error: operand must be constant 4 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           47: th.ldd x6, x6, (x7), 2, 3 # CHECK: [[@LINE]]:8: error: rs1, rd1, and rd2 cannot overlap 
check:18'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:18'2                                                 ?                                            possible intended match
           48:  ^ 
check:18'0     ~~~
...

@topperc topperc deleted the pr/xthead-const branch April 21, 2025 19:26
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…uction matching stage. (llvm#136165)

This removes a special case from processInstruction and removes an
untested range diagnostic we would print if the constant didn't fit in 3
bits.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…uction matching stage. (llvm#136165)

This removes a special case from processInstruction and removes an
untested range diagnostic we would print if the constant didn't fit in 3
bits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:RISC-V mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants