@@ -34,8 +34,7 @@ namespace {
34
34
struct YamlContext {
35
35
YamlContext (const exegesis::LLVMState &State)
36
36
: State(&State), ErrorStream(LastError),
37
- OpcodeNameToOpcodeIdx (State.getOpcodeNameToOpcodeIdxMapping()),
38
- RegNameToRegNo(State.getRegNameToRegNoMapping()) {}
37
+ OpcodeNameToOpcodeIdx (State.getOpcodeNameToOpcodeIdxMapping()) {}
39
38
40
39
void serializeMCInst (const MCInst &MCInst, raw_ostream &OS) {
41
40
OS << getInstrName (MCInst.getOpcode ());
@@ -77,11 +76,11 @@ struct YamlContext {
77
76
}
78
77
79
78
std::optional<unsigned > getRegNo (StringRef RegName) {
80
- auto Iter = RegNameToRegNo. find (RegName);
81
- if (Iter != RegNameToRegNo. end ())
82
- return Iter-> second ;
83
- ErrorStream << " No register with name '" << RegName << " '\n " ;
84
- return std::nullopt ;
79
+ std::optional<MCRegister> RegisterNumber =
80
+ State-> getRegisterNumberFromName (RegName);
81
+ if (!RegisterNumber. has_value ())
82
+ ErrorStream << " No register with name '" << RegName << " '\n " ;
83
+ return RegisterNumber ;
85
84
}
86
85
87
86
private:
@@ -154,7 +153,6 @@ struct YamlContext {
154
153
std::string LastError;
155
154
raw_string_ostream ErrorStream;
156
155
const DenseMap<StringRef, unsigned > &OpcodeNameToOpcodeIdx;
157
- const DenseMap<StringRef, MCRegister> &RegNameToRegNo;
158
156
};
159
157
} // namespace
160
158
@@ -231,10 +229,8 @@ template <> struct MappingTraits<exegesis::BenchmarkMeasure> {
231
229
static const bool flow = true ;
232
230
};
233
231
234
- template <>
235
- struct ScalarEnumerationTraits <exegesis::Benchmark::ModeE> {
236
- static void enumeration (IO &Io,
237
- exegesis::Benchmark::ModeE &Value) {
232
+ template <> struct ScalarEnumerationTraits <exegesis::Benchmark::ModeE> {
233
+ static void enumeration (IO &Io, exegesis::Benchmark::ModeE &Value) {
238
234
Io.enumCase (Value, " " , exegesis::Benchmark::Unknown);
239
235
Io.enumCase (Value, " latency" , exegesis::Benchmark::Latency);
240
236
Io.enumCase (Value, " uops" , exegesis::Benchmark::Uops);
@@ -282,8 +278,7 @@ template <> struct ScalarTraits<exegesis::RegisterValue> {
282
278
static const bool flow = true ;
283
279
};
284
280
285
- template <>
286
- struct MappingContextTraits <exegesis::BenchmarkKey, YamlContext> {
281
+ template <> struct MappingContextTraits <exegesis::BenchmarkKey, YamlContext> {
287
282
static void mapping (IO &Io, exegesis::BenchmarkKey &Obj,
288
283
YamlContext &Context) {
289
284
Io.setContext (&Context);
@@ -293,8 +288,7 @@ struct MappingContextTraits<exegesis::BenchmarkKey, YamlContext> {
293
288
}
294
289
};
295
290
296
- template <>
297
- struct MappingContextTraits <exegesis::Benchmark, YamlContext> {
291
+ template <> struct MappingContextTraits <exegesis::Benchmark, YamlContext> {
298
292
struct NormalizedBinary {
299
293
NormalizedBinary (IO &io) {}
300
294
NormalizedBinary (IO &, std::vector<uint8_t > &Data) : Binary(Data) {}
@@ -311,8 +305,7 @@ struct MappingContextTraits<exegesis::Benchmark, YamlContext> {
311
305
BinaryRef Binary;
312
306
};
313
307
314
- static void mapping (IO &Io, exegesis::Benchmark &Obj,
315
- YamlContext &Context) {
308
+ static void mapping (IO &Io, exegesis::Benchmark &Obj, YamlContext &Context) {
316
309
Io.mapRequired (" mode" , Obj.Mode );
317
310
Io.mapRequired (" key" , Obj.Key , Context);
318
311
Io.mapRequired (" cpu_name" , Obj.CpuName );
@@ -339,8 +332,7 @@ struct MappingContextTraits<exegesis::Benchmark, YamlContext> {
339
332
};
340
333
341
334
template <> struct MappingTraits <exegesis::Benchmark::TripleAndCpu> {
342
- static void mapping (IO &Io,
343
- exegesis::Benchmark::TripleAndCpu &Obj) {
335
+ static void mapping (IO &Io, exegesis::Benchmark::TripleAndCpu &Obj) {
344
336
assert (!Io.outputting () && " can only read TripleAndCpu" );
345
337
// Read triple.
346
338
Io.mapRequired (" llvm_triple" , Obj.LLVMTriple );
@@ -357,8 +349,7 @@ Expected<std::set<Benchmark::TripleAndCpu>>
357
349
Benchmark::readTriplesAndCpusFromYamls (MemoryBufferRef Buffer) {
358
350
// We're only mapping a field, drop other fields and silence the corresponding
359
351
// warnings.
360
- yaml::Input Yin (
361
- Buffer, nullptr , +[](const SMDiagnostic &, void *Context) {});
352
+ yaml::Input Yin (Buffer, nullptr , +[](const SMDiagnostic &, void *Context) {});
362
353
Yin.setAllowUnknownKeys (true );
363
354
std::set<TripleAndCpu> Result;
364
355
yaml::EmptyContext Context;
@@ -373,8 +364,8 @@ Benchmark::readTriplesAndCpusFromYamls(MemoryBufferRef Buffer) {
373
364
return Result;
374
365
}
375
366
376
- Expected<Benchmark>
377
- Benchmark::readYaml ( const LLVMState &State, MemoryBufferRef Buffer) {
367
+ Expected<Benchmark> Benchmark::readYaml ( const LLVMState &State,
368
+ MemoryBufferRef Buffer) {
378
369
yaml::Input Yin (Buffer);
379
370
YamlContext Context (State);
380
371
Benchmark Benchmark;
@@ -385,9 +376,8 @@ Benchmark::readYaml(const LLVMState &State, MemoryBufferRef Buffer) {
385
376
return std::move (Benchmark);
386
377
}
387
378
388
- Expected<std::vector<Benchmark>>
389
- Benchmark::readYamls (const LLVMState &State,
390
- MemoryBufferRef Buffer) {
379
+ Expected<std::vector<Benchmark>> Benchmark::readYamls (const LLVMState &State,
380
+ MemoryBufferRef Buffer) {
391
381
yaml::Input Yin (Buffer);
392
382
YamlContext Context (State);
393
383
std::vector<Benchmark> Benchmarks;
@@ -403,8 +393,7 @@ Benchmark::readYamls(const LLVMState &State,
403
393
return std::move (Benchmarks);
404
394
}
405
395
406
- Error Benchmark::writeYamlTo (const LLVMState &State,
407
- raw_ostream &OS) {
396
+ Error Benchmark::writeYamlTo (const LLVMState &State, raw_ostream &OS) {
408
397
auto Cleanup = make_scope_exit ([&] { OS.flush (); });
409
398
yaml::Output Yout (OS, nullptr /* Ctx*/ , 200 /* WrapColumn*/ );
410
399
YamlContext Context (State);
@@ -416,8 +405,7 @@ Error Benchmark::writeYamlTo(const LLVMState &State,
416
405
return Error::success ();
417
406
}
418
407
419
- Error Benchmark::readYamlFrom (const LLVMState &State,
420
- StringRef InputContent) {
408
+ Error Benchmark::readYamlFrom (const LLVMState &State, StringRef InputContent) {
421
409
yaml::Input Yin (InputContent);
422
410
YamlContext Context (State);
423
411
if (Yin.setCurrentDocument ())
0 commit comments