Skip to content

Commit 532a269

Browse files
authored
[RISCV] Add Qualcomm uC Xqcicli (Conditional Load Immediate) extension (llvm#121292)
This extension adds 12 instructions that conditionally load an immediate value. The current spec can be found at: https://github.com/quic/riscv-unified-db/releases/latest This patch adds assembler only support.
1 parent 6dcd2b0 commit 532a269

File tree

11 files changed

+342
-2
lines changed

11 files changed

+342
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
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)
192192
// CHECK-NEXT: xqciac 0.2 'Xqciac' (Qualcomm uC Load-Store Address Calculation Extension)
193+
// CHECK-NEXT: xqcicli 0.2 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
193194
// CHECK-NEXT: xqcics 0.2 'Xqcics' (Qualcomm uC Conditional Select Extension)
194195
// CHECK-NEXT: xqcicsr 0.2 'Xqcicsr' (Qualcomm uC CSR Extension)
195196
// CHECK-NEXT: xqcilsm 0.2 'Xqcilsm' (Qualcomm uC Load Store Multiple Extension)

llvm/docs/RISCVUsage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ The current vendor extensions supported are:
432432
``experimental-Xqciac``
433433
LLVM implements `version 0.2 of the Qualcomm uC Load-Store Address Calculation 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.
434434

435+
``experimental-Xqcicli``
436+
LLVM implements `version 0.2 of the Qualcomm uC Conditional Load Immediate 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.
437+
435438
``experimental-Xqcics``
436439
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.
437440

llvm/docs/ReleaseNotes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ Changes to the RISC-V Backend
230230
extension.
231231
* Adds experimental assembler support for the Qualcomm uC 'Xqcilsm` (Load Store Multiple)
232232
extension.
233+
* Adds experimental assembler support for the Qualcomm uC 'Xqcicli` (Conditional Load Immediate)
234+
extension.
233235

234236
Changes to the WebAssembly Backend
235237
----------------------------------

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
695695
TRY_TO_DECODE_FEATURE(
696696
RISCV::FeatureVendorXqciac, DecoderTableXqciac32,
697697
"Qualcomm uC Load-Store Address Calculation custom opcode table");
698+
TRY_TO_DECODE_FEATURE(
699+
RISCV::FeatureVendorXqcicli, DecoderTableXqcicli32,
700+
"Qualcomm uC Conditional Load Immediate custom opcode table");
698701
TRY_TO_DECODE(true, DecoderTable32, "RISCV32 table");
699702

700703
return MCDisassembler::Fail;

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,14 @@ def HasVendorXqciac
12821282
AssemblerPredicate<(all_of FeatureVendorXqciac),
12831283
"'Xqciac' (Qualcomm uC Load-Store Address Calculation Extension)">;
12841284

1285+
def FeatureVendorXqcicli
1286+
: RISCVExperimentalExtension<0, 2,
1287+
"Qualcomm uC Conditional Load Immediate Extension">;
1288+
def HasVendorXqcicli
1289+
: Predicate<"Subtarget->hasVendorXqcicli()">,
1290+
AssemblerPredicate<(all_of FeatureVendorXqcicli),
1291+
"'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)">;
1292+
12851293
//===----------------------------------------------------------------------===//
12861294
// LLVM specific features and extensions
12871295
//===----------------------------------------------------------------------===//

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ class QCIStoreMultiple<bits<2> funct2, DAGOperand InTyRs2, string opcodestr>
139139
let Inst{31-25} = {funct2, imm{6-2}};
140140
}
141141

142+
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
143+
class QCILICC<bits<3> funct3, bits<2> funct2, DAGOperand InTyRs2, string opcodestr>
144+
: RVInstRBase<funct3, OPC_CUSTOM_2, (outs GPRNoX0:$rd_wb),
145+
(ins GPRNoX0:$rd, GPRNoX0:$rs1, InTyRs2:$rs2, simm5:$simm),
146+
opcodestr, "$rd, $rs1, $rs2, $simm"> {
147+
let Constraints = "$rd = $rd_wb";
148+
bits<5> simm;
149+
150+
let Inst{31-25} = {simm, funct2};
151+
}
152+
142153
//===----------------------------------------------------------------------===//
143154
// Instructions
144155
//===----------------------------------------------------------------------===//
@@ -243,6 +254,22 @@ let Predicates = [HasVendorXqcilsm, IsRV32], DecoderNamespace = "Xqcilsm" in {
243254
def QC_LWMI : QCILoadMultiple<0b01, uimm5nonzero, "qc.lwmi">;
244255
} // Predicates = [HasVendorXqcilsm, IsRV32], DecoderNamespace = "Xqcilsm"
245256

