Skip to content

Commit 87c2a2d

Browse files
committed
[RISCV] Add Qualcomn uC Xqcisync Synchronization And Delay Extension
1 parent 0744d49 commit 87c2a2d

File tree

7 files changed

+201
-9
lines changed

7 files changed

+201
-9
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -663,14 +663,15 @@ static constexpr FeatureBitset XRivosFeatureGroup = {
663663
};
664664

665665
static constexpr FeatureBitset XqciFeatureGroup = {
666-
RISCV::FeatureVendorXqcia, RISCV::FeatureVendorXqciac,
667-
RISCV::FeatureVendorXqcibi, RISCV::FeatureVendorXqcibm,
668-
RISCV::FeatureVendorXqcicli, RISCV::FeatureVendorXqcicm,
669-
RISCV::FeatureVendorXqcics, RISCV::FeatureVendorXqcicsr,
670-
RISCV::FeatureVendorXqciint, RISCV::FeatureVendorXqcilb,
671-
RISCV::FeatureVendorXqcili, RISCV::FeatureVendorXqcilia,
672-
RISCV::FeatureVendorXqcilo, RISCV::FeatureVendorXqcilsm,
673-
RISCV::FeatureVendorXqcisim, RISCV::FeatureVendorXqcisls,
666+
RISCV::FeatureVendorXqcia, RISCV::FeatureVendorXqciac,
667+
RISCV::FeatureVendorXqcibi, RISCV::FeatureVendorXqcibm,
668+
RISCV::FeatureVendorXqcicli, RISCV::FeatureVendorXqcicm,
669+
RISCV::FeatureVendorXqcics, RISCV::FeatureVendorXqcicsr,
670+
RISCV::FeatureVendorXqciint, RISCV::FeatureVendorXqcilb,
671+
RISCV::FeatureVendorXqcili, RISCV::FeatureVendorXqcilia,
672+
RISCV::FeatureVendorXqcilo, RISCV::FeatureVendorXqcilsm,
673+
RISCV::FeatureVendorXqcisim, RISCV::FeatureVendorXqcisls,
674+
RISCV::FeatureVendorXqcisync,
674675
};
675676

676677
static constexpr FeatureBitset XSfVectorGroup = {

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,14 @@ def HasVendorXqcilo
14221422
AssemblerPredicate<(all_of FeatureVendorXqcilo),
14231423
"'Xqcilo' (Qualcomm uC Large Offset Load Store Extension)">;
14241424

1425+
def FeatureVendorXqcisync
1426+
: RISCVExperimentalExtension<0, 2, "Qualcomm uC Synchronization And Delay Extension">;
1427+
1428+
def HasVendorXqcisync
1429+
: Predicate<"Subtarget->hasVendorXqcisync()">,
1430+
AssemblerPredicate<(all_of FeatureVendorXqcisync),
1431+
"'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)">;
1432+
14251433
def FeatureVendorXqccmp
14261434
: RISCVExperimentalExtension<0, 1,
14271435
"Qualcomm 16-bit Push/Pop and Double Moves",

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,24 @@ class QCIRVInst48EJ<bits<2> func2, string opcodestr>
446446
let Inst{6-0} = 0b0011111;
447447
}
448448

449+
class QCIRVInstCSync<bits<6> func1, string opcodestr>
450+
: RVInst16<(outs), (ins uimm3:$slist), opcodestr,
451+
"$slist", [], InstFormatCB> {
452+
bits<3> slist;
453+
let Inst{15-10} = func1;
454+
let Inst{9-7} = slist{2-0};
455+
let Inst{6-0} = 0b0000001;
456+
}
457+
458+
class QCIRVInstSync<bits<7> func1, string opcodestr>
459+
: RVInst<(outs), (ins uimm5:$imm), opcodestr,
460+
"$imm", [], InstFormatI> {
461+
bits<5> imm;
462+
let Inst{31-25} = func1;
463+
let Inst{24-20} = imm{4-0};
464+
let Inst{19-0} = 0b00000011000000010011;
465+
}
466+
449467
//===----------------------------------------------------------------------===//
450468
// Instructions
451469
//===----------------------------------------------------------------------===//
@@ -779,6 +797,27 @@ let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in {
779797
} // mayLoad = 0, mayStore = 0, hasSideEffects = 1
780798
} // Predicates = [HasVendorXqcisim, IsRV32]
781799

