Skip to content

Commit 8bd65e5

Browse files
committed
Revert "[TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen."
This reverts commit cf7a830.
1 parent cc845e9 commit 8bd65e5

19 files changed

+245
-409
lines changed

clang/lib/Basic/Targets/RISCV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include "clang/Basic/MacroBuilder.h"
1616
#include "clang/Basic/TargetBuiltins.h"
1717
#include "llvm/ADT/StringSwitch.h"
18+
#include "llvm/Support/TargetParser.h"
1819
#include "llvm/Support/raw_ostream.h"
19-
#include "llvm/TargetParser/RISCVTargetParser.h"
2020
#include <optional>
2121

2222
using namespace clang;

clang/lib/Driver/ToolChains/Arch/RISCV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "llvm/Support/Error.h"
1818
#include "llvm/Support/Host.h"
1919
#include "llvm/Support/RISCVISAInfo.h"
20+
#include "llvm/Support/TargetParser.h"
2021
#include "llvm/Support/raw_ostream.h"
21-
#include "llvm/TargetParser/RISCVTargetParser.h"
2222

2323
using namespace clang::driver;
2424
using namespace clang::driver::tools;

llvm/include/llvm/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
add_subdirectory(IR)
22
add_subdirectory(Support)
33
add_subdirectory(Frontend)
4-
add_subdirectory(TargetParser)
54

65
# If we're doing an out-of-tree build, copy a module map for generated
76
# header files into the build area.

llvm/include/llvm/TargetParser/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef PROC
2+
#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)
3+
#endif
4+
5+
PROC(INVALID, {"invalid"}, FK_INVALID, {""})
6+
PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""})
7+
PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""})
8+
PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""})
9+
PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""})
10+
PROC(SIFIVE_E20, {"sifive-e20"}, FK_NONE, {"rv32imc"})
11+
PROC(SIFIVE_E21, {"sifive-e21"}, FK_NONE, {"rv32imac"})
12+
PROC(SIFIVE_E24, {"sifive-e24"}, FK_NONE, {"rv32imafc"})
13+
PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
14+
PROC(SIFIVE_E34, {"sifive-e34"}, FK_NONE, {"rv32imafc"})
15+
PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})
16+
PROC(SIFIVE_S21, {"sifive-s21"}, FK_64BIT, {"rv64imac"})
17+
PROC(SIFIVE_S51, {"sifive-s51"}, FK_64BIT, {"rv64imac"})
18+
PROC(SIFIVE_S54, {"sifive-s54"}, FK_64BIT, {"rv64gc"})
19+
PROC(SIFIVE_S76, {"sifive-s76"}, FK_64BIT, {"rv64gc"})
20+
PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
21+
PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"})
22+
PROC(SYNTACORE_SCR1_BASE, {"syntacore-scr1-base"}, FK_NONE, {"rv32ic"})
23+
PROC(SYNTACORE_SCR1_MAX, {"syntacore-scr1-max"}, FK_NONE, {"rv32imc"})
24+
25+
#undef PROC
26+
27+
#ifndef TUNE_PROC
28+
#define TUNE_PROC(ENUM, NAME)
29+
#endif
30+
31+
TUNE_PROC(GENERIC, "generic")
32+
TUNE_PROC(ROCKET, "rocket")
33+
TUNE_PROC(SIFIVE_7, "sifive-7-series")
34+
35+
#undef TUNE_PROC

llvm/include/llvm/TargetParser/RISCVTargetParser.h

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

llvm/include/llvm/TargetParser/TargetParser.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,34 @@ void fillValidArchListR600(SmallVectorImpl<StringRef> &Values);
154154
IsaVersion getIsaVersion(StringRef GPU);
155155

156156
} // namespace AMDGPU
157+
158+
namespace RISCV {
159+
160+
// We use 64 bits as the known part in the scalable vector types.
161+
static constexpr unsigned RVVBitsPerBlock = 64;
162+
163+
enum CPUKind : unsigned {
164+
#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
165+
#define TUNE_PROC(ENUM, NAME) CK_##ENUM,
166+
#include "RISCVTargetParser.def"
167+
};
168+
169+
enum FeatureKind : unsigned {
170+
FK_INVALID = 0,
171+
FK_NONE = 1,
172+
FK_64BIT = 1 << 2,
173+
};
174+
175+
bool checkCPUKind(CPUKind Kind, bool IsRV64);
176+
bool checkTuneCPUKind(CPUKind Kind, bool IsRV64);
177+
CPUKind parseCPUKind(StringRef CPU);
178+
CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64);
179+
StringRef getMArchFromMcpu(StringRef CPU);
180+
void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
181+
void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
182+
bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector<StringRef> &Features);
183+
184+
} // namespace RISCV
157185
} // namespace llvm
158186

159187
#endif

llvm/include/llvm/module.extern.modulemap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ module LLVM_Extern_IR_Attributes_Gen {}
33
module LLVM_Extern_IR_Intrinsics_Gen {}
44
module LLVM_Extern_IR_Intrinsics_Enum {}
55
module LLVM_Extern_Utils_DataTypes {}
6-
module LLVM_Extern_TargetParser_Gen {}

llvm/include/llvm/module.install.modulemap

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,3 @@ module LLVM_Extern_Utils_DataTypes {
2525
header "Support/DataTypes.h"
2626
export *
2727
}
28-
29-
module LLVM_Extern_TargetParser_Gen {
30-
textual header "TargetParser/RISCVTargetParserDef.inc"
31-
}

llvm/include/llvm/module.modulemap

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,6 @@ module LLVM_Transforms {
391391

392392
extern module LLVM_Extern_Utils_DataTypes "module.extern.modulemap"
393393

394-
// Build the module with the tablegen-generated files needed by the
395-
// TargetParser module before building the TargetParser module itself.
396-
module TargetParserGen {
397-
module RISCVTargetParserDef {
398-
header "TargetParser/RISCVTargetParser.h"
399-
extern module LLVM_Extern_TargetParser_Gen "module.extern.modulemap"
400-
export *
401-
}
402-
}
403-
404394
// A module covering ADT/ and Support/. These are intertwined and
405395
// codependent, and notionally form a single module.
406396
module LLVM_Utils {
@@ -437,6 +427,7 @@ module LLVM_Utils {
437427
textual header "TargetParser/AArch64TargetParser.def"
438428
textual header "TargetParser/ARMTargetParser.def"
439429
textual header "TargetParser/CSKYTargetParser.def"
430+
textual header "TargetParser/RISCVTargetParser.def"
440431
textual header "TargetParser/X86TargetParser.def"
441432
textual header "TargetParser/LoongArchTargetParser.def"
442433
}

0 commit comments

Comments
 (0)