257+
let Predicates = [HasVendorXqcicli, IsRV32], DecoderNamespace = "Xqcicli" in {
258+
def QC_LIEQ : QCILICC<0b000, 0b01, GPRNoX0, "qc.lieq">;
259+
def QC_LINE : QCILICC<0b001, 0b01, GPRNoX0, "qc.line">;
260+
def QC_LILT : QCILICC<0b100, 0b01, GPRNoX0, "qc.lilt">;
261+
def QC_LIGE : QCILICC<0b101, 0b01, GPRNoX0, "qc.lige">;
262+
def QC_LILTU : QCILICC<0b110, 0b01, GPRNoX0, "qc.liltu">;
263+
def QC_LIGEU : QCILICC<0b111, 0b01, GPRNoX0, "qc.ligeu">;
264+
265+
def QC_LIEQI : QCILICC<0b000, 0b11, simm5, "qc.lieqi">;
266+
def QC_LINEI : QCILICC<0b001, 0b11, simm5, "qc.linei">;
267+
def QC_LILTI : QCILICC<0b100, 0b11, simm5, "qc.lilti">;
268+
def QC_LIGEI : QCILICC<0b101, 0b11, simm5, "qc.ligei">;
269+
def QC_LILTUI : QCILICC<0b110, 0b11, uimm5, "qc.liltui">;
270+
def QC_LIGEUI : QCILICC<0b111, 0b11, uimm5, "qc.ligeui">;
271+
} // Predicates = [HasVendorXqcicli, IsRV32], DecoderNamespace = "Xqcicli"
272+
246273
//===----------------------------------------------------------------------===//
247274
// Aliases
248275
//===----------------------------------------------------------------------===//

llvm/lib/TargetParser/RISCVISAInfo.cpp

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

