Skip to content

Commit 6dc5ba4

Browse files
committed
[RISCV] Remove XSfcie extension.
This reverts 0d3eee3 and 4c37d30. XSfcie is not an official SiFive extension name. It stands for SiFive Custom Instruction Extension, which is mentioned in the S76 manual, but then elsewhere in the manual says it is not supported for S76. LLVM had various instructions and CSRs listed as part of this extension, but as far as SiFive is concerned, none of them are part of it. There are no documented extension names for these instructions and CSRs either externally or internally. If these are important to LLVM users, I can facilitate creating extension names for them and have them documented. For now I'm removing everything. Unfortunately, these instructions and CSRs are in LLVM 17 so this is an incompatible change.
1 parent 76facde commit 6dc5ba4

19 files changed

+23
-338
lines changed

clang/test/Driver/riscv-cpus.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
// MCPU-SIFIVE-S76: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
154154
// MCPU-SIFIVE-S76: "-target-feature" "+c"
155155
// MCPU-SIFIVE-S76: "-target-feature" "+zicsr" "-target-feature" "+zifencei" "-target-feature" "+zihintpause"
156-
// MCPU-SIFIVE-S76: "-target-feature" "+xsfcie"
157156
// MCPU-SIFIVE-S76: "-target-abi" "lp64d"
158157

159158
// mcpu with default march

clang/test/Preprocessor/riscv-target-features.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
// CHECK-NOT: __riscv_xcvmac {{.*$}}
3434
// CHECK-NOT: __riscv_xcvmem {{.*$}}
3535
// CHECK-NOT: __riscv_xcvsimd {{.*$}}
36-
// CHECK-NOT: __riscv_xsfcie {{.*$}}
3736
// CHECK-NOT: __riscv_xsfvcp {{.*$}}
3837
// CHECK-NOT: __riscv_xsfvfnrclipxfqf {{.*$}}
3938
// CHECK-NOT: __riscv_xsfvfwmaccqqq {{.*$}}
@@ -315,14 +314,6 @@
315314
// RUN: -o - | FileCheck --check-prefix=CHECK-XCVSIMD-EXT %s
316315
// CHECK-XCVSIMD-EXT: __riscv_xcvsimd 1000000{{$}}
317316

318-
// RUN: %clang --target=riscv32-unknown-linux-gnu \
319-
// RUN: -march=rv32ixsfcie -x c -E -dM %s \
320-
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFCIE-EXT %s
321-
// RUN: %clang --target=riscv64-unknown-linux-gnu \
322-
// RUN: -march=rv64ixsfcie -x c -E -dM %s \
323-
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFCIE-EXT %s
324-
// CHECK-XSFCIE-EXT: __riscv_xsfcie 1000000{{$}}
325-
326317
// RUN: %clang --target=riscv32-unknown-linux-gnu \
327318
// RUN: -march=rv32ixsfvcp -x c -E -dM %s \
328319
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFVCP-EXT %s

llvm/docs/RISCVUsage.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,6 @@ The current vendor extensions supported are:
300300
``XCVbi``
301301
LLVM implements `version 1.0.0 of the CORE-V immediate branching custom instructions specification <https://github.com/openhwgroup/cv32e40p/blob/cv32e40p_v1.3.2/docs/source/instruction_set_extensions.rst>`_ by OpenHW Group. All instructions are prefixed with `cv.` as described in the specification. These instructions are only available for riscv32 at this time.
302302

303-
``XSfcie``
304-
LLVM implements `version 1.0.0 of the SiFive Custom Instruction Extension (CIE) Software Specification <https://sifive.cdn.prismic.io/sifive/767804da-53b2-4893-97d5-b7c030ae0a94_s76mc_core_complex_manual_21G3.pdf>`_ by SiFive. All custom instruction are added as described in the specification, and the riscv-toolchain-convention document linked above. These instructions are only available for S76 processor at this time.
305-
306303
Experimental C Intrinsics
307304
=========================
308305

