Skip to content

Commit 2cbdf14

Browse files
committed
fixup! [RISCV] Merge Xqci Decoder Tables
1 parent 0a2ce34 commit 2cbdf14

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,15 @@ void RISCVDisassembler::addSPOperands(MCInst &MI) const {
609609
#define TRY_TO_DECODE_FEATURE_ANY(FEATURES, DECODER_TABLE, DESC) \
610610
TRY_TO_DECODE((STI.getFeatureBits() & (FEATURES)).any(), DECODER_TABLE, DESC)
611611

612+
static constexpr FeatureBitset XqciFeatureGroup = {
613+
RISCV::FeatureVendorXqcia, RISCV::FeatureVendorXqciac,
614+
RISCV::FeatureVendorXqcicli, RISCV::FeatureVendorXqcicm,
615+
RISCV::FeatureVendorXqcics, RISCV::FeatureVendorXqcicsr,
616+
RISCV::FeatureVendorXqciint, RISCV::FeatureVendorXqcilia,
617+
RISCV::FeatureVendorXqcilo, RISCV::FeatureVendorXqcilsm,
618+
RISCV::FeatureVendorXqcisls,
619+
};
620+
612621
DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
613622
ArrayRef<uint8_t> Bytes,
614623
uint64_t Address,
@@ -696,14 +705,7 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
696705
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVbi, DecoderTableXCVbi32,
697706
"CORE-V Immediate Branching");
698707

699-
FeatureBitset XqciFeaturesWith32BitInsts = {
700-
RISCV::FeatureVendorXqcicsr, RISCV::FeatureVendorXqcisls,
701-
RISCV::FeatureVendorXqcia, RISCV::FeatureVendorXqcics,
702-
RISCV::FeatureVendorXqcilsm, RISCV::FeatureVendorXqciac,
703-
RISCV::FeatureVendorXqcicli, RISCV::FeatureVendorXqcicm,
704-
RISCV::FeatureVendorXqciint
705-
};
706-
TRY_TO_DECODE_FEATURE_ANY(XqciFeaturesWith32BitInsts, DecoderTableXqci32,
708+
TRY_TO_DECODE_FEATURE_ANY(XqciFeatureGroup, DecoderTableXqci32,
707709
"Qualcomm uC Extensions");
708710

709711
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXRivosVizip, DecoderTableXRivos32,
@@ -735,10 +737,7 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
735737
TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZcmp, DecoderTableRVZcmp16,
736738
"Zcmp (16-bit Push/Pop & Double Move Instructions)");
737739

