Skip to content

Commit b0c3132

Browse files
committed
Revert "[RISCV] Add vendor-defined XTheadBb (basic bit-manipulation) extension"
This reverts commit 19a5909.
1 parent 9488816 commit b0c3132

File tree

16 files changed

+9
-3452
lines changed

16 files changed

+9
-3452
lines changed

clang/include/clang/Basic/BuiltinsRISCV.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
// Zbb extension
1919
TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
2020
TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
21-
TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb|xtheadbb")
22-
TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb|xtheadbb,64bit")
21+
TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb")
22+
TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb,64bit")
2323
TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb")
2424
TARGET_BUILTIN(__builtin_riscv_ctz_64, "WiWi", "nc", "zbb,64bit")
2525

clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-xtheadbb.c

Lines changed: 0 additions & 28 deletions
This file was deleted.

clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-xtheadbb.c

Lines changed: 0 additions & 53 deletions
This file was deleted.

llvm/docs/RISCVUsage.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ The current vendor extensions supported are:
172172
``XTHeadBa``
173173
LLVM implements `the THeadBa (address-generation) vendor-defined instructions specified in <https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.2.2/xthead-2023-01-30-2.2.2.pdf>`_ by T-HEAD of Alibaba. Instructions are prefixed with `th.` as described in the specification.
174174

175-
``XTHeadBb``
176-
LLVM implements `the THeadBb (basic bit-manipulation) vendor-defined instructions specified in <https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.2.2/xthead-2023-01-30-2.2.2.pdf>`_ by T-HEAD of Alibaba. Instructions are prefixed with `th.` as described in the specification.
177-
178175
``XTHeadBs``
179176
LLVM implements `the THeadBs (single-bit operations) vendor-defined instructions specified in <https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.2.2/xthead-2023-01-30-2.2.2.pdf>`_ by T-HEAD of Alibaba. Instructions are prefixed with `th.` as described in the specification.
180177

