Skip to content

Commit 0614c60

Browse files
hchandelHarsh Chandel
andauthored
[RISCV] Add Qualcomm uC Xqcics(Conditional Select) extension (#119504)
The Qualcomm uC Xqcics extension adds 8 conditional select instructions. The current spec can be found at: https://github.com/quic/riscv-unified-db/releases/latest This patch adds assembler only support. --------- Co-authored-by: Harsh Chandel <[email protected]>
1 parent 088db86 commit 0614c60

File tree

11 files changed

+347
-1
lines changed

11 files changed

+347
-1
lines changed

clang/test/Driver/print-supported-extensions-riscv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
// CHECK-NEXT: ssctr 1.0 'Ssctr' (Control Transfer Records Supervisor Level)
190190
// CHECK-NEXT: svukte 0.3 'Svukte' (Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
191191
// CHECK-NEXT: xqcia 0.2 'Xqcia' (Qualcomm uC Arithmetic Extension)
192+
// CHECK-NEXT: xqcics 0.2 'Xqcics' (Qualcomm uC Conditional Select Extension)
192193
// CHECK-NEXT: xqcicsr 0.2 'Xqcicsr' (Qualcomm uC CSR Extension)
193194
// CHECK-NEXT: xqcisls 0.2 'Xqcisls' (Qualcomm uC Scaled Load Store Extension)
194195
// CHECK-EMPTY:

llvm/docs/RISCVUsage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ The current vendor extensions supported are:
429429
``experimental-Xqcia``
430430
LLVM implements `version 0.2 of the Qualcomm uC Arithmetic extension specification <https://github.com/quic/riscv-unified-db/releases/latest>`__ by Qualcomm. All instructions are prefixed with `qc.` as described in the specification. These instructions are only available for riscv32.
431431

432+
``experimental-Xqcics``
433+
LLVM implements `version 0.2 of the Qualcomm uC Conditional Select extension specification <https://github.com/quic/riscv-unified-db/releases/latest>`__ by Qualcomm. All instructions are prefixed with `qc.` as described in the specification. These instructions are only available for riscv32.
434+
432435
``experimental-Xqcicsr``
433436
LLVM implements `version 0.2 of the Qualcomm uC CSR extension specification <https://github.com/quic/riscv-unified-db/releases/latest>`__ by Qualcomm. All instructions are prefixed with `qc.` as described in the specification. These instructions are only available for riscv32.
434437

llvm/docs/ReleaseNotes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ Changes to the RISC-V Backend
221221
extension.
222222
* Adds experimental assembler support for the Qualcomm uC 'Xqcia` (Arithmetic)
223223
extension.
224+
* Adds experimental assembler support for the Qualcomm uC 'Xqcics` (Conditonal Select)
225+
extension.
224226

225227
Changes to the WebAssembly Backend
226228
----------------------------------

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,8 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
688688
"Qualcomm uC Scaled Load Store custom opcode table");
689689
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXqcia, DecoderTableXqcia32,
690690
"Qualcomm uC Arithmetic custom opcode table");
691+
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXqcics, DecoderTableXqcics32,
692+
"Qualcomm uC Conditional Select custom opcode table");
691693
TRY_TO_DECODE(true, DecoderTable32, "RISCV32 table");
692694

693695
return MCDisassembler::Fail;

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,14 @@ def HasVendorXqcia
13671367
AssemblerPredicate<(all_of FeatureVendorXqcia),
13681368
"'Xqcia' (Qualcomm uC Arithmetic Extension)">;
13691369