738-
FeatureBitset XqciFeaturesWith16BitInsts = {RISCV::FeatureVendorXqciac,
739-
RISCV::FeatureVendorXqcicm,
740-
RISCV::FeatureVendorXqciint};
741-
TRY_TO_DECODE_FEATURE_ANY(XqciFeaturesWith16BitInsts, DecoderTableXqci16,
740+
TRY_TO_DECODE_FEATURE_ANY(XqciFeatureGroup, DecoderTableXqci16,
742741
"Qualcomm uC 16bit");
743742

744743
TRY_TO_DECODE_AND_ADD_SP(STI.hasFeature(RISCV::FeatureVendorXwchc),
@@ -763,10 +762,7 @@ DecodeStatus RISCVDisassembler::getInstruction48(MCInst &MI, uint64_t &Size,
763762
for (size_t i = Size; i-- != 0;) {
764763
Insn += (static_cast<uint64_t>(Bytes[i]) << 8 * i);
765764
}
766-
767-
FeatureBitset XqciFeaturesWith48BitInsts = {RISCV::FeatureVendorXqcilia,
768-
RISCV::FeatureVendorXqcilo};
769-
TRY_TO_DECODE_FEATURE_ANY(XqciFeaturesWith48BitInsts, DecoderTableXqci48,
765+
TRY_TO_DECODE_FEATURE_ANY(XqciFeatureGroup, DecoderTableXqci48,
770766
"Qualcomm uC 48bit");
771767

772768
return MCDisassembler::Fail;

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ class QCIRVInstEI<bits<3> funct3, bits<2> funct2, string opcodestr>
283283
// Instructions
284284
//===----------------------------------------------------------------------===//
285285

286-
let Predicates = [HasVendorXqcicsr, IsRV32], DecoderNamespace = "Xqci" in {
286+
let DecoderNamespace = "Xqci" in {
287+
288+
let Predicates = [HasVendorXqcicsr, IsRV32] in {
287289
let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in {
288290
def QC_CSRRWR : RVInstR<0b1000110, 0b000, OPC_SYSTEM, (outs GPR:$rd),
289291
(ins GPR:$rs1, GPRNoX0:$rs2), "qc.csrrwr",
@@ -293,9 +295,9 @@ let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in {
293295
(ins uimm5:$rs1, GPRNoX0:$rs2), "qc.csrrwri",
294296
"$rd, $rs1, $rs2">;
295297
} // hasSideEffects = 1, mayLoad = 0, mayStore = 0
296-
} // Predicates = [HasVendorXqcicsr, IsRV32], DecoderNamespace = "Xqci"
298+
} // Predicates = [HasVendorXqcicsr, IsRV32]
297299

298-
let Predicates = [HasVendorXqcisls, IsRV32], DecoderNamespace = "Xqci" in {
300+
let Predicates = [HasVendorXqcisls, IsRV32] in {
299301
def QC_LRB : QCILoad_ScaleIdx<0b1000, "qc.lrb">;
300302
def QC_LRH : QCILoad_ScaleIdx<0b1001, "qc.lrh">;
301303
def QC_LRW : QCILoad_ScaleIdx<0b1010, "qc.lrw">;
@@ -305,9 +307,9 @@ let Predicates = [HasVendorXqcisls, IsRV32], DecoderNamespace = "Xqci" in {
305307
def QC_SRB : QCIStore_ScaleIdx<0b1101, "qc.srb">;
306308
def QC_SRH : QCIStore_ScaleIdx<0b1110, "qc.srh">;
307309
def QC_SRW : QCIStore_ScaleIdx<0b1111, "qc.srw">;
308-
} // Predicates = [HasVendorXqcisls, IsRV32], DecoderNamespace = "Xqci"
310+
} // Predicates = [HasVendorXqcisls, IsRV32]
309311

310-
let Predicates = [HasVendorXqcia, IsRV32], DecoderNamespace = "Xqci" in {
312+
let Predicates = [HasVendorXqcia, IsRV32] in {
311313
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
312314
def QC_SLASAT : QCIRVInstRR<0b01010, GPRNoX0, "qc.slasat">;
313315
def QC_SLLSAT : QCIRVInstRR<0b01100, GPRNoX0, "qc.sllsat">;
@@ -329,9 +331,9 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
329331
def QC_NORMU : QCIRVInstR<0b1000, "qc.normu">;
330332
def QC_NORMEU : QCIRVInstR<0b1001, "qc.normeu">;
331333
} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
332-
} // Predicates = [HasVendorXqcia, IsRV32], DecoderNamespace = "Xqci"
334+
} // Predicates = [HasVendorXqcia, IsRV32]
333335

334-
let Predicates = [HasVendorXqciac, IsRV32], DecoderNamespace = "Xqci" in {
336+
let Predicates = [HasVendorXqciac, IsRV32] in {
335337
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
336338
def QC_C_MULIADD : RVInst16CL<0b001, 0b10, (outs GPRC:$rd_wb),
337339
(ins GPRC:$rd, GPRC:$rs1, uimm5:$uimm),
@@ -360,9 +362,9 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
360362
}
361363

362364
} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
363-
} // Predicates = [HasVendorXqciac, IsRV32], DecoderNamespace = "Xqci"
365+
} // Predicates = [HasVendorXqciac, IsRV32]
364366

365-
let Predicates = [HasVendorXqcics, IsRV32], DecoderNamespace = "Xqci" in {
367+
let Predicates = [HasVendorXqcics, IsRV32] in {
366368
def QC_SELECTIIEQ : QCISELECTIICC <0b010, "qc.selectiieq">;
367369
def QC_SELECTIINE : QCISELECTIICC <0b011, "qc.selectiine">;
368370
def QC_SELECTIEQ : QCISELECTICC <0b010, "qc.selectieq">;
@@ -371,19 +373,19 @@ let Predicates = [HasVendorXqcics, IsRV32], DecoderNamespace = "Xqci" in {
371373
def QC_SELECTNEI : QCISELECTCCI <0b011, "qc.selectnei">;
372374
def QC_SELECTIEQI : QCISELECTICCI <0b010, "qc.selectieqi">;
373375
def QC_SELECTINEI : QCISELECTICCI <0b011, "qc.selectinei">;
374-
} // Predicates = [HasVendorXqcics, IsRV32], DecoderNamespace = "Xqci"
376+
} // Predicates = [HasVendorXqcics, IsRV32]
375377

376-
let Predicates = [HasVendorXqcilsm, IsRV32], DecoderNamespace = "Xqci" in {
378+
let Predicates = [HasVendorXqcilsm, IsRV32] in {
377379
def QC_SWM : QCIStoreMultiple<0b00, GPRNoX0, "qc.swm">;
378380
def QC_SWMI : QCIStoreMultiple<0b01, uimm5nonzero, "qc.swmi">;
379381
def QC_SETWM : QCIStoreMultiple<0b10, GPRNoX0, "qc.setwm">;
380382
def QC_SETWMI : QCIStoreMultiple<0b11, uimm5nonzero, "qc.setwmi">;
381383

382384
def QC_LWM : QCILoadMultiple<0b00, GPRNoX0, "qc.lwm">;
383385
def QC_LWMI : QCILoadMultiple<0b01, uimm5nonzero, "qc.lwmi">;
384-
} // Predicates = [HasVendorXqcilsm, IsRV32], DecoderNamespace = "Xqci"
386+
} // Predicates = [HasVendorXqcilsm, IsRV32]
385387

386-
let Predicates = [HasVendorXqcicli, IsRV32], DecoderNamespace = "Xqci" in {
388+
let Predicates = [HasVendorXqcicli, IsRV32] in {
387389
def QC_LIEQ : QCILICC<0b000, 0b01, GPRNoX0, "qc.lieq">;
388390
def QC_LINE : QCILICC<0b001, 0b01, GPRNoX0, "qc.line">;
389391
def QC_LILT : QCILICC<0b100, 0b01, GPRNoX0, "qc.lilt">;
@@ -397,9 +399,9 @@ let Predicates = [HasVendorXqcicli, IsRV32], DecoderNamespace = "Xqci" in {
397399
def QC_LIGEI : QCILICC<0b101, 0b11, simm5, "qc.ligei">;
398400
def QC_LILTUI : QCILICC<0b110, 0b11, uimm5, "qc.liltui">;
399401
def QC_LIGEUI : QCILICC<0b111, 0b11, uimm5, "qc.ligeui">;
400-
} // Predicates = [HasVendorXqcicli, IsRV32], DecoderNamespace = "Xqci"
402+
} // Predicates = [HasVendorXqcicli, IsRV32]
401403

402-
let Predicates = [HasVendorXqcicm, IsRV32], DecoderNamespace = "Xqci" in {
404+
let Predicates = [HasVendorXqcicm, IsRV32] in {
403405
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
404406
def QC_C_MVEQZ : RVInst16CL<0b101, 0b10, (outs GPRC:$rd_wb),
405407
(ins GPRC:$rd, GPRC:$rs1),
@@ -423,9 +425,9 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
423425
def QC_MVGEI : QCIMVCCI<0b101, "qc.mvgei", simm5>;
424426
def QC_MVLTUI : QCIMVCCI<0b110, "qc.mvltui", uimm5>;
425427
def QC_MVGEUI : QCIMVCCI<0b111, "qc.mvgeui", uimm5>;
426-
} // Predicates = [HasVendorXqcicm, IsRV32], DecoderNamespace = "Xqci"
428+
} // Predicates = [HasVendorXqcicm, IsRV32]
427429

428-
let Predicates = [HasVendorXqciint, IsRV32], DecoderNamespace = "Xqci" in {
430+
let Predicates = [HasVendorXqciint, IsRV32] in {
429431
let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in
430432
def QC_C_DIR : RVInst16CI<0b000, 0b10, (outs GPRNoX0:$rd), (ins),
431433
"qc.c.dir", "$rd"> {
@@ -455,9 +457,9 @@ let Predicates = [HasVendorXqciint, IsRV32], DecoderNamespace = "Xqci" in {
455457

456458
let mayLoad = 1, mayStore = 1, isReturn = 1, isTerminator = 1 in
457459
def QC_C_MILEAVERET : QCIRVInst16CI_NONE<0b10100, "qc.c.mileaveret">;
458-
} // Predicates = [HasVendorXqciint, IsRV32], DecoderNamespace = "Xqci"
460+
} // Predicates = [HasVendorXqciint, IsRV32]
459461

460-
let Predicates = [HasVendorXqcilo, IsRV32], DecoderNamespace = "Xqci" in {
462+
let Predicates = [HasVendorXqcilo, IsRV32] in {
461463
def QC_E_LB : QCIRVInstEILoad<0b101, 0b00, "qc.e.lb">;
462464
def QC_E_LBU : QCIRVInstEILoad<0b101, 0b01, "qc.e.lbu">;
463465
def QC_E_LH : QCIRVInstEILoad<0b101, 0b10, "qc.e.lh">;
@@ -467,9 +469,9 @@ let Predicates = [HasVendorXqcilo, IsRV32], DecoderNamespace = "Xqci" in {
467469
def QC_E_SB : QCIRVInstESStore<0b110, 0b01, "qc.e.sb">;
468470
def QC_E_SH : QCIRVInstESStore<0b110, 0b10, "qc.e.sh">;
469471
def QC_E_SW : QCIRVInstESStore<0b110, 0b11, "qc.e.sw">;
470-
} // Predicates = [HasVendorXqcilo, IsRV32], DecoderNamespace = "Xqci"
472+
} // Predicates = [HasVendorXqcilo, IsRV32]
471473

472-
let Predicates = [HasVendorXqcilia, IsRV32], DecoderNamespace = "Xqci" in {
474+
let Predicates = [HasVendorXqcilia, IsRV32] in {
473475
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
474476
def QC_E_XORAI : QCIRVInstEAI<0b001, 0b0, "qc.e.xorai">;
475477
def QC_E_ORAI : QCIRVInstEAI<0b001, 0b1, "qc.e.orai" >;
@@ -481,7 +483,9 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
481483
def QC_E_ADDI : QCIRVInstEI<0b011, 0b10, "qc.e.addi">;
482484
def QC_E_ANDI : QCIRVInstEI<0b011, 0b11, "qc.e.andi">;
483485
} // hasSideEffects = 0, mayLoad = 0, mayStore = 0
484-
} // Predicates = [HasVendorXqcilia, IsRV32], DecoderNamespace = "Xqci"
486+
} // Predicates = [HasVendorXqcilia, IsRV32]
487+
488+
} // DecoderNamespace = "Xqci"
485489

486490
//===----------------------------------------------------------------------===//
487491
// Aliases

0 commit comments

Comments
 (0)