brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 8a9f3af Raw
61 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// Definitions and utilities for Validation Events.11///12//===----------------------------------------------------------------------===//13 14#ifndef LLVM_TOOLS_LLVM_EXEGESIS_VALIDATIONEVENT_H15#define LLVM_TOOLS_LLVM_EXEGESIS_VALIDATIONEVENT_H16 17#include "llvm/ADT/StringRef.h"18#include "llvm/Support/Error.h"19 20namespace llvm {21 22namespace exegesis {23 24// The main list of supported validation events. The mapping between validation25// events and pfm counters is defined in TableDef files for each target.26enum 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.40const char *getValidationEventName(ValidationEvent VE);41const char *getValidationEventDescription(ValidationEvent VE);42 43// Returns the ValidationEvent with the given name.44Expected<ValidationEvent> getValidationEventByName(StringRef Name);45 46// Command-line options for validation events.47struct 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 exegesis58} // namespace llvm59 60#endif61