@@ -48,37 +48,41 @@ static void emitRISCVExtensions(RecordKeeper &Records, raw_ostream &OS) {
48
48
OS << " #undef GET_SUPPORTED_EXTENSIONS\n\n " ;
49
49
50
50
std::vector<Record *> Extensions =
51
- Records.getAllDerivedDefinitions (" RISCVExtension" );
51
+ Records.getAllDerivedDefinitionsIfDefined (" RISCVExtension" );
52
52
llvm::sort (Extensions, [](const Record *Rec1, const Record *Rec2) {
53
53
return getExtensionName (Rec1) < getExtensionName (Rec2);
54
54
});
55
55
56
- printExtensionTable (OS, Extensions, /* Experimental=*/ false );
57
- printExtensionTable (OS, Extensions, /* Experimental=*/ true );
56
+ if (!Extensions.empty ()) {
57
+ printExtensionTable (OS, Extensions, /* Experimental=*/ false );
58
+ printExtensionTable (OS, Extensions, /* Experimental=*/ true );
59
+ }
58
60
59
61
OS << " #endif // GET_SUPPORTED_EXTENSIONS\n\n " ;
60
62
61
63
OS << " #ifdef GET_IMPLIED_EXTENSIONS\n " ;
62
64
OS << " #undef GET_IMPLIED_EXTENSIONS\n\n " ;
63
65
64
- OS << " \n static constexpr ImpliedExtsEntry ImpliedExts[] = {\n " ;
65
- for (Record *Ext : Extensions) {
66
- auto ImpliesList = Ext->getValueAsListOfDefs (" Implies" );
67
- if (ImpliesList.empty ())
68
- continue ;
66
+ if (!Extensions.empty ()) {
67
+ OS << " \n static constexpr ImpliedExtsEntry ImpliedExts[] = {\n " ;
68
+ for (Record *Ext : Extensions) {
69
+ auto ImpliesList = Ext->getValueAsListOfDefs (" Implies" );
70
+ if (ImpliesList.empty ())
71
+ continue ;
69
72
70
- StringRef Name = getExtensionName (Ext);
73
+ StringRef Name = getExtensionName (Ext);
71
74
72
- for (auto *ImpliedExt : ImpliesList) {
73
- if (!ImpliedExt->isSubClassOf (" RISCVExtension" ))
74
- continue ;
75
+ for (auto *ImpliedExt : ImpliesList) {
76
+ if (!ImpliedExt->isSubClassOf (" RISCVExtension" ))
77
+ continue ;
75
78
76
- OS << " { {\" " << Name << " \" }, \" " << getExtensionName (ImpliedExt)
77
- << " \" },\n " ;
79
+ OS << " { {\" " << Name << " \" }, \" " << getExtensionName (ImpliedExt)
80
+ << " \" },\n " ;
81
+ }
78
82
}
79
- }
80
83
81
- OS << " };\n\n " ;
84
+ OS << " };\n\n " ;
85
+ }
82
86
83
87
OS << " #endif // GET_IMPLIED_EXTENSIONS\n\n " ;
84
88
}
@@ -122,19 +126,20 @@ static void emitRISCVProfiles(RecordKeeper &Records, raw_ostream &OS) {
122
126
OS << " #ifdef GET_SUPPORTED_PROFILES\n " ;
123
127
OS << " #undef GET_SUPPORTED_PROFILES\n\n " ;
124
128
125
- OS << " static constexpr RISCVProfile SupportedProfiles[] = { \n " ;
129
+ auto Profiles = Records. getAllDerivedDefinitionsIfDefined ( " RISCVProfile " ) ;
126
130
127
- auto Profiles = Records.getAllDerivedDefinitions (" RISCVProfile" );
128
- llvm::sort (Profiles, LessRecordFieldName ());
131
+ if (!Profiles.empty ()) {
132
+ llvm::sort (Profiles, LessRecordFieldName ());
133
+ OS << " static constexpr RISCVProfile SupportedProfiles[] = {\n " ;
134
+ for (const Record *Rec : Profiles) {
135
+ OS.indent (4 ) << " {\" " << Rec->getValueAsString (" Name" ) << " \" ,\" " ;
136
+ printMArch (OS, Rec->getValueAsListOfDefs (" Implies" ));
137
+ OS << " \" },\n " ;
138
+ }
129
139
130
- for (const Record *Rec : Profiles) {
131
- OS.indent (4 ) << " {\" " << Rec->getValueAsString (" Name" ) << " \" ,\" " ;
132
- printMArch (OS, Rec->getValueAsListOfDefs (" Implies" ));
133
- OS << " \" },\n " ;
140
+ OS << " };\n\n " ;
134
141
}
135
142
136
- OS << " };\n\n " ;
137
-
138
143
OS << " #endif // GET_SUPPORTED_PROFILES\n\n " ;
139
144
}
140
145
@@ -144,7 +149,8 @@ static void emitRISCVProcs(RecordKeeper &RK, raw_ostream &OS) {
144
149
<< " #endif\n\n " ;
145
150
146
151
// Iterate on all definition records.
147
- for (const Record *Rec : RK.getAllDerivedDefinitions (" RISCVProcessorModel" )) {
152
+ for (const Record *Rec :
153
+ RK.getAllDerivedDefinitionsIfDefined (" RISCVProcessorModel" )) {
148
154
const std::vector<Record *> &Features =
149
155
Rec->getValueAsListOfDefs (" Features" );
150
156
bool FastScalarUnalignedAccess = any_of (Features, [&](auto &Feature) {
@@ -177,7 +183,7 @@ static void emitRISCVProcs(RecordKeeper &RK, raw_ostream &OS) {
177
183
<< " #endif\n\n " ;
178
184
179
185
for (const Record *Rec :
180
- RK.getAllDerivedDefinitions (" RISCVTuneProcessorModel" )) {
186
+ RK.getAllDerivedDefinitionsIfDefined (" RISCVTuneProcessorModel" )) {
181
187
OS << " TUNE_PROC(" << Rec->getName () << " , "
182
188
<< " \" " << Rec->getValueAsString (" Name" ) << " \" )\n " ;
183
189
}
0 commit comments