Skip to content

Commit d72f620

Browse files
authored
[RISCV] Merge DecoderNamespace for T-Head extensions. NFC (#130555)
Consistent with what has been done for Rivos, SiFive, and Qualcomm extensions.
1 parent 414e5c5 commit d72f620

File tree

2 files changed

+27
-46
lines changed

2 files changed

+27
-46
lines changed

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

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,14 @@ static constexpr FeatureBitset XSfSystemGroup = {
667667
RISCV::FeatureVendorXSiFivecflushdlone,
668668
};
669669

670+
static constexpr FeatureBitset XTHeadGroup = {
671+
RISCV::FeatureVendorXTHeadBa, RISCV::FeatureVendorXTHeadBb,
672+
RISCV::FeatureVendorXTHeadBs, RISCV::FeatureVendorXTHeadCondMov,
673+
RISCV::FeatureVendorXTHeadCmo, RISCV::FeatureVendorXTHeadFMemIdx,
674+
RISCV::FeatureVendorXTHeadMac, RISCV::FeatureVendorXTHeadMemIdx,
675+
RISCV::FeatureVendorXTHeadMemPair, RISCV::FeatureVendorXTHeadSync,
676+
RISCV::FeatureVendorXTHeadVdot};
677+
670678
DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
671679
ArrayRef<uint8_t> Bytes,
672680
uint64_t Address,
@@ -681,28 +689,8 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
681689

682690
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXVentanaCondOps,
683691
DecoderTableXVentana32, "XVentanaCondOps");
684-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBa, DecoderTableXTHeadBa32,
685-
"XTHeadBa");
686-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBb, DecoderTableXTHeadBb32,
687-
"XTHeadBb");
688-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBs, DecoderTableXTHeadBs32,
689-
"XTHeadBs");
690-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadCondMov,
691-
DecoderTableXTHeadCondMov32, "XTHeadCondMov");
692-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadCmo, DecoderTableXTHeadCmo32,
693-
"XTHeadCmo");
694-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadFMemIdx,
695-
DecoderTableXTHeadFMemIdx32, "XTHeadFMemIdx");
696-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadMac, DecoderTableXTHeadMac32,
697-
"XTHeadMac");
698-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadMemIdx,
699-
DecoderTableXTHeadMemIdx32, "XTHeadMemIdx");
700-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadMemPair,
701-
DecoderTableXTHeadMemPair32, "XTHeadMemPair");
702-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadSync,
703-
DecoderTableXTHeadSync32, "XTHeadSync");
704-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadVdot,
705-
DecoderTableXTHeadVdot32, "XTHeadVdot");
692+
TRY_TO_DECODE_FEATURE_ANY(XTHeadGroup, DecoderTableXTHead32,
693+
"T-Head extensions");
706694
TRY_TO_DECODE_FEATURE_ANY(XSfVectorGroup, DecoderTableXSfvector32,
707695
"SiFive vector extensions");
708696
TRY_TO_DECODE_FEATURE_ANY(XSfSystemGroup, DecoderTableXSfsystem32,

llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ class THInstVdotVV<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
4343
: RVInstVV<funct6, opv, outs, ins, opcodestr, argstr> {
4444
let Inst{26} = 0;
4545
let Inst{6-0} = OPC_CUSTOM_0.Value;
46-
let DecoderNamespace = "XTHeadVdot";
46+
let DecoderNamespace = "XTHead";
4747
}
4848

4949
class THInstVdotVX<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
5050
string opcodestr, string argstr>
5151
: RVInstVX<funct6, opv, outs, ins, opcodestr, argstr> {
5252
let Inst{26} = 1;
5353
let Inst{6-0} = OPC_CUSTOM_0.Value;
54-
let DecoderNamespace = "XTHeadVdot";
54+
let DecoderNamespace = "XTHead";
5555
}
5656

5757
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
@@ -243,11 +243,12 @@ multiclass THVdotVMAQA<string opcodestr, bits<6> funct6>
243243
// Instructions
244244
//===----------------------------------------------------------------------===//
245245

246-
let Predicates = [HasVendorXTHeadBa], DecoderNamespace = "XTHeadBa" in
246+
let DecoderNamespace = "XTHead" in {
247+
let Predicates = [HasVendorXTHeadBa] in
247248
def TH_ADDSL : THShiftALU_rri<0b001, "th.addsl">,
248249
Sched<[WriteSHXADD, ReadSHXADD, ReadSHXADD]>;
249250

250-
let Predicates = [HasVendorXTHeadBb], DecoderNamespace = "XTHeadBb" in {
251+
let Predicates = [HasVendorXTHeadBb] in {
251252
def TH_SRRI : THShift_ri<0b00010, 0b001, "th.srri">;
252253
def TH_EXT : THBitfieldExtract_rii<0b010, "th.ext">;
253254
def TH_EXTU : THBitfieldExtract_rii<0b011, "th.extu">;
@@ -257,24 +258,22 @@ def TH_REV : THRev_r<0b10000, 0b01, "th.rev">;
257258
def TH_TSTNBZ : THRev_r<0b10000, 0b00, "th.tstnbz">;
258259
} // Predicates = [HasVendorXTHeadBb]
259260

260-
let Predicates = [HasVendorXTHeadBb, IsRV64], DecoderNamespace = "XTHeadBb",
261+
let Predicates = [HasVendorXTHeadBb, IsRV64],
261262
IsSignExtendingOpW = 1 in {
262263
def TH_SRRIW : THShiftW_ri<0b0001010, 0b001, "th.srriw">;
263264
def TH_REVW : THRev_r<0b10010, 0b00, "th.revw">;
264265
} // Predicates = [HasVendorXTHeadBb, IsRV64]
265266

266-
let Predicates = [HasVendorXTHeadBs], DecoderNamespace = "XTHeadBs",
267+
let Predicates = [HasVendorXTHeadBs],
267268
IsSignExtendingOpW = 1 in
268269
def TH_TST : THShift_ri<0b10001, 0b001, "th.tst">,
269270
Sched<[WriteSingleBitImm, ReadSingleBitImm]>;
270271

271-
let Predicates = [HasVendorXTHeadCondMov],
272-
DecoderNamespace = "XTHeadCondMov" in {
272+
let Predicates = [HasVendorXTHeadCondMov] in {
273273
def TH_MVEQZ : THCondMov_rr<0b0100000, "th.mveqz">;
274274
def TH_MVNEZ : THCondMov_rr<0b0100001, "th.mvnez">;
275275
} // Predicates = [HasVendorXTHeadCondMov]
276276

277-
let DecoderNamespace = "XTHeadMac" in {
278277
let Predicates = [HasVendorXTHeadMac] in {
279278
def TH_MULA : THMulAccumulate_rr<0b0010000, "th.mula">;
280279
def TH_MULS : THMulAccumulate_rr<0b0010001, "th.muls">;
@@ -289,9 +288,7 @@ let Predicates = [HasVendorXTHeadMac, IsRV64], IsSignExtendingOpW = 1 in {
289288
def TH_MULAW : THMulAccumulate_rr<0b0010010, "th.mulaw">;
290289
def TH_MULSW : THMulAccumulate_rr<0b0010011, "th.mulsw">;
291290
} // Predicates = [HasVendorXTHeadMac, IsRV64]
292-
} // DecoderNamespace = "XTHeadMac"
293291

294-
let DecoderNamespace = "XTHeadMemPair" in {
295292
let Predicates = [HasVendorXTHeadMemPair] in {
296293
def TH_LWUD : THLoadPair<0b11110, "th.lwud">,
297294
Sched<[WriteLDW, WriteLDW, ReadMemBase]>;
@@ -308,9 +305,8 @@ def TH_LDD : THLoadPair<0b11111, "th.ldd">,
308305
def TH_SDD : THStorePair<0b11111, "th.sdd">,
309306
Sched<[WriteSTD, WriteSTD, ReadStoreData, ReadMemBase]>;
310307
}
311-
} // DecoderNamespace = "XTHeadMemPair"
312308

313-
let Predicates = [HasVendorXTHeadMemIdx], DecoderNamespace = "XTHeadMemIdx" in {
309+
let Predicates = [HasVendorXTHeadMemIdx] in {
314310
// T-Head Load/Store + Update instructions.
315311
def TH_LBIA : THLoadUpdate<0b00011, "th.lbia">,
316312
Sched<[WriteLDB, ReadMemBase]>;
@@ -390,7 +386,7 @@ def TH_SURW : THStoreIndexed<GPR, 0b01010, "th.surw">,
390386
Sched<[WriteLDB, ReadMemBase]>;
391387
}
392388

393-
let Predicates = [HasVendorXTHeadMemIdx, IsRV64], DecoderNamespace = "XTHeadMemIdx" in {
389+
let Predicates = [HasVendorXTHeadMemIdx, IsRV64] in {
394390
// T-Head Load/Store + Update instructions.
395391
def TH_LWUIA : THLoadUpdate<0b11011, "th.lwuia">,
396392
Sched<[WriteLDH, ReadMemBase]>;
@@ -426,37 +422,34 @@ def TH_SURD : THStoreIndexed<GPR, 0b01110, "th.surd">,
426422

427423
// T-Head Load/Store Indexed instructions for floating point registers.
428424

429-
let Predicates = [HasVendorXTHeadFMemIdx, HasStdExtF],
430-
DecoderNamespace = "XTHeadFMemIdx" in {
425+
let Predicates = [HasVendorXTHeadFMemIdx, HasStdExtF] in {
431426
def TH_FLRW : THLoadIndexed<FPR32, 0b01000, "th.flrw">,
432427
Sched<[WriteFLD32, ReadFMemBase]>;
433428
def TH_FSRW : THStoreIndexed<FPR32, 0b01000, "th.fsrw">,
434429
Sched<[WriteFST32, ReadFStoreData, ReadFMemBase]>;
435430
}
436431

437-
let Predicates = [HasVendorXTHeadFMemIdx, HasStdExtD],
438-
DecoderNamespace = "XTHeadFMemIdx" in {
432+
let Predicates = [HasVendorXTHeadFMemIdx, HasStdExtD] in {
439433
def TH_FLRD : THLoadIndexed<FPR64, 0b01100, "th.flrd">,
440434
Sched<[WriteFLD64, ReadFMemBase]>;
441435
def TH_FSRD : THStoreIndexed<FPR64, 0b01100, "th.fsrd">,
442436
Sched<[WriteFST64, ReadFStoreData, ReadFMemBase]>;
443437
}
444438

445-
let Predicates = [HasVendorXTHeadFMemIdx, HasStdExtF, IsRV64],
446-
DecoderNamespace = "XTHeadFMemIdx" in {
439+
let Predicates = [HasVendorXTHeadFMemIdx, HasStdExtF, IsRV64] in {
447440
def TH_FLURW : THLoadIndexed<FPR32, 0b01010, "th.flurw">,
448441
Sched<[WriteFLD32, ReadFMemBase]>;
449442
def TH_FSURW : THStoreIndexed<FPR32, 0b01010, "th.fsurw">,
450443
Sched<[WriteFST32, ReadFStoreData, ReadFMemBase]>;
451444
}
452445

453-
let Predicates = [HasVendorXTHeadFMemIdx, HasStdExtD, IsRV64],
454-
DecoderNamespace = "XTHeadFMemIdx" in {
446+
let Predicates = [HasVendorXTHeadFMemIdx, HasStdExtD, IsRV64] in {
455447
def TH_FLURD : THLoadIndexed<FPR64, 0b01110, "th.flurd">,
456448
Sched<[WriteFLD64, ReadFMemBase]>;
457449
def TH_FSURD : THStoreIndexed<FPR64, 0b01110, "th.fsurd">,
458450
Sched<[WriteFST64, ReadFStoreData, ReadFMemBase]>;
459451
}
452+
} // DecoderNamespace = "XTHead"
460453

461454
let Predicates = [HasVendorXTHeadVdot] in {
462455
defm THVdotVMAQA : THVdotVMAQA<"th.vmaqa", 0b100000>;
@@ -692,7 +685,7 @@ let Predicates = [HasVendorXTHeadMemPair] in {
692685
(TH_SWD GPR:$rd1, GPR:$rd2, GPR:$rs1, uimm2_3:$uimm2_3, 3)>;
693686
}
694687

695-
let Predicates = [HasVendorXTHeadCmo], DecoderNamespace = "XTHeadCmo" in {
688+
let Predicates = [HasVendorXTHeadCmo], DecoderNamespace = "XTHead" in {
696689
def TH_DCACHE_CSW : THCacheInst_r<0b00001, "th.dcache.csw">;
697690
def TH_DCACHE_ISW : THCacheInst_r<0b00010, "th.dcache.isw">;
698691
def TH_DCACHE_CISW : THCacheInst_r<0b00011, "th.dcache.cisw">;
@@ -717,7 +710,7 @@ def TH_L2CACHE_IALL : THCacheInst_void<0b10110, "th.l2cache.iall">;
717710
def TH_L2CACHE_CIALL : THCacheInst_void<0b10111, "th.l2cache.ciall">;
718711
}
719712

720-
let Predicates = [HasVendorXTHeadSync], DecoderNamespace = "XTHeadSync" in {
713+
let Predicates = [HasVendorXTHeadSync], DecoderNamespace = "XTHead" in {
721714
def TH_SFENCE_VMAS : THCacheInst_rr<0b0000010, "th.sfence.vmas">;
722715
def TH_SYNC : THCacheInst_void<0b11000, "th.sync">;
723716
def TH_SYNC_S : THCacheInst_void<0b11001, "th.sync.s">;

0 commit comments

Comments
 (0)