Skip to content

Commit 42b7aa6

Browse files
committed
[𝘀𝗽𝗿] changes to main this commit is based on
Created using spr 1.3.6-beta.1 [skip ci]
1 parent 9685681 commit 42b7aa6

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

llvm/lib/Target/RISCV/RISCVProcessors.td

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class RISCVProcessorModel<string n,
4949
string default_march = "">
5050
: ProcessorModel<n, m, f, tunef> {
5151
string DefaultMarch = default_march;
52+
int MVendorID = 0;
53+
int MArchID = 0;
54+
int MImpID = 0;
5255
}
5356

5457
class RISCVTuneProcessorModel<string n,
@@ -435,7 +438,11 @@ def VENTANA_VEYRON_V1 : RISCVProcessorModel<"veyron-v1",
435438
TuneZExtHFusion,
436439
TuneZExtWFusion,
437440
TuneShiftedZExtWFusion,
438-
TuneLDADDFusion]>;
441+
TuneLDADDFusion]> {
442+
let MVendorID = 0x61f;
443+
let MArchID = 0x8000000000010000;
444+
let MImpID = 0x111;
445+
}
439446

440447
def XIANGSHAN_NANHU : RISCVProcessorModel<"xiangshan-nanhu",
441448
XiangShanNanHuModel,

llvm/lib/TargetParser/RISCVTargetParser.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace RISCV {
2222

2323
enum CPUKind : unsigned {
2424
#define PROC(ENUM, NAME, DEFAULT_MARCH, FAST_SCALAR_UNALIGN, \
25-
FAST_VECTOR_UNALIGN) \
25+
FAST_VECTOR_UNALIGN, MVENDORID, MARCHID, MIMPID) \
2626
CK_##ENUM,
2727
#define TUNE_PROC(ENUM, NAME) CK_##ENUM,
2828
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
@@ -33,13 +33,24 @@ struct CPUInfo {
3333
StringLiteral DefaultMarch;
3434
bool FastScalarUnalignedAccess;
3535
bool FastVectorUnalignedAccess;
36+
uint32_t MVendorID;
37+
uint64_t MArchID;
38+
uint64_t MImpID;
3639
bool is64Bit() const { return DefaultMarch.starts_with("rv64"); }
3740
};
3841

3942
constexpr CPUInfo RISCVCPUInfo[] = {
4043
#define PROC(ENUM, NAME, DEFAULT_MARCH, FAST_SCALAR_UNALIGN, \
41-
FAST_VECTOR_UNALIGN) \
42-
{NAME, DEFAULT_MARCH, FAST_SCALAR_UNALIGN, FAST_VECTOR_UNALIGN},
44+
FAST_VECTOR_UNALIGN, MVENDORID, MARCHID, MIMPID) \
45+
{ \
46+
NAME, \
47+
DEFAULT_MARCH, \
48+
FAST_SCALAR_UNALIGN, \
49+
FAST_VECTOR_UNALIGN, \
50+
MVENDORID, \
51+
MARCHID, \
52+
MIMPID, \
53+
},
4354
#include "llvm/TargetParser/RISCVTargetParserDef.inc"
4455
};
4556

llvm/test/TableGen/riscv-target-def.td

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ class RISCVProcessorModel<string n,
8181
string default_march = "">
8282
: ProcessorModel<n, m, f, tunef> {
8383
string DefaultMarch = default_march;
84+
int MVendorID = 0;
85+
int MArchID = 0;
86+
int MImpID = 0;
8487
}
8588

8689
class RISCVTuneProcessorModel<string n,
@@ -160,13 +163,13 @@ def ROCKET : RISCVTuneProcessorModel<"rocket",
160163
// CHECK: #endif // GET_SUPPORTED_PROFILES
161164

162165
// CHECK: #ifndef PROC
163-
// CHECK-NEXT: #define PROC(ENUM, NAME, DEFAULT_MARCH, FAST_SCALAR_UNALIGN, FAST_VECTOR_UNALIGN)
166+
// CHECK-NEXT: #define PROC(ENUM, NAME, DEFAULT_MARCH, FAST_SCALAR_UNALIGN, FAST_VECTOR_UNALIGN, MVENDORID, MARCHID, MIMPID)
164167
// CHECK-NEXT: #endif
165168