1370+
def FeatureVendorXqcics
1371+
: RISCVExperimentalExtension<"xqcics", 0, 2,
1372+
"'Xqcics' (Qualcomm uC Conditional Select Extension)">;
1373+
def HasVendorXqcics
1374+
: Predicate<"Subtarget->hasVendorXqcics()">,
1375+
AssemblerPredicate<(all_of FeatureVendorXqcics),
1376+
"'Xqcics' (Qualcomm uC Conditional Select Extension)">;
1377+
13701378
//===----------------------------------------------------------------------===//
13711379
// LLVM specific features and extensions
13721380
//===----------------------------------------------------------------------===//

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,54 @@ class QCIRVInstRR<bits<5> func5, DAGOperand InTyRs1, string opcodestr>
5757
: RVInstR<{0b00, func5}, 0b011, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
5858
(ins InTyRs1:$rs1, GPRNoX0:$rs2), opcodestr, "$rd, $rs1, $rs2">;
5959

60+
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
61+
class QCISELECTIICC<bits<3> funct3, string opcodestr>
62+
: RVInstR4<0b00, funct3, OPC_CUSTOM_2, (outs GPRNoX0:$rd_wb),
63+
(ins GPRNoX0:$rd, GPRNoX0:$rs1, simm5:$simm1, simm5:$simm2),
64+
opcodestr, "$rd, $rs1, $simm1, $simm2"> {
65+
let Constraints = "$rd = $rd_wb";
66+
bits<5> simm1;
67+
bits<5> simm2;
68+
69+
let rs3 = simm2;
70+
let rs2 = simm1;
71+
}
72+
73+
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
74+
class QCISELECTICC<bits<3> funct3, string opcodestr>
75+
: RVInstR4<0b01, funct3, OPC_CUSTOM_2, (outs GPRNoX0:$rd_wb),
76+
(ins GPRNoX0:$rd, GPRNoX0:$rs1, GPRNoX0:$rs2, simm5:$simm2),
77+
opcodestr, "$rd, $rs1, $rs2, $simm2"> {
78+
let Constraints = "$rd = $rd_wb";
79+
bits<5> simm2;
80+
81+
let rs3 = simm2;
82+
}
83+
84+
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
85+
class QCISELECTCCI<bits<3> funct3, string opcodestr>
86+
: RVInstR4<0b10, funct3, OPC_CUSTOM_2, (outs GPRNoX0:$rd_wb),
87+
(ins GPRNoX0:$rd, simm5:$imm, GPRNoX0:$rs2, GPRNoX0:$rs3),
88+
opcodestr, "$rd, $imm, $rs2, $rs3"> {
89+
let Constraints = "$rd = $rd_wb";
90+
bits<5> imm;
91+
92+
let rs1 = imm;
93+
}
94+
95+
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
96+
class QCISELECTICCI<bits<3> funct3, string opcodestr>
97+
: RVInstR4<0b11, funct3, OPC_CUSTOM_2, (outs GPRNoX0:$rd_wb),
98+
(ins GPRNoX0:$rd, simm5:$imm, GPRNoX0:$rs2, simm5:$simm2),
99+
opcodestr, "$rd, $imm, $rs2, $simm2"> {
100+
let Constraints = "$rd = $rd_wb";
101+
bits<5> imm;
102+
bits<5> simm2;
103+
104+
let rs3 = simm2;
105+
let rs1 = imm;
106+
}
107+
60108
//===----------------------------------------------------------------------===//
61109
// Instructions
62110
//===----------------------------------------------------------------------===//
@@ -108,3 +156,14 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
108156
def QC_NORMEU : QCIRVInstR<0b1001, "qc.normeu">;
109157
} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
110158
} // Predicates = [HasVendorXqcia, IsRV32], DecoderNamespace = "Xqcia"
159+
160+
let Predicates = [HasVendorXqcics, IsRV32], DecoderNamespace = "Xqcics" in {
161+
def QC_SELECTIIEQ : QCISELECTIICC <0b010, "qc.selectiieq">;
162+
def QC_SELECTIINE : QCISELECTIICC <0b011, "qc.selectiine">;
163+
def QC_SELECTIEQ : QCISELECTICC <0b010, "qc.selectieq">;
164+
def QC_SELECTINE : QCISELECTICC <0b011, "qc.selectine">;
165+
def QC_SELECTEQI : QCISELECTCCI <0b010, "qc.selecteqi">;
166+
def QC_SELECTNEI : QCISELECTCCI <0b011, "qc.selectnei">;
167+
def QC_SELECTIEQI : QCISELECTICCI <0b010, "qc.selectieqi">;
168+
def QC_SELECTINEI : QCISELECTICCI <0b011, "qc.selectinei">;
169+
} // Predicates = [HasVendorXqcics, IsRV32], DecoderNamespace = "Xqcics"

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ Error RISCVISAInfo::checkDependency() {
742742
bool HasZvl = MinVLen != 0;
743743
bool HasZcmt = Exts.count("zcmt") != 0;
744744
static constexpr StringLiteral XqciExts[] = {
745-
{"xqcia"}, {"xqcicsr"}, {"xqcisls"}};
745+
{"xqcia"}, {"xqcics"}, {"xqcicsr"}, {"xqcisls"}};
746746

