Skip to content

Commit 12e1667

Browse files
committed
[RISCV] Add Qualcomm uC Xqciio (External Input Output) extension
This extension adds two external input output instructions for a non-memory-mapped device. The current spec can be found at: https://github.com/quic/riscv-unified-db/releases/latest This patch adds assembler only support. Change-Id: Icef5879bce785c17039dc3958f7b52483ad9c65a
1 parent 174110b commit 12e1667

File tree

13 files changed

+136
-15
lines changed

13 files changed

+136
-15
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
// CHECK-NEXT: xqcics 0.2 'Xqcics' (Qualcomm uC Conditional Select Extension)
207207
// CHECK-NEXT: xqcicsr 0.2 'Xqcicsr' (Qualcomm uC CSR Extension)
208208
// CHECK-NEXT: xqciint 0.4 'Xqciint' (Qualcomm uC Interrupts Extension)
209+
// CHECK-NEXT: xqciio 0.1 'Xqciio' (Qualcomm uC External Input Output Extension)
209210
// CHECK-NEXT: xqcilb 0.2 'Xqcilb' (Qualcomm uC Long Branch Extension)
210211
// CHECK-NEXT: xqcili 0.2 'Xqcili' (Qualcomm uC Load Large Immediate Extension)
211212
// CHECK-NEXT: xqcilia 0.2 'Xqcilia' (Qualcomm uC Large Immediate Arithmetic Extension)

llvm/docs/RISCVUsage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ The current vendor extensions supported are:
461461
``experimental-Xqcicsr``
462462
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.
463463

464+
``experimental-Xqciio``
465+
LLVM implements `version 0.1 of the Qualcomm uC External Input Output 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.
466+
464467
``experimental-Xqciint``
465468
LLVM implements `version 0.4 of the Qualcomm uC Interrupts 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.
466469

llvm/docs/ReleaseNotes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ Changes to the RISC-V Backend
142142
extension.
143143
* Adds experimental assembler support for the Qualcomm uC 'Xqcisync` (Sync Delay)
144144
extension.
145+
* Adds experimental assembler support for the Qualcomm uC 'Xqciio` (External Input Output)
146+
extension.
145147
* Adds assembler support for the 'Zilsd` (Load/Store Pair Instructions)
146148
extension.
147149
* Adds assembler support for the 'Zclsd` (Compressed Load/Store Pair Instructions)

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,16 @@ struct RISCVOperand final : public MCParsedAsmOperand {
987987
return SignExtend64<32>(Imm);
988988
}
989989

990+
bool isUImm14Lsb00() const {
991+
if (!isImm())
992+
return false;
993+
int64_t Imm;
994+
RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
995+
bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
996+
return IsConstantImm && isShiftedUInt<12, 2>(Imm) &&
997+
VK == RISCVMCExpr::VK_None;
998+
}
999+
9901000
bool isSImm11() const {
9911001
if (!isImm())
9921002
return false;
@@ -1741,6 +1751,10 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
17411751
return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 10) - 1);
17421752
case Match_InvalidUImm11:
17431753
return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 11) - 1);
1754+
case Match_InvalidUImm14Lsb00:
1755+
return generateImmOutOfRangeError(
1756+
Operands, ErrorInfo, 0, (1 << 14) - 4,
1757+
"immediate must be a multiple of 4 bytes in the range");
17441758
case Match_InvalidUImm16NonZero:
17451759
return generateImmOutOfRangeError(Operands, ErrorInfo, 1, (1 << 16) - 1);
17461760
case Match_InvalidSImm12:

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -672,15 +672,15 @@ static constexpr FeatureBitset XRivosFeatureGroup = {
672672
};
673673

