summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/Instruction.h
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-06-28 15:50:26 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-06-28 15:50:26 +0000
commit877f9a7e392f0bbc61225f498fd9cf6462f1dd28 (patch)
tree4505141a795268445afb789e99d40293520d215a /llvm/tools/llvm-mca/Instruction.h
parent298a61590ab694b33407a56feb60e19145078cac (diff)
downloadbcm5719-llvm-877f9a7e392f0bbc61225f498fd9cf6462f1dd28.tar.gz
bcm5719-llvm-877f9a7e392f0bbc61225f498fd9cf6462f1dd28.zip
[llvm-mca] Use a WriteRef to describe register writes in class RegisterFile.
This patch introduces a new class named WriteRef. A WriteRef is used by the RegisterFile to keep track of register definitions. Internally it wraps a WriteState, as well as the source index of the defining instruction. This patch allows the tool to propagate additional information to support future analysis on data dependencies. llvm-svn: 335867
Diffstat (limited to 'llvm/tools/llvm-mca/Instruction.h')
-rw-r--r--llvm/tools/llvm-mca/Instruction.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/tools/llvm-mca/Instruction.h b/llvm/tools/llvm-mca/Instruction.h
index 32246cebaa5..2df6a59f38c 100644
--- a/llvm/tools/llvm-mca/Instruction.h
+++ b/llvm/tools/llvm-mca/Instruction.h
@@ -381,6 +381,36 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const InstRef &IR) {
}
#endif
+/// A reference to a register write.
+///
+/// This class is mainly used by the register file to describe register
+/// mappings. It correlates a register write to the source index of the
+/// defining instruction.
+class WriteRef {
+ std::pair<unsigned, WriteState *> Data;
+ static const unsigned INVALID_IID;
+
+public:
+ WriteRef() : Data(INVALID_IID, nullptr) {}
+ WriteRef(unsigned SourceIndex, WriteState *WS) : Data(SourceIndex, WS) {}
+
+ unsigned getSourceIndex() const { return Data.first; }
+ const WriteState *getWriteState() const { return Data.second; }
+ WriteState *getWriteState() { return Data.second; }
+ void invalidate() { Data = std::make_pair(INVALID_IID, nullptr); }
+
+ bool isValid() const {
+ return Data.first != INVALID_IID && Data.second != nullptr;
+ }
+ bool operator==(const WriteRef &Other) const {
+ return Data == Other.Data;
+ }
+
+#ifndef NDEBUG
+ void dump() const;
+#endif
+};
+
} // namespace mca
#endif
OpenPOWER on IntegriCloud