747747
if (HasI && HasE)
748748
return getIncompatibleError("i", "e");

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
; RUN: llc -mtriple=riscv32 -mattr=+xtheadsync %s -o - | FileCheck --check-prefix=RV32XTHEADSYNC %s
8383
; RUN: llc -mtriple=riscv32 -mattr=+xwchc %s -o - | FileCheck --check-prefix=RV32XWCHC %s
8484
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcia %s -o - | FileCheck --check-prefix=RV32XQCIA %s
85+
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcics %s -o - | FileCheck --check-prefix=RV32XQCICS %s
8586
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcicsr %s -o - | FileCheck --check-prefix=RV32XQCICSR %s
8687
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcisls %s -o - | FileCheck --check-prefix=RV32XQCISLS %s
8788
; RUN: llc -mtriple=riscv32 -mattr=+zaamo %s -o - | FileCheck --check-prefix=RV32ZAAMO %s
@@ -389,6 +390,7 @@
389390
; RV32XTHEADSYNC: .attribute 5, "rv32i2p1_xtheadsync1p0"
390391
; RV32XWCHC: .attribute 5, "rv32i2p1_xwchc2p2"
391392
; RV32XQCIA: .attribute 5, "rv32i2p1_xqcia0p2"
393+
; RV32XQCICS: .attribute 5, "rv32i2p1_xqcics0p2"
392394
; RV32XQCICSR: .attribute 5, "rv32i2p1_xqcicsr0p2"
393395
; RV32XQCISLS: .attribute 5, "rv32i2p1_xqcisls0p2"
394396
; RV32ZAAMO: .attribute 5, "rv32i2p1_zaamo1p0"