747748
if (HasI && HasE)
748749
return getIncompatibleError("i", "e");

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
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
8585
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqciac %s -o - | FileCheck --check-prefix=RV32XQCIAC %s
86+
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcicli %s -o - | FileCheck --check-prefix=RV32XQCICLI %s
8687
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcics %s -o - | FileCheck --check-prefix=RV32XQCICS %s
8788
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcicsr %s -o - | FileCheck --check-prefix=RV32XQCICSR %s
8889
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcilsm %s -o - | FileCheck --check-prefix=RV32XQCILSM %s
@@ -393,6 +394,7 @@
393394
; RV32XWCHC: .attribute 5, "rv32i2p1_xwchc2p2"
394395
; RV32XQCIA: .attribute 5, "rv32i2p1_xqcia0p2"
395396
; RV32XQCIAC: .attribute 5, "rv32i2p1_zca1p0_xqciac0p2"
397+
; RV32XQCICLI: .attribute 5, "rv32i2p1_xqcicli0p2"
396398
; RV32XQCICS: .attribute 5, "rv32i2p1_xqcics0p2"
397399
; RV32XQCICSR: .attribute 5, "rv32i2p1_xqcicsr0p2"
398400
; RV32XQCILSM: .attribute 5, "rv32i2p1_xqcilsm0p2"

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

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# Xqcicli - Qualcomm uC Conditional Load Immediate Instructions
2+
# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-xqcicli < %s 2>&1 \
3+
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-PLUS %s
4+
# RUN: not llvm-mc -triple riscv32 -mattr=-experimental-xqcicli < %s 2>&1 \
5+
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-MINUS %s
6+
7+
# CHECK: :[[@LINE+1]]:9: error: invalid operand for instruction
8+
qc.lieq x0, x4, x6, 10
9+
10+
# CHECK: :[[@LINE+1]]:13: error: invalid operand for instruction
11+
qc.lieq x2, x0, x6, 10
12+
13+
# CHECK: :[[@LINE+1]]:17: error: invalid operand for instruction
14+
qc.lieq x2, x4, x0, 10
15+
16+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
17+
qc.lieq x2, x4, x6
18+
19+
# CHECK-PLUS: :[[@LINE+1]]:21: error: immediate must be an integer in the range [-16, 15]
20+
qc.lieq x2, x4, x6, 40
21+
22+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
23+
qc.lieq x2, x4, x6, 10
24+
25+
26+
# CHECK: :[[@LINE+1]]:9: error: invalid operand for instruction
27+
qc.lige x0, x8, x20, 2
28+
29+
# CHECK: :[[@LINE+1]]:13: error: invalid operand for instruction
30+
qc.lige x4, x0, x20, 2
31+
32+
# CHECK: :[[@LINE+1]]:17: error: invalid operand for instruction
33+
qc.lige x4, x8, x0, 2
34+
35+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
36+
qc.lige x4, x8, x20
37+
38+
# CHECK-PLUS: :[[@LINE+1]]:22: error: immediate must be an integer in the range [-16, 15]
39+
qc.lige x4, x8, x20, -18
40+
41+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
42+
qc.lige x4, x8, x20, 2
43+
44+
45+
# CHECK: :[[@LINE+1]]:9: error: invalid operand for instruction
46+
qc.lilt x0, x9, x10, 3
47+
48+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
49+
qc.lilt x19, x0, x10, 3
50+
51+
# CHECK: :[[@LINE+1]]:18: error: invalid operand for instruction
52+
qc.lilt x19, x9, x0, 3
53+
54+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
55+
qc.lilt x19, x9, x10
56+
57+
# CHECK-PLUS: :[[@LINE+1]]:23: error: immediate must be an integer in the range [-16, 15]
58+
qc.lilt x19, x9, x10, 39
59+
60+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
61+
qc.lilt x19, x9, x10, 3
62+
63+
64+
# CHECK: :[[@LINE+1]]:9: error: invalid operand for instruction
65+
qc.line x0, x14, x6, 10
66+
67+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
68+
qc.line x18, x0, x6, 10
69+
70+
# CHECK: :[[@LINE+1]]:19: error: invalid operand for instruction
71+
qc.line x18, x14, x0, 10
72+
73+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
74+
qc.line x18, x14, x6
75+
76+
# CHECK-PLUS: :[[@LINE+1]]:23: error: immediate must be an integer in the range [-16, 15]
77+
qc.line x18, x14, x6, 100
78+
79+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
80+
qc.line x18, x14, x6, 10
81+
82+
83+
# CHECK: :[[@LINE+1]]:10: error: invalid operand for instruction
84+
qc.ligeu x0, x4, x6, 10
85+
86+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
87+
qc.ligeu x2, x0, x6, 10
88+
89+
# CHECK: :[[@LINE+1]]:18: error: invalid operand for instruction
90+
qc.ligeu x2, x4, x0, 10
91+
92+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
93+
qc.ligeu x2, x4, x6
94+
95+
# CHECK-PLUS: :[[@LINE+1]]:22: error: immediate must be an integer in the range [-16, 15]
96+
qc.ligeu x2, x4, x6, 70
97+
98+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
99+
qc.ligeu x2, x4, x6, 10
100+
101+
102+
# CHECK: :[[@LINE+1]]:10: error: invalid operand for instruction
103+
qc.liltu x0, x19, x12, 13
104+
105+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
106+
qc.liltu x1, x0, x12, 13
107+
108+
# CHECK: :[[@LINE+1]]:19: error: invalid operand for instruction
109+
qc.liltu x1, x19, x0, 13
110+
111+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
112+
qc.liltu x1, x19, x12
113+
114+
# CHECK-PLUS: :[[@LINE+1]]:24: error: immediate must be an integer in the range [-16, 15]
115+
qc.liltu x1, x19, x12, 73
116+
117+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
118+
qc.liltu x1, x19, x12, 13
119+
120+
121+
# CHECK: :[[@LINE+1]]:10: error: invalid operand for instruction
122+
qc.lieqi x0, x1, 15, 12
123+
124+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
125+
qc.lieqi x7, x0, 15, 12
126+
127+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
128+
qc.lieqi x7, x1, 15
129+
130+
# CHECK-PLUS: :[[@LINE+1]]:18: error: immediate must be an integer in the range [-16, 15]
131+
qc.lieqi x7, x1, 25, 12
132+
133+
# CHECK-PLUS: :[[@LINE+1]]:22: error: immediate must be an integer in the range [-16, 15]
134+
qc.lieqi x7, x1, 15, -22
135+
136+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
137+
qc.lieqi x7, x1, 15, 12
138+
139+
140+
# CHECK: :[[@LINE+1]]:10: error: invalid operand for instruction
141+
qc.ligei x0, x11, -4, 9
142+
143+
# CHECK: :[[@LINE+1]]:15: error: invalid operand for instruction
144+
qc.ligei x17, x0, -4, 9
145+
146+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
147+
qc.ligei x17, x11, -4
148+
149+
# CHECK-PLUS: :[[@LINE+1]]:20: error: immediate must be an integer in the range [-16, 15]
150+
qc.ligei x17, x11, -24, 9
151+
152+
# CHECK-PLUS: :[[@LINE+1]]:24: error: immediate must be an integer in the range [-16, 15]
153+
qc.ligei x17, x11, -4, 59
154+
155+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
156+
qc.ligei x17, x11, -4, 9
157+
158+
159+
# CHECK: :[[@LINE+1]]:10: error: invalid operand for instruction
160+
qc.lilti x0, x11, -14, 2
161+
162+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
163+
qc.lilti x9, x0, -14, 2
164+
165+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
166+
qc.lilti x9, x11, -14
167+
168+
# CHECK-PLUS: :[[@LINE+1]]:19: error: immediate must be an integer in the range [-16, 15]
169+
qc.lilti x9, x11, -84, 2
170+
171+
# CHECK-PLUS: :[[@LINE+1]]:24: error: immediate must be an integer in the range [-16, 15]
172+
qc.lilti x9, x11, -14, 52
173+
174+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
175+
qc.lilti x9, x11, -14, 2
176+
177+
178+
# CHECK: :[[@LINE+1]]:10: error: invalid operand for instruction
179+
qc.linei x0, x1, 10, 12
180+
181+
# CHECK: :[[@LINE+1]]:14: error: invalid operand for instruction
182+
qc.linei x5, x0, 10, 12
183+
184+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
185+
qc.linei x5, x1, 10
186+
187+
# CHECK-PLUS: :[[@LINE+1]]:18: error: immediate must be an integer in the range [-16, 15]
188+
qc.linei x5, x1, 130, 12
189+
190+
# CHECK-PLUS: :[[@LINE+1]]:22: error: immediate must be an integer in the range [-16, 15]
191+
qc.linei x5, x1, 10, 124
192+
193+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
194+
qc.linei x5, x1, 10, 12
195+
196+
197+
# CHECK: :[[@LINE+1]]:11: error: invalid operand for instruction
198+
qc.ligeui x0, x12, 7, -12
199+
200+
# CHECK: :[[@LINE+1]]:15: error: invalid operand for instruction
201+
qc.ligeui x2, x0, 7, -12
202+
203+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
204+
qc.ligeui x2, x12, 7
205+
206+
# CHECK-PLUS: :[[@LINE+1]]:20: error: immediate must be an integer in the range [0, 31]
207+
qc.ligeui x2, x12, -7, -12
208+
209+
# CHECK-PLUS: :[[@LINE+1]]:23: error: immediate must be an integer in the range [-16, 15]
210+
qc.ligeui x2, x12, 7, -17
211+
212+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
213+
qc.ligeui x2, x12, 7, -12
214+
215+
216+
# CHECK: :[[@LINE+1]]:11: error: invalid operand for instruction
217+
qc.liltui x0, x25, 31, 12
218+
219+
# CHECK: :[[@LINE+1]]:15: error: invalid operand for instruction
220+
qc.liltui x3, x0, 31, 12
221+
222+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
223+
qc.liltui x3, x25, 31
224+
225+
# CHECK-PLUS: :[[@LINE+1]]:20: error: immediate must be an integer in the range [0, 31]
226+
qc.liltui x3, x25, 32, 12
227+
228+
# CHECK-PLUS: :[[@LINE+1]]:24: error: immediate must be an integer in the range [-16, 15]
229+
qc.liltui x3, x25, 31, 112
230+
231+
# CHECK-MINUS: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcicli' (Qualcomm uC Conditional Load Immediate Extension)
232+
qc.liltui x3, x25, 31, 12

0 commit comments

Comments
 (0)