Allow SymbolUserOpInterface operators to be used in RemoveDeadValues Pass (#117405)
[llvm-project.git] / llvm / tools / llvm-exegesis / lib / Error.h
blob4a3e48997f24f66fcf06e141ab089b87937bf914
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TOOLS_LLVM_EXEGESIS_ERROR_H
10 #define LLVM_TOOLS_LLVM_EXEGESIS_ERROR_H
12 #include "llvm/ADT/Twine.h"
13 #include "llvm/Support/Error.h"
15 namespace llvm {
16 namespace exegesis {
18 // A class representing failures that happened within llvm-exegesis, they are
19 // used to report informations to the user.
20 class Failure : public StringError {
21 public:
22 Failure(const Twine &S) : StringError(S, inconvertibleErrorCode()) {}
25 // A class representing failures that happened during clustering calculations.
26 class ClusteringError : public ErrorInfo<ClusteringError> {
27 public:
28 static char ID;
29 ClusteringError(const Twine &S) : Msg(S.str()) {}
31 void log(raw_ostream &OS) const override;
33 std::error_code convertToErrorCode() const override;
35 private:
36 std::string Msg;
39 // A class representing a non-descript snippet execution failure. This class
40 // is designed to sub-classed into more specific failures that contain
41 // additional data about the specific error that they represent. Instead of
42 // halting the program, the errors are reported in the output.
43 class SnippetExecutionFailure : public ErrorInfo<SnippetExecutionFailure> {
44 public:
45 static char ID;
47 std::error_code convertToErrorCode() const override;
50 // A class representing specifically segmentation faults that happen during
51 // snippet execution.
52 class SnippetSegmentationFault : public SnippetExecutionFailure {
53 public:
54 static char ID;
55 SnippetSegmentationFault(uintptr_t SegFaultAddress)
56 : Address(SegFaultAddress) {};
58 uintptr_t getAddress() { return Address; }
60 void log(raw_ostream &OS) const override;
62 private:
63 uintptr_t Address;
66 // A class representing all other non-specific failures that happen during
67 // snippet execution.
68 class SnippetSignal : public SnippetExecutionFailure {
69 public:
70 static char ID;
71 SnippetSignal(int Signal) : SignalNumber(Signal){};
73 void log(raw_ostream &OS) const override;
75 private:
76 int SignalNumber;
79 } // namespace exegesis
80 } // namespace llvm
82 #endif