llvm/test/MC/RISCV/xqcics-invalid.s

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Xqcics - Qualcomm uC Conditional Select Extension
2+
# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-xqcics < %s 2>&1 \
3+
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-IMM %s
4+
# RUN: not llvm-mc -triple riscv32 -mattr=-experimental-xqcics < %s 2>&1 \
5+
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-EXT %s
6+
7+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
8+
qc.selecteqi 9, 15, x4, x3
9+
10+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
11+
qc.selecteqi x9, 15, x4
12+
13+
# CHECK-IMM: :[[@LINE+1]]:18: error: immediate must be an integer in the range [-16, 15]
14+
qc.selecteqi x9, 16, x4, x3
15+
16+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcics' (Qualcomm uC Conditional Select Extension)
17+
qc.selecteqi x9, 15, x4, x3
18+
19+
20+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
21+
qc.selectieq 8, x4, x3, 12
22+
23+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
24+
qc.selectieq x8, x4, x3
25+
26+
# CHECK-IMM: :[[@LINE+1]]:26: error: immediate must be an integer in the range [-16, 15]
27+
qc.selectieq x8, x4, x3, 17
28+
29+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcics' (Qualcomm uC Conditional Select Extension)
30+
qc.selectieq x8, x4, x3, 12
31+
32+
33+
# CHECK: :[[@LINE+1]]:15: error: invalid operand for instruction
34+
qc.selectieqi 9, 11, x3, 12
35+
36+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
37+
qc.selectieqi x9, 11, x3
38+
39+
# CHECK-IMM: :[[@LINE+1]]:19: error: immediate must be an integer in the range [-16, 15]
40+
qc.selectieqi x9, 16, x3, 12
41+
42+
# CHECK-IMM: :[[@LINE+1]]:27: error: immediate must be an integer in the range [-16, 15]
43+
qc.selectieqi x9, 11, x3, 18
44+
45+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcics' (Qualcomm uC Conditional Select Extension)
46+
qc.selectieqi x9, 11, x3, 12
47+
48+
49+
# CHECK: :[[@LINE+1]]:15: error: invalid operand for instruction
50+
qc.selectiieq 9, x3, 11, 12
51+
52+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
53+
qc.selectiieq x9, x3, 11
54+
55+
# CHECK-IMM: :[[@LINE+1]]:23: error: immediate must be an integer in the range [-16, 15]
56+
qc.selectiieq x9, x3, 16, 12
57+
58+
# CHECK-IMM: :[[@LINE+1]]:27: error: immediate must be an integer in the range [-16, 15]
59+
qc.selectiieq x9, x3, 11, 17
60+
61+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcics' (Qualcomm uC Conditional Select Extension)
62+
qc.selectiieq x9, x3, 11, 12
63+
64+
65+
# CHECK: :[[@LINE+1]]:15: error: invalid operand for instruction
66+
qc.selectiine 8, x3, 10, 11
67+
68+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
69+
qc.selectiine x8, x3, 10
70+
71+
# CHECK-IMM: :[[@LINE+1]]:23: error: immediate must be an integer in the range [-16, 15]
72+
qc.selectiine x8, x3, 16, 11
73+
74+
# CHECK-IMM: :[[@LINE+1]]:27: error: immediate must be an integer in the range [-16, 15]
75+
qc.selectiine x8, x3, 12, 18
76+
77+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcics' (Qualcomm uC Conditional Select Extension)
78+
qc.selectiine x8, x3, 10, 11
79+
80+
81+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
82+
qc.selectine 8, x3, x4, 11
83+
84+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
85+
qc.selectine x8, x3, x4
86+
87+
# CHECK-IMM: :[[@LINE+1]]:26: error: immediate must be an integer in the range [-16, 15]
88+
qc.selectine x8, x3, x4, 16
89+
90+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcics' (Qualcomm uC Conditional Select Extension)
91+
qc.selectine x8, x3, x4, 11
92+
93+
94+
# CHECK: :[[@LINE+1]]:15: error: invalid operand for instruction
95+
qc.selectinei 8, 11, x3, 12
96+
97+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
98+
qc.selectinei x8, 11, x3
99+
100+
# CHECK-IMM: :[[@LINE+1]]:19: error: immediate must be an integer in the range [-16, 15]
101+
qc.selectinei x8, 16, x3, 12
102+
103+
# CHECK-IMM: :[[@LINE+1]]:27: error: immediate must be an integer in the range [-16, 15]
104+
qc.selectinei x8, 11, x3, 18
105+
106+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcics' (Qualcomm uC Conditional Select Extension)
107+
qc.selectinei x8, 11, x3, 12
108+
109+
110+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
111+
qc.selectnei 8, 11, x3, x5
112+
113+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
114+
qc.selectnei x8, 11, x3
115+
116+
# CHECK-IMM: :[[@LINE+1]]:18: error: immediate must be an integer in the range [-16, 15]
117+
qc.selectnei x8, 16, x3, x5
118+
119+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcics' (Qualcomm uC Conditional Select Extension)
120+
qc.selectnei x8, 11, x3, x5
121+

0 commit comments

Comments
 (0)