brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · c899023 Raw
95 lines · c
1//===-- Error.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#ifndef LLVM_TOOLS_LLVM_EXEGESIS_ERROR_H10#define LLVM_TOOLS_LLVM_EXEGESIS_ERROR_H11 12#include "llvm/ADT/Twine.h"13#include "llvm/Support/Error.h"14 15namespace llvm {16namespace exegesis {17 18// A class representing failures that happened within llvm-exegesis, they are19// used to report informations to the user.20class Failure : public StringError {21public:22  Failure(const Twine &S) : StringError(S, inconvertibleErrorCode()) {}23};24 25// A class representing failures that happened during clustering calculations.26class ClusteringError : public ErrorInfo<ClusteringError> {27public:28  static char ID;29  ClusteringError(const Twine &S) : Msg(S.str()) {}30 31  void log(raw_ostream &OS) const override;32 33  std::error_code convertToErrorCode() const override;34 35private:36  std::string Msg;37};38 39// A class representing a non-descript snippet execution failure. This class40// is designed to sub-classed into more specific failures that contain41// additional data about the specific error that they represent. Instead of42// halting the program, the errors are reported in the output.43class SnippetExecutionFailure : public ErrorInfo<SnippetExecutionFailure> {44public:45  static char ID;46 47  std::error_code convertToErrorCode() const override;48};49 50// A class representing specifically segmentation faults that happen during51// snippet execution.52class SnippetSegmentationFault : public SnippetExecutionFailure {53public:54  static char ID;55  SnippetSegmentationFault(uintptr_t SegFaultAddress)56      : Address(SegFaultAddress) {};57 58  uintptr_t getAddress() { return Address; }59 60  void log(raw_ostream &OS) const override;61 62private:63  uintptr_t Address;64};65 66// A class representing all other non-specific failures that happen during67// snippet execution.68class SnippetSignal : public SnippetExecutionFailure {69public:70  static char ID;71  SnippetSignal(int Signal) : SignalNumber(Signal){};72 73  void log(raw_ostream &OS) const override;74 75private:76  int SignalNumber;77};78 79// A class representing a case where a perf counter was only partially80// scheduled, most likely due to perf counter contention.81struct PerfCounterNotFullyEnabled82    : public ErrorInfo<PerfCounterNotFullyEnabled> {83  static char ID;84  PerfCounterNotFullyEnabled() = default;85 86  void log(raw_ostream &OS) const override;87 88  std::error_code convertToErrorCode() const override;89};90 91} // namespace exegesis92} // namespace llvm93 94#endif95