llvm/lib/Support/RISCVISAInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ static const RISCVSupportedExtension SupportedExtensions[] = {
110110

111111
// vendor-defined ('X') extensions
112112
{"xtheadba", RISCVExtensionVersion{1, 0}},
113-
{"xtheadbb", RISCVExtensionVersion{1, 0}},
114113
{"xtheadbs", RISCVExtensionVersion{1, 0}},
115114
{"xtheadvdot", RISCVExtensionVersion{1, 0}},
116115
{"xventanacondops", RISCVExtensionVersion{1, 0}},

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,6 @@ DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
478478
if (Result != MCDisassembler::Fail)
479479
return Result;
480480
}
481-
if (STI.getFeatureBits()[RISCV::FeatureVendorXTHeadBb]) {
482-
LLVM_DEBUG(dbgs() << "Trying XTHeadBb custom opcode table:\n");
483-
Result = decodeInstruction(DecoderTableTHeadBb32, MI, Insn, Address, this,
484-
STI);
485-
if (Result != MCDisassembler::Fail)
486-
return Result;
487-
}
488481
if (STI.getFeatureBits()[RISCV::FeatureVendorXTHeadBs]) {
489482
LLVM_DEBUG(dbgs() << "Trying XTHeadBs custom opcode table:\n");
490483
Result = decodeInstruction(DecoderTableTHeadBs32, MI, Insn, Address, this,

llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,20 +352,15 @@ InstSeq generateInstSeq(int64_t Val, const FeatureBitset &ActiveFeatures) {
352352
}
353353
}
354354

355-
// Perform optimization with rori in the Zbb and th.srri in the XTheadBb
356-
// extension.
357-
if (Res.size() > 2 && (ActiveFeatures[RISCV::FeatureStdExtZbb] ||
358-
ActiveFeatures[RISCV::FeatureVendorXTHeadBb])) {
355+
// Perform optimization with rori in the Zbb extension.
356+
if (Res.size() > 2 && ActiveFeatures[RISCV::FeatureStdExtZbb]) {
359357
if (unsigned Rotate = extractRotateInfo(Val)) {
360358
RISCVMatInt::InstSeq TmpSeq;
361359
uint64_t NegImm12 =
362360
((uint64_t)Val >> (64 - Rotate)) | ((uint64_t)Val << Rotate);
363361
assert(isInt<12>(NegImm12));
364362
TmpSeq.emplace_back(RISCV::ADDI, NegImm12);
365-
TmpSeq.emplace_back(ActiveFeatures[RISCV::FeatureStdExtZbb]
366-
? RISCV::RORI
367-
: RISCV::TH_SRRI,
368-
Rotate);
363+
TmpSeq.emplace_back(RISCV::RORI, Rotate);
369364
Res = TmpSeq;
370365
}
371366
}
@@ -410,7 +405,6 @@ OpndKind Inst::getOpndKind() const {
410405
case RISCV::RORI:
411406
case RISCV::BSETI:
412407
case RISCV::BCLRI:
413-
case RISCV::TH_SRRI:
414408
return RISCVMatInt::RegImm;
415409
}
416410
}

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,6 @@ def HasVendorXTHeadBa : Predicate<"Subtarget->hasVendorXTHeadBa()">,
470470
AssemblerPredicate<(all_of FeatureVendorXTHeadBa),
471471
"'xtheadba' (T-Head address calculation instructions)">;
472472

473-
def FeatureVendorXTHeadBb
474-
: SubtargetFeature<"xtheadbb", "HasVendorXTHeadBb", "true",
475-
"'xtheadbb' (T-Head basic bit-manipulation instructions)">;
476-
def HasVendorXTHeadBb : Predicate<"Subtarget->hasVendorXTHeadBb()">,
477-
AssemblerPredicate<(all_of FeatureVendorXTHeadBb),
478-
"'xtheadbb' (T-Head basic bit-manipulation instructions)">;
479-
480473
def FeatureVendorXTHeadBs
481474
: SubtargetFeature<"xtheadbs", "HasVendorXTHeadBs", "true",
482475
"'xtheadbs' (T-Head single-bit instructions)">;

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,15 +1115,11 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
11151115
bool IsANDIOrZExt =
11161116
isInt<12>(C2) ||
11171117
(C2 == UINT64_C(0xFFFF) && Subtarget->hasStdExtZbb());
1118-
// With XTHeadBb, we can use TH.EXTU.
1119-
IsANDIOrZExt |= C2 == UINT64_C(0xFFFF) && Subtarget->hasVendorXTHeadBb();
11201118
if (IsANDIOrZExt && (isInt<12>(N1C->getSExtValue()) || !N0.hasOneUse()))
11211119
break;
11221120
// If this can be a ZEXT.w, don't do this if the ZEXT has multiple users or
11231121
// the constant is a simm32.
11241122
bool IsZExtW = C2 == UINT64_C(0xFFFFFFFF) && Subtarget->hasStdExtZba();
1125-
// With XTHeadBb, we can use TH.EXTU.
1126-
IsZExtW |= C2 == UINT64_C(0xFFFFFFFF) && Subtarget->hasVendorXTHeadBb();
11271123
if (IsZExtW && (isInt<32>(N1C->getSExtValue()) || !N0.hasOneUse()))
11281124
break;
11291125

@@ -2401,8 +2397,6 @@ bool RISCVDAGToDAGISel::hasAllNBitUsers(SDNode *Node, unsigned Bits,
24012397
case RISCV::FCVT_S_WU:
24022398
case RISCV::FCVT_D_W:
24032399
case RISCV::FCVT_D_WU:
2404-
case RISCV::TH_REVW:
2405-
case RISCV::TH_SRRIW:
24062400
if (Bits < 32)
24072401
return false;
24082402
break;

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
233233

234234
setOperationAction(ISD::EH_DWARF_CFA, MVT::i32, Custom);
235235

236-
if (!Subtarget.hasStdExtZbb() && !Subtarget.hasVendorXTHeadBb())
236+
if (!Subtarget.hasStdExtZbb())
237237
setOperationAction(ISD::SIGN_EXTEND_INREG, {MVT::i8, MVT::i16}, Expand);
238238

239239
if (Subtarget.is64Bit()) {
@@ -280,8 +280,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
280280
setOperationAction({ISD::SHL_PARTS, ISD::SRL_PARTS, ISD::SRA_PARTS}, XLenVT,
281281
Custom);
282282

283-
if (Subtarget.hasStdExtZbb() || Subtarget.hasStdExtZbkb() ||
284-
Subtarget.hasVendorXTHeadBb()) {
283+
if (Subtarget.hasStdExtZbb() || Subtarget.hasStdExtZbkb()) {
285284
if (Subtarget.is64Bit())
286285
setOperationAction({ISD::ROTL, ISD::ROTR}, MVT::i32, Custom);
287286
} else {
@@ -291,8 +290,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
291290
// With Zbb we have an XLen rev8 instruction, but not GREVI. So we'll
292291
// pattern match it directly in isel.
293292
setOperationAction(ISD::BSWAP, XLenVT,
294-
(Subtarget.hasStdExtZbb() || Subtarget.hasStdExtZbkb() ||
295-
Subtarget.hasVendorXTHeadBb())
293+
(Subtarget.hasStdExtZbb() || Subtarget.hasStdExtZbkb())
296294
? Legal
297295
: Expand);
298296
// Zbkb can use rev8+brev8 to implement bitreverse.
@@ -311,15 +309,6 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
311309
setOperationAction({ISD::CTTZ, ISD::CTLZ, ISD::CTPOP}, XLenVT, Expand);
312310
}
313311

314-
if (Subtarget.hasVendorXTHeadBb()) {
315-
setOperationAction({ISD::CTLZ}, XLenVT, Legal);
316-
317-
// We need the custom lowering to make sure that the resulting sequence
318-
// for the 32bit case is efficient on 64bit targets.
319-
if (Subtarget.is64Bit())
320-
setOperationAction({ISD::CTLZ, ISD::CTLZ_ZERO_UNDEF}, MVT::i32, Custom);
321-
}
322-
323312
if (Subtarget.is64Bit())
324313
setOperationAction(ISD::ABS, MVT::i32, Custom);
325314

@@ -1223,7 +1212,7 @@ bool RISCVTargetLowering::isCheapToSpeculateCttz(Type *Ty) const {
12231212
}
12241213

12251214
bool RISCVTargetLowering::isCheapToSpeculateCtlz(Type *Ty) const {
1226-
return Subtarget.hasStdExtZbb() || Subtarget.hasVendorXTHeadBb();
1215+
return Subtarget.hasStdExtZbb();
12271216
}
12281217

12291218
bool RISCVTargetLowering::isMaskAndCmp0FoldingBeneficial(

llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -54,38 +54,6 @@ class THShiftALU_rri<bits<3> funct3, string opcodestr>
5454
let Inst{26-25} = uimm2;
5555
}
5656

57-
let Predicates = [HasVendorXTHeadBb], DecoderNamespace = "THeadBb",
58-
hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
59-
class THShift_ri<bits<5> funct5, bits<3> funct3, string opcodestr>
60-
: RVInstIShift<funct5, funct3, OPC_CUSTOM_0, (outs GPR:$rd),
61-
(ins GPR:$rs1, uimmlog2xlen:$shamt),
62-
opcodestr, "$rd, $rs1, $shamt">;
63-
64-
class THBitfieldExtract_rii<bits<3> funct3, string opcodestr>
65-
: RVInstI<funct3, OPC_CUSTOM_0, (outs GPR:$rd),
66-
(ins GPR:$rs1, uimmlog2xlen:$msb, uimmlog2xlen:$lsb),
67-
opcodestr, "$rd, $rs1, $msb, $lsb"> {
68-
bits<6> msb;
69-
bits<6> lsb;
70-
let Inst{31-26} = msb;
71-
let Inst{25-20} = lsb;
72-
}
73-
74-
class THRev_r<bits<5> funct5, bits<2> funct2, string opcodestr>
75-
: RVInstR4<funct2, 0b001, OPC_CUSTOM_0, (outs GPR:$rd), (ins GPR:$rs1),
76-
opcodestr, "$rd, $rs1"> {
77-
let rs3 = funct5;
78-
let rs2 = 0;
79-
}
80-
}
81-
82-
let Predicates = [HasVendorXTHeadBb, IsRV64], DecoderNamespace = "THeadBb",
83-
hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
84-
class THShiftW_ri<bits<7> funct7, bits<3> funct3, string opcodestr>
85-
: RVInstIShiftW<funct7, funct3, OPC_CUSTOM_0, (outs GPR:$rd),
86-
(ins GPR:$rs1, uimm5:$shamt),
87-
opcodestr, "$rd, $rs1, $shamt">;
88-
8957
//===----------------------------------------------------------------------===//
9058
// Combination of instruction classes.
9159
// Use these multiclasses to define instructions more easily.
@@ -107,21 +75,6 @@ def TH_ADDSL : THShiftALU_rri<0b001, "th.addsl">,
10775
Sched<[WriteSHXADD, ReadSHXADD, ReadSHXADD]>;
10876
} // Predicates = [HasVendorXTHeadBa]
10977

110-
let Predicates = [HasVendorXTHeadBb] in {
111-
def TH_SRRI : THShift_ri<0b00010, 0b001, "th.srri">;
112-
def TH_EXT : THBitfieldExtract_rii<0b010, "th.ext">;
113-
def TH_EXTU : THBitfieldExtract_rii<0b011, "th.extu">;
114-
def TH_FF0 : THRev_r<0b10000, 0b10, "th.ff0">;
115-
def TH_FF1 : THRev_r<0b10000, 0b11, "th.ff1">;
116-
def TH_REV : THRev_r<0b10000, 0b01, "th.rev">;
117-
def TH_TSTNBZ : THRev_r<0b10000, 0b00, "th.tstnbz">;
118-
} // Predicates = [HasVendorXTHeadBb]
119-
120-
let Predicates = [HasVendorXTHeadBb, IsRV64], IsSignExtendingOpW = 1 in {
121-
def TH_SRRIW : THShiftW_ri<0b0001010, 0b001, "th.srriw">;
122-
def TH_REVW : THRev_r<0b10010, 0b00, "th.revw">;
123-
} // Predicates = [HasVendorXTHeadBb, IsRV64]
124-
12578
let Predicates = [HasVendorXTHeadBs], DecoderNamespace = "THeadBs" in {
12679
let IsSignExtendingOpW = 1 in
12780
def TH_TST : RVBShift_ri<0b10001, 0b001, OPC_CUSTOM_0, "th.tst">,
@@ -216,49 +169,6 @@ def : Pat<(add sh3add_op:$rs1, non_imm12:$rs2),
216169
(TH_ADDSL GPR:$rs2, sh3add_op:$rs1, 3)>;
217170
} // Predicates = [HasVendorXTHeadBa]
218171

219-
let Predicates = [HasVendorXTHeadBb] in {
220-
def : PatGprImm<rotr, TH_SRRI, uimmlog2xlen>;
221-
// There's no encoding for a rotate-left-immediate in X-THead-Bb, as
222-
// it can be implemented with th.srri by negating the immediate.
223-
def : Pat<(rotl GPR:$rs1, uimmlog2xlen:$shamt),
224-
(TH_SRRI GPR:$rs1, (ImmSubFromXLen uimmlog2xlen:$shamt))>;
225-
def : Pat<(rotr GPR:$rs1, GPR:$rs2),
226-
(OR (SRL GPR:$rs1, GPR:$rs2),
227-
(SLL GPR:$rs1, (SUB X0, GPR:$rs2)))>;
228-
def : Pat<(rotl GPR:$rs1, GPR:$rs2),
229-
(OR (SLL GPR:$rs1, GPR:$rs2),
230-
(SRL GPR:$rs1, (SUB X0, GPR:$rs2)))>;
231-
//def : Pat<(and GPR:$rs1, 1), (TH_EXTU GPR:$rs1, 0, 0)>;
232-
//def : Pat<(and GPR:$rs1, 0xff), (TH_EXTU GPR:$rs1, 7, 0)>;
233-
def : Pat<(and GPR:$rs1, 0xffff), (TH_EXTU GPR:$rs1, 15, 0)>;
234-
def : Pat<(and GPR:$rs1, 0xffffffff), (TH_EXTU GPR:$rs1, 31, 0)>;
235-
def : Pat<(sext_inreg GPR:$rs1, i32), (TH_EXT GPR:$rs1, 31, 0)>;
236-
def : Pat<(sext_inreg GPR:$rs1, i16), (TH_EXT GPR:$rs1, 15, 0)>;
237-
def : Pat<(sext_inreg GPR:$rs1, i8), (TH_EXT GPR:$rs1, 7, 0)>;
238-
def : Pat<(sext_inreg GPR:$rs1, i1), (TH_EXT GPR:$rs1, 0, 0)>;
239-
def : PatGpr<ctlz, TH_FF1>;
240-
def : Pat<(ctlz (xor GPR:$rs1, -1)), (TH_FF0 GPR:$rs1)>;
241-
def : PatGpr<bswap, TH_REV>;
242-
} // Predicates = [HasVendorXTHeadBb]
243-
244-
let Predicates = [HasVendorXTHeadBb, IsRV64] in {
245-
def : PatGprImm<riscv_rorw, TH_SRRIW, uimm5>;
246-
def : Pat<(riscv_rolw GPR:$rs1, uimm5:$rs2),
247-
(TH_SRRIW GPR:$rs1, (ImmSubFrom32 uimm5:$rs2))>;
248-
def : Pat<(riscv_rorw i64:$rs1, i64:$rs2),
249-
(OR (SRLW i64:$rs1, i64:$rs2),
250-
(SLLW i64:$rs1, (SUB X0, i64:$rs2)))>;
251-
def : Pat<(riscv_rolw i64:$rs1, i64:$rs2),
252-
(OR (SLLW i64:$rs1, i64:$rs2),
253-
(SRLW i64:$rs1, (SUB X0, i64:$rs2)))>;
254-
def : Pat<(sra (bswap i64:$rs1), (i64 32)),
255-
(TH_REVW i64:$rs1)>;
256-
def : Pat<(binop_allwusers<srl> (bswap i64:$rs1), (i64 32)),
257-
(TH_REVW i64:$rs1)>;
258-
def : Pat<(riscv_clzw i64:$rs1),
259-
(TH_FF0 (SLLI (XORI i64:$rs1, -1), 32))>;
260-
} // Predicates = [HasVendorXTHeadBb, IsRV64]
261-
262172
let Predicates = [HasVendorXTHeadBs] in {
263173
def : Pat<(and (srl GPR:$rs1, uimmlog2xlen:$shamt), 1),
264174
(TH_TST GPR:$rs1, uimmlog2xlen:$shamt)>;

0 commit comments

Comments
 (0)