166-
// CHECK: PROC(GENERIC_RV32, {"generic-rv32"}, {"rv32i2p1"}, 0, 0)
167-
// CHECK-NEXT: PROC(GENERIC_RV64, {"generic-rv64"}, {"rv64i2p1"}, 0, 0)
168-
// CHECK-NEXT: PROC(ROCKET_RV32, {"rocket-rv32"}, {"rv32i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0, 0)
169-
// CHECK-NEXT: PROC(ROCKET_RV64, {"rocket-rv64"}, {"rv64i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0, 0)
169+
// CHECK: PROC(GENERIC_RV32, {"generic-rv32"}, {"rv32i2p1"}, 0, 0, 0x00000000, 0x00000000, 0x00000000)
170+
// CHECK-NEXT: PROC(GENERIC_RV64, {"generic-rv64"}, {"rv64i2p1"}, 0, 0, 0x00000000, 0x0000000000000000, 0x0000000000000000)
171+
// CHECK-NEXT: PROC(ROCKET_RV32, {"rocket-rv32"}, {"rv32i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0, 0, 0x00000000, 0x00000000, 0x00000000)
172+
// CHECK-NEXT: PROC(ROCKET_RV64, {"rocket-rv64"}, {"rv64i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0, 0, 0x00000000, 0x0000000000000000, 0x0000000000000000)
170173

171174
// CHECK: #undef PROC
172175

llvm/utils/TableGen/RISCVTargetDefEmitter.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "llvm/ADT/DenseSet.h"
15+
#include "llvm/Support/Format.h"
1516
#include "llvm/Support/RISCVISAUtils.h"
1617
#include "llvm/TableGen/Record.h"
1718
#include "llvm/TableGen/TableGenBackend.h"
@@ -166,7 +167,7 @@ static void emitRISCVProfiles(const RecordKeeper &Records, raw_ostream &OS) {
166167
static void emitRISCVProcs(const RecordKeeper &RK, raw_ostream &OS) {
167168
OS << "#ifndef PROC\n"
168169
<< "#define PROC(ENUM, NAME, DEFAULT_MARCH, FAST_SCALAR_UNALIGN"
169-
<< ", FAST_VECTOR_UNALIGN)\n"
170+
<< ", FAST_VECTOR_UNALIGN, MVENDORID, MARCHID, MIMPID)\n"
170171
<< "#endif\n\n";
171172

172173
// Iterate on all definition records.
@@ -182,6 +183,10 @@ static void emitRISCVProcs(const RecordKeeper &RK, raw_ostream &OS) {
182183
return Feature->getValueAsString("Name") == "unaligned-vector-mem";
183184
});
184185

186+
bool IsRV64 = any_of(Features, [&](auto &Feature) {
187+
return Feature->getValueAsString("Name") == "64bit";
188+
});
189+
185190
OS << "PROC(" << Rec->getName() << ", {\"" << Rec->getValueAsString("Name")
186191
<< "\"}, {\"";
187192

@@ -192,8 +197,17 @@ static void emitRISCVProcs(const RecordKeeper &RK, raw_ostream &OS) {
192197
printMArch(OS, Features);
193198
else
194199
OS << MArch;
200+
201+
uint32_t MVendorID = Rec->getValueAsInt("MVendorID");
202+
uint64_t MArchID = Rec->getValueAsInt("MArchID");
203+
uint64_t MImpID = Rec->getValueAsInt("MImpID");
204+
195205
OS << "\"}, " << FastScalarUnalignedAccess << ", "
196-
<< FastVectorUnalignedAccess << ")\n";
206+
<< FastVectorUnalignedAccess;
207+
OS << ", " << format_hex(MVendorID, 10);
208+
OS << ", " << format_hex(MArchID, IsRV64 ? 18 : 10);
209+
OS << ", " << format_hex(MImpID, IsRV64 ? 18 : 10);
210+
OS << ")\n";
197211
}
198212
OS << "\n#undef PROC\n";
199213
OS << "\n";

0 commit comments

Comments
 (0)