800+
let Predicates = [HasVendorXqcisync, IsRV32] in {
801+
let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in {
802+
def QC_C_DELAY : RVInst16<(outs), (ins uimm5nonzero:$imm), "qc.c.delay",
803+
"$imm", [], InstFormatCI> {
804+
bits<5> imm;
805+
let Inst{15-7} = 0b000000000;
806+
let Inst{6-2} = imm{4-0};
807+
let Inst{1-0} = 0b10;
808+
}
809+
def QC_C_SYNC : QCIRVInstCSync<0b100000, "qc.c.sync">;
810+
def QC_C_SYNCR : QCIRVInstCSync<0b100001, "qc.c.syncr">;
811+
def QC_C_SYNCWF: QCIRVInstCSync<0b100100, "qc.c.syncwf">;
812+
def QC_C_SYNCWL: QCIRVInstCSync<0b100101, "qc.c.syncwl">;
813+
def QC_SYNC: QCIRVInstSync<0b0001000, "qc.sync">;
814+
def QC_SYNCR: QCIRVInstSync<0b0010000, "qc.syncr">;
815+
def QC_SYNCWF: QCIRVInstSync<0b0100000, "qc.syncwf">;
816+
def QC_SYNCWL: QCIRVInstSync<0b1000000, "qc.syncwl">;
817+
818+
} // mayLoad = 0, mayStore = 0, hasSideEffects = 1
819+
} // Predicates = [HasVendorXqcisync, IsRV32]
820+
782821
} // DecoderNamespace = "Xqci"
783822

