@@ -89,12 +89,12 @@ static void emitRISCVExtensions(RecordKeeper &Records, raw_ostream &OS) {
89
89
//
90
90
// This is almost the same as RISCVFeatures::parseFeatureBits, except that we
91
91
// get feature name from feature records instead of feature bits.
92
- static void printMArch (raw_ostream &OS, const Record &Rec ) {
92
+ static void printMArch (raw_ostream &OS, const std::vector< Record *> &Features ) {
93
93
RISCVISAUtils::OrderedExtensionMap Extensions;
94
94
unsigned XLen = 0 ;
95
95
96
96
// Convert features to FeatureVector.
97
- for (auto *Feature : Rec. getValueAsListOfDefs ( " Features" ) ) {
97
+ for (auto *Feature : Features) {
98
98
StringRef FeatureName = getExtensionName (Feature);
99
99
if (Feature->isSubClassOf (" RISCVExtension" )) {
100
100
unsigned Major = Feature->getValueAsInt (" MajorVersion" );
@@ -118,22 +118,39 @@ static void printMArch(raw_ostream &OS, const Record &Rec) {
118
118
OS << LS << Ext.first << Ext.second .Major << ' p' << Ext.second .Minor ;
119
119
}
120
120
121
+ static void emitRISCVProfiles (RecordKeeper &Records, raw_ostream &OS) {
122
+ OS << " #ifdef GET_SUPPORTED_PROFILES\n " ;
123
+ OS << " #undef GET_SUPPORTED_PROFILES\n\n " ;
124
+
125
+ OS << " static constexpr RISCVProfile SupportedProfiles[] = {\n " ;
126
+
127
+ for (const Record *Rec : Records.getAllDerivedDefinitions (" RISCVProfile" )) {
128
+ OS.indent (4 ) << " {\" " << Rec->getValueAsString (" Name" ) << " \" ,\" " ;
129
+ printMArch (OS, Rec->getValueAsListOfDefs (" Implies" ));
130
+ OS << " \" },\n " ;
131
+ }
132
+
133
+ OS << " };\n\n " ;
134
+
135
+ OS << " #endif // GET_SUPPORTED_PROFILES\n\n " ;
136
+ }
137
+
121
138
static void emitRISCVProcs (RecordKeeper &RK, raw_ostream &OS) {
122
139
OS << " #ifndef PROC\n "
123
140
<< " #define PROC(ENUM, NAME, DEFAULT_MARCH, FAST_UNALIGNED_ACCESS)\n "
124
141
<< " #endif\n\n " ;
125
142
126
143
// Iterate on all definition records.
127
144
for (const Record *Rec : RK.getAllDerivedDefinitions (" RISCVProcessorModel" )) {
128
- bool FastScalarUnalignedAccess =
129
- any_of (Rec->getValueAsListOfDefs (" Features" ), [&](auto &Feature) {
130
- return Feature->getValueAsString (" Name" ) == " unaligned-scalar-mem" ;
131
- });
145
+ const std::vector<Record *> &Features =
146
+ Rec->getValueAsListOfDefs (" Features" );
147
+ bool FastScalarUnalignedAccess = any_of (Features, [&](auto &Feature) {
148
+ return Feature->getValueAsString (" Name" ) == " unaligned-scalar-mem" ;
149
+ });
132
150
133
- bool FastVectorUnalignedAccess =
134
- any_of (Rec->getValueAsListOfDefs (" Features" ), [&](auto &Feature) {
135
- return Feature->getValueAsString (" Name" ) == " unaligned-vector-mem" ;
136
- });
151
+ bool FastVectorUnalignedAccess = any_of (Features, [&](auto &Feature) {
152
+ return Feature->getValueAsString (" Name" ) == " unaligned-vector-mem" ;
153
+ });
137
154
138
155
bool FastUnalignedAccess =
139
156
FastScalarUnalignedAccess && FastVectorUnalignedAccess;
@@ -145,7 +162,7 @@ static void emitRISCVProcs(RecordKeeper &RK, raw_ostream &OS) {
145
162
146
163
// Compute MArch from features if we don't specify it.
147
164
if (MArch.empty ())
148
- printMArch (OS, *Rec );
165
+ printMArch (OS, Features );
149
166
else
150
167
OS << MArch;
151
168
OS << " \" }, " << FastUnalignedAccess << " )\n " ;
@@ -167,6 +184,7 @@ static void emitRISCVProcs(RecordKeeper &RK, raw_ostream &OS) {
167
184
168
185
static void EmitRISCVTargetDef (RecordKeeper &RK, raw_ostream &OS) {
169
186
emitRISCVExtensions (RK, OS);
187
+ emitRISCVProfiles (RK, OS);
170
188
emitRISCVProcs (RK, OS);
171
189
}
172
190
0 commit comments