@@ -40,6 +40,7 @@ bool RevFeature::ParseMachineModel() {
40
40
output->verbose ( CALL_INFO, 6 , 0 , " Core %u ; Setting XLEN to %u\n " , ProcID, xlen );
41
41
output->verbose ( CALL_INFO, 6 , 0 , " Core %u ; Architecture string=%s\n " , ProcID, mac );
42
42
43
+ // clang-format off
43
44
// /< List of architecture extensions. These must listed in canonical order
44
45
// /< as shown in Table 27.11, Chapter 27, of the RISC-V Unprivileged Spec
45
46
// /< (Table 74 of Chapter 36 in the 2024 version).
@@ -48,34 +49,39 @@ bool RevFeature::ParseMachineModel() {
48
49
// /< in linear time complexity of the table and the string. Some of the
49
50
// /< extensions imply other extensions, so the extension flags are ORed.
50
51
// /<
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.
52
55
// /<
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
72
78
};
73
79
// clang-format on
74
80
75
81
// -- step 2: parse all the features
76
82
// Note: Extension strings, if present, must appear in the order listed in the table above.
77
83
if ( *mac ) {
78
- for ( const auto & [ext, minimumVersion, maximumVersion, flags] : table ) {
84
+ for ( auto [ext, majorVersion, minorVersion , minimumVersion, maximumVersion, flags] : table ) {
79
85
// Look for an architecture string matching the current extension
80
86
if ( !strncasecmp ( mac, ext.data (), ext.size () ) ) {
81
87
@@ -86,7 +92,6 @@ bool RevFeature::ParseMachineModel() {
86
92
mac += ext.size ();
87
93
88
94
// Optional version string follows extension
89
- unsigned long majorVersion = 2 , minorVersion = 0 ;
90
95
if ( isdigit ( *mac ) ) {
91
96
majorVersion = strtoul ( mac, const_cast <char **>( &mac ), 10 );
92
97
if ( tolower ( *mac ) == ' p' && isdigit ( *++mac ) )
@@ -95,7 +100,12 @@ bool RevFeature::ParseMachineModel() {
95
100
96
101
if ( majorVersion < minimumVersion || majorVersion > maximumVersion ) {
97
102
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 ()
99
109
);
100
110
}
101
111
0 commit comments