diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-10-22 15:36:15 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-10-22 15:36:15 +0000 |
commit | 01b9fd6868104bc05a48c819d7516078d325b929 (patch) | |
tree | 7b8467b5ca5b07b3b039d7d5408616233efb1c35 /llvm/tools/llvm-mca/CodeRegion.h | |
parent | 6f5cd7c67fd104942738925b235ed2ca87e6d5d6 (diff) | |
download | bcm5719-llvm-01b9fd6868104bc05a48c819d7516078d325b929.tar.gz bcm5719-llvm-01b9fd6868104bc05a48c819d7516078d325b929.zip |
[llvm-mca] Use llvm::ArrayRef in class SourceMgr. NFCI
Class SourceMgr now uses type ArrayRef<MCInst> to reference the
sequence of code from a "CodeRegion".
llvm-svn: 344911
Diffstat (limited to 'llvm/tools/llvm-mca/CodeRegion.h')
-rw-r--r-- | llvm/tools/llvm-mca/CodeRegion.h | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/llvm/tools/llvm-mca/CodeRegion.h b/llvm/tools/llvm-mca/CodeRegion.h index 7f0025e4884..21ca8da9b53 100644 --- a/llvm/tools/llvm-mca/CodeRegion.h +++ b/llvm/tools/llvm-mca/CodeRegion.h @@ -34,6 +34,7 @@ #ifndef LLVM_TOOLS_LLVM_MCA_CODEREGION_H #define LLVM_TOOLS_LLVM_MCA_CODEREGION_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/MC/MCInst.h" #include "llvm/Support/SMLoc.h" @@ -49,7 +50,7 @@ class CodeRegion { // An optional descriptor for this region. llvm::StringRef Description; // Instructions that form this region. - std::vector<std::unique_ptr<const llvm::MCInst>> Instructions; + std::vector<llvm::MCInst> Instructions; // Source location range. llvm::SMLoc RangeStart; llvm::SMLoc RangeEnd; @@ -61,8 +62,8 @@ public: CodeRegion(llvm::StringRef Desc, llvm::SMLoc Start) : Description(Desc), RangeStart(Start), RangeEnd() {} - void addInstruction(std::unique_ptr<const llvm::MCInst> Instruction) { - Instructions.emplace_back(std::move(Instruction)); + void addInstruction(const llvm::MCInst &Instruction) { + Instructions.emplace_back(Instruction); } llvm::SMLoc startLoc() const { return RangeStart; } @@ -72,10 +73,7 @@ public: bool empty() const { return Instructions.empty(); } bool isLocInRange(llvm::SMLoc Loc) const; - const std::vector<std::unique_ptr<const llvm::MCInst>> & - getInstructions() const { - return Instructions; - } + llvm::ArrayRef<llvm::MCInst> getInstructions() const { return Instructions; } llvm::StringRef getDescription() const { return Description; } }; @@ -106,23 +104,21 @@ public: void beginRegion(llvm::StringRef Description, llvm::SMLoc Loc); void endRegion(llvm::SMLoc Loc); - void addInstruction(std::unique_ptr<const llvm::MCInst> Instruction); + void addInstruction(const llvm::MCInst &Instruction); CodeRegions(llvm::SourceMgr &S) : SM(S) { // Create a default region for the input code sequence. addRegion("Default", llvm::SMLoc()); } - const std::vector<std::unique_ptr<const llvm::MCInst>> & - getInstructionSequence(unsigned Idx) const { + llvm::ArrayRef<llvm::MCInst> getInstructionSequence(unsigned Idx) const { return Regions[Idx]->getInstructions(); } bool empty() const { - return std::all_of(Regions.begin(), Regions.end(), - [](const std::unique_ptr<CodeRegion> &Region) { - return Region->empty(); - }); + return llvm::all_of(Regions, [](const std::unique_ptr<CodeRegion> &Region) { + return Region->empty(); + }); } }; |