diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-09-02 21:17:18 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-12-08 17:34:50 +0000 |
commit | 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e (patch) | |
tree | 62f873df87c7c675557a179e0c4c83fe9f3087bc /contrib/llvm-project/llvm/tools/llvm-mca/CodeRegion.h | |
parent | cf037972ea8863e2bab7461d77345367d2c1e054 (diff) | |
parent | 7fa27ce4a07f19b07799a767fc29416f3b625afb (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/tools/llvm-mca/CodeRegion.h')
-rw-r--r-- | contrib/llvm-project/llvm/tools/llvm-mca/CodeRegion.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/contrib/llvm-project/llvm/tools/llvm-mca/CodeRegion.h b/contrib/llvm-project/llvm/tools/llvm-mca/CodeRegion.h index b5b2f3a0d118..ce107fd8f3b6 100644 --- a/contrib/llvm-project/llvm/tools/llvm-mca/CodeRegion.h +++ b/contrib/llvm-project/llvm/tools/llvm-mca/CodeRegion.h @@ -91,6 +91,8 @@ public: CodeRegion(llvm::StringRef Desc, llvm::SMLoc Start) : Description(Desc), RangeStart(Start) {} + virtual ~CodeRegion() = default; + void addInstruction(const llvm::MCInst &Instruction) { Instructions.emplace_back(Instruction); } @@ -115,14 +117,14 @@ using AnalysisRegion = CodeRegion; /// in analysis of the region. class InstrumentRegion : public CodeRegion { /// Instrument for this region. - SharedInstrument Instrument; + UniqueInstrument I; public: - InstrumentRegion(llvm::StringRef Desc, llvm::SMLoc Start, SharedInstrument I) - : CodeRegion(Desc, Start), Instrument(I) {} + InstrumentRegion(llvm::StringRef Desc, llvm::SMLoc Start, UniqueInstrument I) + : CodeRegion(Desc, Start), I(std::move(I)) {} public: - SharedInstrument getInstrument() const { return Instrument; } + Instrument *getInstrument() const { return I.get(); } }; class CodeRegionParseError final : public Error {}; @@ -142,6 +144,7 @@ protected: public: CodeRegions(llvm::SourceMgr &S) : SM(S), FoundErrors(false) {} + virtual ~CodeRegions() = default; typedef std::vector<UniqueCodeRegion>::iterator iterator; typedef std::vector<UniqueCodeRegion>::const_iterator const_iterator; @@ -167,26 +170,34 @@ public: bool isValid() const { return !FoundErrors; } bool isRegionActive(llvm::StringRef Description) const { - return ActiveRegions.find(Description) != ActiveRegions.end(); + return ActiveRegions.contains(Description); } + + virtual void beginRegion(llvm::StringRef Description, llvm::SMLoc Loc) = 0; + virtual void beginRegion(llvm::StringRef Description, llvm::SMLoc Loc, + UniqueInstrument Instrument) = 0; + virtual void endRegion(llvm::StringRef Description, llvm::SMLoc Loc) = 0; }; struct AnalysisRegions : public CodeRegions { AnalysisRegions(llvm::SourceMgr &S); - void beginRegion(llvm::StringRef Description, llvm::SMLoc Loc); - void endRegion(llvm::StringRef Description, llvm::SMLoc Loc); + void beginRegion(llvm::StringRef Description, llvm::SMLoc Loc) override; + void beginRegion(llvm::StringRef Description, llvm::SMLoc Loc, + UniqueInstrument Instrument) override {} + void endRegion(llvm::StringRef Description, llvm::SMLoc Loc) override; }; struct InstrumentRegions : public CodeRegions { + InstrumentRegions(llvm::SourceMgr &S); + void beginRegion(llvm::StringRef Description, llvm::SMLoc Loc) override{}; void beginRegion(llvm::StringRef Description, llvm::SMLoc Loc, - SharedInstrument Instrument); - void endRegion(llvm::StringRef Description, llvm::SMLoc Loc); + UniqueInstrument Instrument) override; + void endRegion(llvm::StringRef Description, llvm::SMLoc Loc) override; - const SmallVector<SharedInstrument> - getActiveInstruments(llvm::SMLoc Loc) const; + const SmallVector<Instrument *> getActiveInstruments(llvm::SMLoc Loc) const; }; } // namespace mca |