784823
//===----------------------------------------------------------------------===//

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ Error RISCVISAInfo::checkDependency() {
747747
{"xqcia"}, {"xqciac"}, {"xqcibi"}, {"xqcibm"},
748748
{"xqcicli"}, {"xqcicm"}, {"xqcics"}, {"xqcicsr"},
749749
{"xqciint"}, {"xqcilb"}, {"xqcili"}, {"xqcilia"},
750-
{"xqcilo"}, {"xqcilsm"}, {"xqcisim"}, {"xqcisls"}};
750+
{"xqcilo"}, {"xqcilsm"}, {"xqcisim"}, {"xqcisls"},{"xqcisync"}};
751751
static constexpr StringLiteral ZcdOverlaps[] = {
752752
{"zcmt"}, {"zcmp"}, {"xqccmp"}, {"xqciac"}, {"xqcicm"}};
753753

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@
426426
; RV32XQCILSM: .attribute 5, "rv32i2p1_xqcilsm0p2"
427427
; RV32XQCISIM: attribute 5, "rv32i2p1_zca1p0_xqcisim0p2"
428428
; RV32XQCISLS: .attribute 5, "rv32i2p1_xqcisls0p2"
429+
; RV32XQCISYNC: .attribute 5, "rv32i2p1_zca1p0_xqcisync0p2"
429430
; RV32ZAAMO: .attribute 5, "rv32i2p1_zaamo1p0"
430431
; RV32ZALRSC: .attribute 5, "rv32i2p1_zalrsc1p0"
431432
; RV32ZCA: .attribute 5, "rv32i2p1_zca1p0"
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Xqcisync - Qualcomm uC Synchronization And Delay Extension
2+
# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-xqcisync < %s 2>&1 \
3+
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-PLUS,CHECK-IMM %s
4+
# RUN: not llvm-mc -triple riscv32 -mattr=-experimental-xqcisync < %s 2>&1 \
5+
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-MINUS,CHECK-EXT %s
6+
7+
# CHECK-PLUS: :[[@LINE+2]]:12: error: immediate must be an integer in the range [1, 31]
8+
# CHECK-MINUS: :[[@LINE+1]]:12: error: invalid operand for instruction
9+
qc.c.delay 0
10+
11+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
12+
qc.c.delay
13+
14+
# CHECK-IMM: :[[@LINE+1]]:12: error: immediate must be an integer in the range [1, 31]
15+
qc.c.delay 32
16+
17+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)
18+
qc.c.delay 5
19+
20+
# CHECK-PLUS: :[[@LINE+2]]:11: error: immediate must be an integer in the range [0, 7]
21+
# CHECK-MINUS: :[[@LINE+1]]:11: error: invalid operand for instruction
22+
qc.c.sync 8
23+
24+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
25+
qc.c.sync
26+
27+
# CHECK-IMM: :[[@LINE+1]]:11: error: immediate must be an integer in the range [0, 7]
28+
qc.c.sync -1
29+
30+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)
31+
qc.c.sync 3
32+
33+
# CHECK-PLUS: :[[@LINE+2]]:12: error: immediate must be an integer in the range [0, 7]
34+
# CHECK-MINUS: :[[@LINE+1]]:12: error: invalid operand for instruction
35+
qc.c.syncr 10
36+
37+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
38+
qc.c.syncr
39+
40+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)
41+
qc.c.syncr 3
42+
43+
# CHECK-PLUS: :[[@LINE+2]]:13: error: immediate must be an integer in the range [0, 7]
44+
# CHECK-MINUS: :[[@LINE+1]]:13: error: invalid operand for instruction
45+
qc.c.syncwf 8
46+
47+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
48+
qc.c.syncwf
49+
50+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)
51+
qc.c.syncwf 5
52+
53+
# CHECK-PLUS: :[[@LINE+2]]:13: error: immediate must be an integer in the range [0, 7]
54+
# CHECK-MINUS: :[[@LINE+1]]:13: error: invalid operand for instruction
55+
qc.c.syncwl 8
56+
57+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
58+
qc.c.syncwl
59+
60+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)
61+
qc.c.syncwl 7
62+
63+
# CHECK-PLUS: :[[@LINE+2]]:9: error: immediate must be an integer in the range [0, 31]
64+
# CHECK-MINUS: :[[@LINE+1]]:9: error: invalid operand for instruction
65+
qc.sync 32
66+
67+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
68+
qc.sync
69+
70+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)
71+
qc.sync 10
72+
73+
# CHECK-PLUS: :[[@LINE+2]]:10: error: immediate must be an integer in the range [0, 31]
74+
# CHECK-MINUS: :[[@LINE+1]]:10: error: invalid operand for instruction
75+
qc.syncr -1
76+
77+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
78+
qc.syncr
79+
80+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)
81+
qc.syncr 10
82+
83+
# CHECK-PLUS: :[[@LINE+2]]:11: error: immediate must be an integer in the range [0, 31]
84+
# CHECK-MINUS: :[[@LINE+1]]:11: error: invalid operand for instruction
85+
qc.syncwf 33
86+
87+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
88+
qc.syncwf
89+
90+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)
91+
qc.syncwf 10
92+
93+
# CHECK-PLUS: :[[@LINE+2]]:11: error: immediate must be an integer in the range [0, 31]
94+
# CHECK-MINUS: :[[@LINE+1]]:11: error: invalid operand for instruction
95+
qc.syncwl -1
96+
97+
# CHECK: :[[@LINE+1]]:1: error: too few operands for instruction
98+
qc.syncwl
99+
100+
# CHECK-EXT: :[[@LINE+1]]:1: error: instruction requires the following: 'Xqcisync' (Qualcomm uC Synchronization And Delay Extension)
101+
qc.syncwl 10
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Xqcisync - Qualcomm uC Synchronization And Delay Extension
2+
# RUN: llvm-mc -triple=riscv32 -mattr=+experimental-xqcisync < %s -show-encoding \
3+
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
4+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcisync < %s \
5+
# RUN: | llvm-objdump --mattr=+experimental-xqcisync --no-print-imm-hex -d - \
6+
# RUN: | FileCheck -check-prefix=CHECK-INST %s
7+
8+
# CHECK-INST: qc.c.delay 5
9+
# CHECK-ENC: encoding: [0x16,0x00]
10+
qc.c.delay 5
11+
12+
# CHECK-INST: qc.c.sync 3
13+
# CHECK-ENC: encoding: [0x81,0x81]
14+
qc.c.sync 3
15+
16+
# CHECK-INST: qc.c.syncr 3
17+
# CHECK-ENC: encoding: [0x81,0x85]
18+
qc.c.syncr 3
19+
20+
# CHECK-INST: qc.c.syncwf 5
21+
# CHECK-ENC: encoding: [0x81,0x92]
22+
qc.c.syncwf 5
23+
24+
# CHECK-INST: qc.c.syncwl 7
25+
# CHECK-ENC: encoding: [0x81,0x97]
26+
qc.c.syncwl 7
27+
28+
# CHECK-INST: qc.sync 10
29+
# CHECK-ENC: encoding: [0x13,0x30,0xa0,0x10]
30+
qc.sync 10
31+
32+
# CHECK-INST: qc.syncr 10
33+
# CHECK-ENC: encoding: [0x13,0x30,0xa0,0x20]
34+
qc.syncr 10
35+
36+
# CHECK-INST: qc.syncwf 10
37+
# CHECK-ENC: encoding: [0x13,0x30,0xa0,0x40]
38+
qc.syncwf 10
39+
40+
# CHECK-INST: qc.syncwl 10
41+
# CHECK-ENC: encoding: [0x13,0x30,0xa0,0x80]
42+
qc.syncwl 10

0 commit comments

Comments
 (0)