674674
static constexpr FeatureBitset XqciFeatureGroup = {
675-
RISCV::FeatureVendorXqcia, RISCV::FeatureVendorXqciac,
676-
RISCV::FeatureVendorXqcibi, RISCV::FeatureVendorXqcibm,
677-
RISCV::FeatureVendorXqcicli, RISCV::FeatureVendorXqcicm,
678-
RISCV::FeatureVendorXqcics, RISCV::FeatureVendorXqcicsr,
679-
RISCV::FeatureVendorXqciint, RISCV::FeatureVendorXqcilb,
680-
RISCV::FeatureVendorXqcili, RISCV::FeatureVendorXqcilia,
681-
RISCV::FeatureVendorXqcilo, RISCV::FeatureVendorXqcilsm,
682-
RISCV::FeatureVendorXqcisim, RISCV::FeatureVendorXqcisls,
683-
RISCV::FeatureVendorXqcisync,
675+
RISCV::FeatureVendorXqcia, RISCV::FeatureVendorXqciac,
676+
RISCV::FeatureVendorXqcibi, RISCV::FeatureVendorXqcibm,
677+
RISCV::FeatureVendorXqcicli, RISCV::FeatureVendorXqcicm,
678+
RISCV::FeatureVendorXqcics, RISCV::FeatureVendorXqcicsr,
679+
RISCV::FeatureVendorXqciint, RISCV::FeatureVendorXqciio,
680+
RISCV::FeatureVendorXqcilb, RISCV::FeatureVendorXqcili,
681+
RISCV::FeatureVendorXqcilia, RISCV::FeatureVendorXqcilo,
682+
RISCV::FeatureVendorXqcilsm, RISCV::FeatureVendorXqcisim,
683+
RISCV::FeatureVendorXqcisls, RISCV::FeatureVendorXqcisync,
684684
};
685685