llvm/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ Changes to the RISC-V Backend
146146
and is no longer experimental. However, the C intrinsics for these extensions
147147
are still experimental. To use the C intrinsics for these extensions,
148148
``-menable-experimental-extensions`` needs to be passed to Clang.
149+
* XSfcie extension and SiFive CSRs and instructions that were associated with
150+
it have been removed. None of these CSRs and instructions were part of
151+
"SiFive Custom Instruction Extension" as SiFive defines it. The LLVM project
152+
needs to work with SiFive to define and document real extension names for
153+
individual CSRs and instructions.
149154

150155
Changes to the WebAssembly Backend
151156
----------------------------------

llvm/lib/Support/RISCVISAInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ static const RISCVSupportedExtension SupportedExtensions[] = {
7575
{"xcvmac", RISCVExtensionVersion{1, 0}},
7676
{"xcvmem", RISCVExtensionVersion{1, 0}},
7777
{"xcvsimd", RISCVExtensionVersion{1, 0}},
78-
{"xsfcie", RISCVExtensionVersion{1, 0}},
7978
{"xsfvcp", RISCVExtensionVersion{1, 0}},
8079
{"xsfvfnrclipxfqf", RISCVExtensionVersion{1, 0}},
8180
{"xsfvfwmaccqqq", RISCVExtensionVersion{1, 0}},

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

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,57 +1832,18 @@ ParseStatus RISCVAsmParser::parseCSRSystemRegister(OperandVector &Operands) {
18321832
if (getParser().parseIdentifier(Identifier))
18331833
return ParseStatus::Failure;
18341834

1835-
// Check for CSR names conflicts.
1836-
// Custom CSR names might conflict with CSR names in privileged spec.
1837-
// E.g. - SiFive mnscratch(0x350) and privileged spec mnscratch(0x740).
1838-
auto CheckCSRNameConflict = [&]() {
1839-
if (!(RISCVSysReg::lookupSysRegByName(Identifier))) {
1840-
Error(S, "system register use requires an option to be enabled");
1841-
return true;
1842-
}
1843-
return false;
1844-
};
1845-
1846-
// First check for vendor specific CSRs.
1847-
auto SiFiveReg = RISCVSysReg::lookupSiFiveRegByName(Identifier);
1848-
if (SiFiveReg) {
1849-
if (SiFiveReg->haveVendorRequiredFeatures(getSTI().getFeatureBits())) {
1850-
Operands.push_back(
1851-
RISCVOperand::createSysReg(Identifier, S, SiFiveReg->Encoding));
1852-
return ParseStatus::Success;
1853-
}
1854-
if (CheckCSRNameConflict())
1855-
return ParseStatus::Failure;
1856-
}
1857-
18581835
auto SysReg = RISCVSysReg::lookupSysRegByName(Identifier);
1836+
if (!SysReg)
1837+
SysReg = RISCVSysReg::lookupSysRegByAltName(Identifier);
18591838
if (!SysReg)
18601839
if ((SysReg = RISCVSysReg::lookupSysRegByDeprecatedName(Identifier)))
18611840
Warning(S, "'" + Identifier + "' is a deprecated alias for '" +
18621841
SysReg->Name + "'");
18631842

1864-
// Check for CSR encoding conflicts.
1865-
// Custom CSR encoding might conflict with CSR encoding in privileged spec.
1866-
// E.g. - SiFive mnscratch(0x350) and privileged spec miselect(0x350).
1867-
auto CheckCSREncodingConflict = [&]() {
1868-
auto Reg = RISCVSysReg::lookupSiFiveRegByEncoding(SysReg->Encoding);
1869-
if (Reg && Reg->haveVendorRequiredFeatures(getSTI().getFeatureBits())) {
1870-
Warning(S, "'" + Identifier + "' CSR is not available on the current " +
1871-
"subtarget. Instead '" + Reg->Name +
1872-
"' CSR will be used.");
1873-
Operands.push_back(
1874-
RISCVOperand::createSysReg(Reg->Name, S, Reg->Encoding));
1875-
return true;
1876-
}
1877-
return false;
1878-
};
1879-
1880-
// Accept a named SysReg if the required features are present.
1843+
// Accept a named Sys Reg if the required features are present.
18811844
if (SysReg) {
18821845
if (!SysReg->haveRequiredFeatures(getSTI().getFeatureBits()))
18831846
return Error(S, "system register use requires an option to be enabled");
1884-
if (CheckCSREncodingConflict())
1885-
return ParseStatus::Success;
18861847
Operands.push_back(
18871848
RISCVOperand::createSysReg(Identifier, S, SysReg->Encoding));
18881849
return ParseStatus::Success;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,6 @@ DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
566566
TRY_TO_DECODE_FEATURE(
567567
RISCV::FeatureVendorXSfvfnrclipxfqf, DecoderTableXSfvfnrclipxfqf32,
568568
"SiFive FP32-to-int8 Ranged Clip Instructions opcode table");
569-
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXSfcie, DecoderTableXSfcie32,
570-
"Sifive CIE custom opcode table");
571569
TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVbitmanip,
572570
DecoderTableXCVbitmanip32,
573571
"CORE-V Bit Manipulation custom opcode table");

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ extern const SubtargetFeatureKV RISCVFeatureKV[RISCV::NumSubtargetFeatures];
2727

2828
namespace RISCVSysReg {
2929
#define GET_SysRegsList_IMPL
30-
#define GET_SiFiveRegsList_IMPL
3130
#include "RISCVGenSearchableTables.inc"
3231
} // namespace RISCVSysReg
3332

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ int getLoadFPImm(APFloat FPImm);
401401
namespace RISCVSysReg {
402402
struct SysReg {
403403
const char *Name;
404+
const char *AltName;
404405
const char *DeprecatedName;
405406
unsigned Encoding;
406407
// FIXME: add these additional fields when needed.
@@ -424,22 +425,9 @@ struct SysReg {
424425
return true;
425426
return (FeaturesRequired & ActiveFeatures) == FeaturesRequired;
426427
}
427-
428-
bool haveVendorRequiredFeatures(const FeatureBitset &ActiveFeatures) const {
429-
// Not in 32-bit mode.
430-
if (isRV32Only && ActiveFeatures[RISCV::Feature64Bit])
431-
return false;
432-
// No required feature associated with the system register.
433-
if (FeaturesRequired.none())
434-
return false;
435-
return (FeaturesRequired & ActiveFeatures) == FeaturesRequired;
436-
}
437428
};
438429

439-
struct SiFiveReg : SysReg {};
440-
441430
#define GET_SysRegsList_DECL
442-
#define GET_SiFiveRegsList_DECL
443431
#include "RISCVGenSearchableTables.inc"
444432
} // end namespace RISCVSysReg
445433

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,8 @@ void RISCVInstPrinter::printCSRSystemRegister(const MCInst *MI, unsigned OpNo,
121121
const MCSubtargetInfo &STI,
122122
raw_ostream &O) {
123123
unsigned Imm = MI->getOperand(OpNo).getImm();
124-
auto SiFiveReg = RISCVSysReg::lookupSiFiveRegByEncoding(Imm);
125124
auto SysReg = RISCVSysReg::lookupSysRegByEncoding(Imm);
126-
if (SiFiveReg && SiFiveReg->haveVendorRequiredFeatures(STI.getFeatureBits()))
127-
markup(O, Markup::Register) << SiFiveReg->Name;
128-
else if (SysReg && SysReg->haveRequiredFeatures(STI.getFeatureBits()))
125+
if (SysReg && SysReg->haveRequiredFeatures(STI.getFeatureBits()))
129126
markup(O, Markup::Register) << SysReg->Name;
130127
else
131128
markup(O, Markup::Register) << formatImm(Imm);

0 commit comments

Comments
 (0)