diff options
| author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-10-24 10:56:47 +0000 |
|---|---|---|
| committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-10-24 10:56:47 +0000 |
| commit | 083addf75192ff07eccd002eceeeacd085054217 (patch) | |
| tree | 724d9216029784e31e31e21542d39ee6d7b99de5 /llvm/tools/llvm-mca/include/Support.h | |
| parent | 5a74a9cf5f9eb012d97075e3d85f7a8698a97a3e (diff) | |
| download | bcm5719-llvm-083addf75192ff07eccd002eceeeacd085054217.tar.gz bcm5719-llvm-083addf75192ff07eccd002eceeeacd085054217.zip | |
[llvm-mca] [llvm-mca] Improved error handling and error reporting from class InstrBuilder.
A new class named InstructionError has been added to Support.h in order to
improve the error reporting from class InstrBuilder.
The llvm-mca driver is responsible for handling InstructionError objects, and
printing them out to stderr.
The goal of this patch is to remove all the remaining error handling logic from
the library code.
In particular, this allows us to:
- Simplify the logic in InstrBuilder by removing a needless dependency from
MCInstrPrinter.
- Centralize all the error halding logic in a new function named 'runPipeline'
(see llvm-mca.cpp).
This is also a first step towards generalizing class InstrBuilder, so that in
future, we will be able to reuse its logic to also "lower" MachineInstr to
mca::Instruction objects.
Differential Revision: https://reviews.llvm.org/D53585
llvm-svn: 345129
Diffstat (limited to 'llvm/tools/llvm-mca/include/Support.h')
| -rw-r--r-- | llvm/tools/llvm-mca/include/Support.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/tools/llvm-mca/include/Support.h b/llvm/tools/llvm-mca/include/Support.h index 91c8e1b4177..9371394542d 100644 --- a/llvm/tools/llvm-mca/include/Support.h +++ b/llvm/tools/llvm-mca/include/Support.h @@ -18,9 +18,29 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/MC/MCSchedule.h" +#include "llvm/Support/Error.h" namespace mca { +template <typename T> +class InstructionError : public llvm::ErrorInfo<InstructionError<T>> { +public: + static char ID; + std::string Message; + const T &Inst; + + InstructionError(std::string M, const T &MCI) + : Message(std::move(M)), Inst(MCI) {} + + void log(llvm::raw_ostream &OS) const override { OS << Message; } + + std::error_code convertToErrorCode() const override { + return llvm::inconvertibleErrorCode(); + } +}; + +template <typename T> char InstructionError<T>::ID; + /// This class represents the number of cycles per resource (fractions of /// cycles). That quantity is managed here as a ratio, and accessed via the /// double cast-operator below. The two quantities, number of cycles and |

