1 | //===-- ValidationEvent.h ---------------------------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | /// |
9 | /// \file |
10 | /// Definitions and utilities for Validation Events. |
11 | /// |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #ifndef LLVM_TOOLS_LLVM_EXEGESIS_VALIDATIONEVENT_H |
15 | #define LLVM_TOOLS_LLVM_EXEGESIS_VALIDATIONEVENT_H |
16 | |
17 | #include "llvm/ADT/StringRef.h" |
18 | #include "llvm/Support/Error.h" |
19 | |
20 | namespace llvm { |
21 | |
22 | namespace exegesis { |
23 | |
24 | // The main list of supported validation events. The mapping between validation |
25 | // events and pfm counters is defined in TableDef files for each target. |
26 | enum ValidationEvent { |
27 | InstructionRetired, |
28 | L1DCacheLoadMiss, |
29 | L1DCacheStoreMiss, |
30 | L1ICacheLoadMiss, |
31 | DataTLBLoadMiss, |
32 | DataTLBStoreMiss, |
33 | InstructionTLBLoadMiss, |
34 | BranchPredictionMiss, |
35 | // Number of events. |
36 | NumValidationEvents, |
37 | }; |
38 | |
39 | // Returns the name/description of the given event. |
40 | const char *getValidationEventName(ValidationEvent VE); |
41 | const char *getValidationEventDescription(ValidationEvent VE); |
42 | |
43 | // Returns the ValidationEvent with the given name. |
44 | Expected<ValidationEvent> getValidationEventByName(StringRef Name); |
45 | |
46 | // Command-line options for validation events. |
47 | struct ValidationEventOptions { |
48 | template <class Opt> void apply(Opt &O) const { |
49 | for (int I = 0; I < NumValidationEvents; ++I) { |
50 | const auto VE = static_cast<ValidationEvent>(I); |
51 | O.getParser().addLiteralOption(getValidationEventName(VE), VE, |
52 | getValidationEventDescription(VE)); |
53 | } |
54 | } |
55 | }; |
56 | |
57 | } // namespace exegesis |
58 | } // namespace llvm |
59 | |
60 | #endif |
61 | |