[llvm] [RISCV][MC] Allow x0 as the destination of qc.inw (PR #225602)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 23:17:55 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Zeyi Xu (zeyi2)

<details>
<summary>Changes</summary>

According to the Xqciio specification, `qc.inw` does not impose any restriction that excludes `x0` as the destination register. In `qc.inw.yaml`, `rd` is defined as:

```
- name: rd
  location: 11-7
```

This commit removes the incorrect `x0` restriction for `qc.inw`.

Link: https://github.com/qualcomm/riscv-unified-db/blob/main/arch_overlay/qc_iu/inst/Xqci/qc.inw.yaml

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


3 Files Affected:

- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td (+1-1) 
- (modified) llvm/test/MC/RISCV/xqciio-invalid.s (-4) 
- (modified) llvm/test/MC/RISCV/xqciio-valid.s (+4) 


``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td
index 643d04d1da878..3dd4edd0530b1 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td
@@ -1132,7 +1132,7 @@ let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in {
     let imm12 = imm14{13-2};
   }
 
-  def QC_INW : RVInstI<0b101, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
+  def QC_INW : RVInstI<0b101, OPC_CUSTOM_0, (outs GPR:$rd),
                        (ins GPR:$rs1, uimm14lsb00_optional:$imm14),
                        "qc.inw", "$rd, ${imm14}(${rs1})"> {
     bits<14> imm14;
diff --git a/llvm/test/MC/RISCV/xqciio-invalid.s b/llvm/test/MC/RISCV/xqciio-invalid.s
index 3a4c852c50f92..08fa01645fd79 100644
--- a/llvm/test/MC/RISCV/xqciio-invalid.s
+++ b/llvm/test/MC/RISCV/xqciio-invalid.s
@@ -25,10 +25,6 @@ qc.inw x23, 16380(17)
 # CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqciio' (Qualcomm uC External Input Output Extension)
 qc.inw x23, x17
 
-# CHECK-PLUS: :[[@LINE+2]]:8: error: register must be a GPR excluding zero (x0)
-# CHECK-MINUS: :[[@LINE+1]]:1: error: invalid instruction
-qc.inw x0, 16380(x17)
-
 # CHECK-PLUS: :[[@LINE+2]]:13: error: immediate must be a multiple of 4 bytes in the range [0, 16380]
 # CHECK-MINUS: :[[@LINE+1]]:1: error: invalid instruction
 qc.inw x23, 16384(x17)
diff --git a/llvm/test/MC/RISCV/xqciio-valid.s b/llvm/test/MC/RISCV/xqciio-valid.s
index 3d6ecf2560a87..750ad536af9c5 100644
--- a/llvm/test/MC/RISCV/xqciio-valid.s
+++ b/llvm/test/MC/RISCV/xqciio-valid.s
@@ -18,3 +18,7 @@ qc.outw x5, 2048(x10)
 # CHECK-INST: qc.inw    s7, 16380(a7)
 # CHECK-ENC: encoding: [0x8b,0xdb,0xf8,0xff]
 qc.inw x23, 16380(x17)
+
+# CHECK-INST: qc.inw    zero, 16380(a7)
+# CHECK-ENC: encoding: [0x0b,0xd0,0xf8,0xff]
+qc.inw x0, 16380(x17)

``````````

</details>


https://github.com/llvm/llvm-project/pull/225602


More information about the llvm-commits mailing list