Skip to content

Commit b7904b7

Browse files
committed
change default versions to be per-extension
1 parent 416b31a commit b7904b7

File tree

2 files changed

+44
-31
lines changed

2 files changed

+44
-31
lines changed

include/RevFeature.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,25 @@ namespace SST::RevCPU {
2323
/// ORed to indicate multiple extensions being present.
2424
enum RevFeatureType : uint32_t {
2525
RV_UNKNOWN = 0, ///< RevFeatureType: unknown feature
26-
RV_E = 1 << 0, ///< RevFeatureType: E-extension
27-
RV_I = 1 << 1, ///< RevFeatureType: I-extension
26+
RV_I = 1 << 0, ///< RevFeatureType: I-extension
27+
RV_E = 1 << 1, ///< RevFeatureType: E-extension
2828
RV_M = 1 << 2, ///< RevFeatureType: M-extension
2929
RV_A = 1 << 3, ///< RevFeatureType: A-extension
3030
RV_F = 1 << 4, ///< RevFeatureType: F-extension
3131
RV_D = 1 << 5, ///< RevFeatureType: D-extension
3232
RV_Q = 1 << 6, ///< RevFeatureType: Q-extension
3333
RV_C = 1 << 7, ///< RevFeatureType: C-extension
34-
RV_P = 1 << 8, ///< RevFeatureType: P-Extension
35-
RV_V = 1 << 9, ///< RevFeatureType: V-extension
36-
RV_H = 1 << 10, ///< RevFeatureType: H-extension
37-
RV_ZICSR = 1 << 11, ///< RevFEatureType: Zicsr-extension
38-
RV_ZIFENCEI = 1 << 12, ///< RevFeatureType: Zifencei-extension
39-
RV_ZTSO = 1 << 13, ///< RevFeatureType: Ztso-extension
34+
RV_B = 1 << 8, ///< RevFeatureType: C-extension
35+
RV_P = 1 << 9, ///< RevFeatureType: P-Extension
36+
RV_V = 1 << 10, ///< RevFeatureType: V-extension
37+
RV_H = 1 << 11, ///< RevFeatureType: H-extension
38+
RV_ZICSR = 1 << 12, ///< RevFEatureType: Zicsr-extension
39+
RV_ZIFENCEI = 1 << 13, ///< RevFeatureType: Zifencei-extension
4040
RV_ZFA = 1 << 14, ///< RevFeatureType: Zfa-extension
4141
RV_ZICBOM = 1 << 15, ///< RevFeatureType: Zicbom-extension
42+
RV_ZFH = 1 << 16, ///< RevFeatureType: H-extension
43+
RV_ZFHMIN = 1 << 17, ///< RevFeatureRtpe: Zfhmin extension
44+
RV_ZTSO = 1 << 18, ///< RevFeatureType: Ztso-extension
4245
};
4346

4447
class RevFeature {

src/RevFeature.cc

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ bool RevFeature::ParseMachineModel() {
4040
output->verbose( CALL_INFO, 6, 0, "Core %u ; Setting XLEN to %u\n", ProcID, xlen );
4141
output->verbose( CALL_INFO, 6, 0, "Core %u ; Architecture string=%s\n", ProcID, mac );
4242

43+
// clang-format off
4344
///< List of architecture extensions. These must listed in canonical order
4445
///< as shown in Table 27.11, Chapter 27, of the RISC-V Unprivileged Spec
4546
///< (Table 74 of Chapter 36 in the 2024 version).
@@ -48,34 +49,39 @@ bool RevFeature::ParseMachineModel() {
4849
///< in linear time complexity of the table and the string. Some of the
4950
///< extensions imply other extensions, so the extension flags are ORed.
5051
///<
51-
///< The second and third values are the major version range that Rev supports.
52+
///< The second and third values are the major and minor default version.
53+
///< The fourth and fifth values are the major version range that Rev supports.
54+
///< Values of -1, 0 for the fourth and fifth values indicates no Rev support yet.
5255
///<
53-
// clang-format off
54-
static constexpr std::tuple<std::string_view, uint32_t, uint32_t, uint32_t> table[] = {
55-
{ "I", 1, -1, RV_I },
56-
{ "E", 1, -1, RV_E },
57-
{ "M", 1, -1, RV_M },
58-
{ "A", 1, -1, RV_A },
59-
{ "F", 1, -1, RV_F | RV_ZICSR },
60-
{ "D", 1, -1, RV_D | RV_F | RV_ZICSR },
61-
{ "G", 1, -1, RV_I | RV_M | RV_A | RV_F | RV_D | RV_ZICSR | RV_ZIFENCEI },
62-
{ "Q", 1, -1, RV_Q | RV_D | RV_F | RV_ZICSR },
63-
{ "C", 1, -1, RV_C },
64-
{ "P", 1, -1, RV_P },
65-
{ "V", 1, -1, RV_V | RV_D | RV_F | RV_ZICSR },
66-
{ "H", 1, -1, RV_H },
67-
{ "Zicsr", 1, -1, RV_ZICSR },
68-
{ "Zifencei", 1, -1, RV_ZIFENCEI },
69-
{ "Ztso", 1, -1, RV_ZTSO },
70-
{ "Zfa", 1, -1, RV_ZFA | RV_F | RV_ZICSR },
71-
{ "Zicbom", 1, -1, RV_ZICBOM },
56+
///< ExtensionName DefaultMajor DefaultMinor MinSupportedVersion MaxSupportedVersion Flags
57+
static constexpr std::tuple<std::string_view, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t> table[] = {
58+
{ "I", 2, 1, 2, 2, RV_I },
59+
{ "E", 2, 0, -1, 0, RV_E }, // Unsupported
60+
{ "M", 2, 0, 2, 2, RV_M },
61+
{ "A", 2, 1, 2, 2, RV_A },
62+
{ "F", 2, 2, 2, 2, RV_F | RV_ZICSR },
63+
{ "D", 2, 2, 2, 2, RV_D | RV_F | RV_ZICSR },
64+
{ "G", 2, 0, 2, 2, RV_I | RV_M | RV_A | RV_F | RV_D | RV_ZICSR | RV_ZIFENCEI },
65+
{ "Q", 2, 2, -1, 0, RV_Q | RV_D | RV_F | RV_ZICSR }, // Unsupported
66+
{ "C", 2, 0, 2, 2, RV_C },
67+
{ "B", 1, 0, -1, 0, RV_B }, // Unsupported
68+
{ "P", 0, 2, -1, 0, RV_P }, // Unsupported
69+
{ "V", 1, 0, -1, 0, RV_V | RV_D | RV_F | RV_ZICSR },
70+
{ "H", 1, 0, -1, 0, RV_H }, // Unsupported
71+
{ "Zicsr", 2, 0, 2, 2, RV_ZICSR },
72+
{ "Zifencei", 2, 0, 2, 2, RV_ZIFENCEI },
73+
{ "Zfa", 1, 0, 1, 1, RV_ZFA | RV_F | RV_ZICSR },
74+
{ "Zicbom", 1, 0, 1, 1, RV_ZICBOM },
75+
{ "Zfhmin", 1, 0, -1, 0, RV_ZFHMIN | RV_F | RV_ZICSR }, // Unsupported
76+
{ "Zfh", 1, 0, -1, 0, RV_ZFH | RV_ZFHMIN | RV_F | RV_ZICSR }, // Unsupported
77+
{ "Ztso", 1, 0, -1, 0, RV_ZTSO }, // Unsupported
7278
};
7379
// clang-format on
7480

7581
// -- step 2: parse all the features
7682
// Note: Extension strings, if present, must appear in the order listed in the table above.
7783
if( *mac ) {
78-
for( const auto& [ext, minimumVersion, maximumVersion, flags] : table ) {
84+
for( auto [ext, majorVersion, minorVersion, minimumVersion, maximumVersion, flags] : table ) {
7985
// Look for an architecture string matching the current extension
8086
if( !strncasecmp( mac, ext.data(), ext.size() ) ) {
8187

@@ -86,7 +92,6 @@ bool RevFeature::ParseMachineModel() {
8692
mac += ext.size();
8793

8894
// Optional version string follows extension
89-
unsigned long majorVersion = 2, minorVersion = 0;
9095
if( isdigit( *mac ) ) {
9196
majorVersion = strtoul( mac, const_cast<char**>( &mac ), 10 );
9297
if( tolower( *mac ) == 'p' && isdigit( *++mac ) )
@@ -95,7 +100,12 @@ bool RevFeature::ParseMachineModel() {
95100

96101
if( majorVersion < minimumVersion || majorVersion > maximumVersion ) {
97102
output->fatal(
98-
CALL_INFO, -1, "Error: Version %lu.%lu of %s extension is not supported\n", majorVersion, minorVersion, ext.data()
103+
CALL_INFO,
104+
-1,
105+
"Error: Version %" PRIu32 ".%" PRIu32 " of %s extension is not supported\n",
106+
majorVersion,
107+
minorVersion,
108+
ext.data()
99109
);
100110
}
101111

0 commit comments

Comments
 (0)