@@ -85,16 +85,22 @@ static void ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature,
8585}
8686
8787// / Return the length of the longest entry in the table.
88- template <typename T>
89- static size_t getLongestEntryLength (ArrayRef<T> Table) {
88+ static size_t getLongestEntryLength (ArrayRef<SubtargetFeatureKV> Table) {
9089 size_t MaxLen = 0 ;
9190 for (auto &I : Table)
9291 MaxLen = std::max (MaxLen, std::strlen (I.Key ));
9392 return MaxLen;
9493}
9594
95+ static size_t getLongestEntryLength (ArrayRef<StringRef> Table) {
96+ size_t MaxLen = 0 ;
97+ for (StringRef I : Table)
98+ MaxLen = std::max (MaxLen, I.size ());
99+ return MaxLen;
100+ }
101+
96102// / Display help for feature and mcpu choices.
97- static void Help (ArrayRef<SubtargetSubTypeKV> CPUTable ,
103+ static void Help (ArrayRef<StringRef> CPUNames ,
98104 ArrayRef<SubtargetFeatureKV> FeatTable) {
99105 // the static variable ensures that the help information only gets
100106 // printed once even though a target machine creates multiple subtargets
@@ -104,14 +110,17 @@ static void Help(ArrayRef<SubtargetSubTypeKV> CPUTable,
104110 }
105111
106112 // Determine the length of the longest CPU and Feature entries.
107- unsigned MaxCPULen = getLongestEntryLength (CPUTable );
113+ unsigned MaxCPULen = getLongestEntryLength (CPUNames );
108114 unsigned MaxFeatLen = getLongestEntryLength (FeatTable);
109115
110116 // Print the CPU table.
111117 errs () << " Available CPUs for this target:\n\n " ;
112- for (auto &CPU : CPUTable)
113- errs () << format (" %-*s - Select the %s processor.\n " , MaxCPULen, CPU.Key ,
114- CPU.Key );
118+ for (auto &CPUName : CPUNames) {
119+ if (CPUName == " apple-latest" )
120+ continue ;
121+ errs () << format (" %-*s - Select the %s processor.\n " , MaxCPULen, CPUName.str ().c_str (),
122+ CPUName.str ().c_str ());
123+ }
115124 errs () << ' \n ' ;
116125
117126 // Print the Feature table.
@@ -127,7 +136,7 @@ static void Help(ArrayRef<SubtargetSubTypeKV> CPUTable,
127136}
128137
129138// / Display help for mcpu choices only
130- static void cpuHelp (ArrayRef<SubtargetSubTypeKV> CPUTable ) {
139+ static void cpuHelp (ArrayRef<StringRef> CPUNames ) {
131140 // the static variable ensures that the help information only gets
132141 // printed once even though a target machine creates multiple subtargets
133142 static bool PrintOnce = false ;
@@ -137,8 +146,11 @@ static void cpuHelp(ArrayRef<SubtargetSubTypeKV> CPUTable) {
137146
138147 // Print the CPU table.
139148 errs () << " Available CPUs for this target:\n\n " ;
140- for (auto &CPU : CPUTable)
141- errs () << " \t " << CPU.Key << " \n " ;
149+ for (auto &CPU : CPUNames) {
150+ if (CPU == " apple-latest" )
151+ continue ;
152+ errs () << " \t " << CPU << " \n " ;
153+ }
142154 errs () << ' \n ' ;
143155
144156 errs () << " Use -mcpu or -mtune to specify the target's processor.\n "
@@ -148,7 +160,9 @@ static void cpuHelp(ArrayRef<SubtargetSubTypeKV> CPUTable) {
148160 PrintOnce = true ;
149161}
150162
151- static FeatureBitset getFeatures (StringRef CPU, StringRef TuneCPU, StringRef FS,
163+ static FeatureBitset getFeatures (MCSubtargetInfo &STI,
164+ StringRef CPU, StringRef TuneCPU, StringRef FS,
165+ ArrayRef<StringRef> ProcNames,
152166 ArrayRef<SubtargetSubTypeKV> ProcDesc,
153167 ArrayRef<SubtargetFeatureKV> ProcFeatures) {
154168 SubtargetFeatures Features (FS);
@@ -163,7 +177,7 @@ static FeatureBitset getFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS,
163177
164178 // Check if help is needed
165179 if (CPU == " help" )
166- Help (ProcDesc , ProcFeatures);
180+ Help (ProcNames , ProcFeatures);
167181
168182 // Find CPU entry if CPU name is specified.
169183 else if (!CPU.empty ()) {
@@ -196,9 +210,9 @@ static FeatureBitset getFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS,
196210 for (const std::string &Feature : Features.getFeatures ()) {
197211 // Check for help
198212 if (Feature == " +help" )
199- Help (ProcDesc , ProcFeatures);
213+ Help (ProcNames , ProcFeatures);
200214 else if (Feature == " +cpuhelp" )
201- cpuHelp (ProcDesc );
215+ cpuHelp (ProcNames );
202216 else
203217 ApplyFeatureFlag (Bits, Feature, ProcFeatures);
204218 }
@@ -208,7 +222,7 @@ static FeatureBitset getFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS,
208222
209223void MCSubtargetInfo::InitMCProcessorInfo (StringRef CPU, StringRef TuneCPU,
210224 StringRef FS) {
211- FeatureBits = getFeatures (CPU, TuneCPU, FS, ProcDesc, ProcFeatures);
225+ FeatureBits = getFeatures (* this , CPU, TuneCPU, FS, ProcNames , ProcDesc, ProcFeatures);
212226 FeatureString = std::string (FS);
213227
214228 if (!TuneCPU.empty ())
@@ -219,20 +233,22 @@ void MCSubtargetInfo::InitMCProcessorInfo(StringRef CPU, StringRef TuneCPU,
219233
220234void MCSubtargetInfo::setDefaultFeatures (StringRef CPU, StringRef TuneCPU,
221235 StringRef FS) {
222- FeatureBits = getFeatures (CPU, TuneCPU, FS, ProcDesc, ProcFeatures);
236+ FeatureBits = getFeatures (* this , CPU, TuneCPU, FS, ProcNames , ProcDesc, ProcFeatures);
223237 FeatureString = std::string (FS);
224238}
225239
226240MCSubtargetInfo::MCSubtargetInfo (const Triple &TT, StringRef C, StringRef TC,
227- StringRef FS, ArrayRef<SubtargetFeatureKV> PF,
241+ StringRef FS,
242+ ArrayRef<StringRef> PN,
243+ ArrayRef<SubtargetFeatureKV> PF,
228244 ArrayRef<SubtargetSubTypeKV> PD,
229245 const MCWriteProcResEntry *WPR,
230246 const MCWriteLatencyEntry *WL,
231247 const MCReadAdvanceEntry *RA,
232248 const InstrStage *IS, const unsigned *OC,
233249 const unsigned *FP)
234250 : TargetTriple(TT), CPU(std::string(C)), TuneCPU(std::string(TC)),
235- ProcFeatures(PF), ProcDesc(PD), WriteProcResTable(WPR),
251+ ProcNames(PN), ProcFeatures(PF), ProcDesc(PD), WriteProcResTable(WPR),
236252 WriteLatencyTable(WL), ReadAdvanceTable(RA), Stages(IS),
237253 OperandCycles(OC), ForwardingPaths(FP) {
238254 InitMCProcessorInfo (CPU, TuneCPU, FS);
0 commit comments