686686
static constexpr FeatureBitset XSfVectorGroup = {

llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ enum OperandType : unsigned {
314314
OPERAND_UIMM10_LSB00_NONZERO,
315315
OPERAND_UIMM11,
316316
OPERAND_UIMM12,
317+
OPERAND_UIMM14_LSB00,
317318
OPERAND_UIMM16,
318319
OPERAND_UIMM16_NONZERO,
319320
OPERAND_UIMM20,

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,13 @@ def HasVendorXqcicm
13761376
AssemblerPredicate<(all_of FeatureVendorXqcicm),
13771377
"'Xqcicm' (Qualcomm uC Conditional Move Extension)">;
13781378

1379+
def FeatureVendorXqciio
1380+
: RISCVExperimentalExtension<0, 1, "Qualcomm uC External Input Output Extension">;
1381+
def HasVendorXqciio
1382+
: Predicate<"Subtarget->hasVendorXqciio()">,
1383+
AssemblerPredicate<(all_of FeatureVendorXqciio),
1384+
"'Xqciio' (Qualcomm uC External Input Output Extension)">;
1385+
13791386
def FeatureVendorXqciint
13801387
: RISCVExperimentalExtension<0, 4, "Qualcomm uC Interrupts Extension",
13811388
[FeatureStdExtZca]>;

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ def uimm10 : RISCVUImmLeafOp<10>;
6969

7070
def uimm11 : RISCVUImmLeafOp<11>;
7171

72+
// A 14-bit unsigned immediate where the least significant two bits are zero.
73+
def uimm14lsb00 : RISCVOp,
74+
ImmLeaf<XLenVT, [{return isShiftedUInt<12, 2>(Imm);}]> {
75+
let ParserMatchClass = UImmAsmOperand<14, "Lsb00">;
76+
let EncoderMethod = "getImmOpValue";
77+
let DecoderMethod = "decodeUImmOperand<14>";
78+
let OperandType = "OPERAND_UIMM14_LSB00";
79+
}
80+
7281
def uimm16nonzero : RISCVOp<XLenVT>,
7382
ImmLeaf<XLenVT, [{return (Imm != 0) && isUInt<16>(Imm);}]> {
7483
let ParserMatchClass = UImmAsmOperand<16, "NonZero">;
@@ -741,6 +750,28 @@ def QC_C_MILEAVERET : QCIRVInst16CI_NONE<0b10100, "qc.c.mileaveret">;
741750

742751
} // Predicates = [HasVendorXqciint, IsRV32], hasSideEffects = 1
743752

753+
let Predicates = [HasVendorXqciio, IsRV32] in {
754+
let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in {
755+
def QC_OUTW : RVInstI<0b100, OPC_CUSTOM_0, (outs),
756+
(ins GPR:$rs3, GPR:$rs1, uimm14lsb00:$imm14),
757+
"qc.outw", "$rs3, ${imm14}(${rs1})"> {
758+
bits<5> rs3;
759+
bits<14> imm14;
760+
761+
let rd = rs3;
762+
let imm12 = imm14{13-2};
763+
}
764+
765+
def QC_INW : RVInstI<0b101, OPC_CUSTOM_0, (outs GPRNoX0:$rd),
766+
(ins GPR:$rs1, uimm14lsb00:$imm14),
767+
"qc.inw", "$rd, ${imm14}(${rs1})"> {
768+
bits<14> imm14;
769+
770+
let imm12 = imm14{13-2};
771+
}
772+
} // hasSideEffects = 1, mayLoad = 0, mayStore = 0
773+
} // Predicates = [HasVendorXqciio, IsRV32]
774+
744775
let Predicates = [HasVendorXqcilo, IsRV32] in {
745776
def QC_E_LB : QCIRVInstEILoad<0b101, 0b00, "qc.e.lb">;
746777
def QC_E_LBU : QCIRVInstEILoad<0b101, 0b01, "qc.e.lbu">;

llvm/lib/TargetParser/RISCVISAInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,9 @@ Error RISCVISAInfo::checkDependency() {
745745

746746
static constexpr StringLiteral XqciExts[] = {
747747
{"xqcia"}, {"xqciac"}, {"xqcibi"}, {"xqcibm"}, {"xqcicli"},
748-
{"xqcicm"}, {"xqcics"}, {"xqcicsr"}, {"xqciint"}, {"xqcilb"},
749-
{"xqcili"}, {"xqcilia"}, {"xqcilo"}, {"xqcilsm"}, {"xqcisim"},
750-
{"xqcisls"}, {"xqcisync"}};
748+
{"xqcicm"}, {"xqcics"}, {"xqcicsr"}, {"xqciint"}, {"xqciio"},
749+
{"xqcilb"}, {"xqcili"}, {"xqcilia"}, {"xqcilo"}, {"xqcilsm"},
750+
{"xqcisim"}, {"xqcisls"}, {"xqcisync"}};
751751
static constexpr StringLiteral ZcdOverlaps[] = {
752752
{"zcmt"}, {"zcmp"}, {"xqccmp"}, {"xqciac"}, {"xqcicm"}};
753753

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcics %s -o - | FileCheck --check-prefix=RV32XQCICS %s
9494
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcicsr %s -o - | FileCheck --check-prefix=RV32XQCICSR %s
9595
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqciint %s -o - | FileCheck --check-prefix=RV32XQCIINT %s
96+
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqciio %s -o - | FileCheck --check-prefix=RV32XQCIIO %s
9697
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcilb %s -o - | FileCheck --check-prefix=RV32XQCILB %s
9798
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcili %s -o - | FileCheck --check-prefix=RV32XQCILI %s
9899
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcilia %s -o - | FileCheck --check-prefix=RV32XQCILIA %s
@@ -428,6 +429,7 @@
428429
; RV32XQCICS: .attribute 5, "rv32i2p1_xqcics0p2"
429430
; RV32XQCICSR: .attribute 5, "rv32i2p1_xqcicsr0p2"
430431
; RV32XQCIINT: .attribute 5, "rv32i2p1_zca1p0_xqciint0p4"
432+
; RV32XQCIIO: .attribute 5, "rv32i2p1_xqciio0p1"
431433
; RV32XQCILB: .attribute 5, "rv32i2p1_zca1p0_xqcilb0p2"
432434
; RV32XQCILI: .attribute 5, "rv32i2p1_zca1p0_xqcili0p2"
433435
; RV32XQCILIA: .attribute 5, "rv32i2p1_zca1p0_xqcilia0p2"

0 commit comments

Comments
 (0)