summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/Instruction.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-mca/Instruction.h')
-rw-r--r--llvm/tools/llvm-mca/Instruction.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/tools/llvm-mca/Instruction.h b/llvm/tools/llvm-mca/Instruction.h
index 55dc644a587..33e867fedce 100644
--- a/llvm/tools/llvm-mca/Instruction.h
+++ b/llvm/tools/llvm-mca/Instruction.h
@@ -107,6 +107,9 @@ class WriteState {
// that we don't break the WAW, and the two writes can be merged together.
const WriteState *DependentWrite;
+ // Number of writes that are in a WAW dependency with this write.
+ unsigned NumWriteUsers;
+
// A list of dependent reads. Users is a set of dependent
// reads. A dependent read is added to the set only if CyclesLeft
// is "unknown". As soon as CyclesLeft is 'known', each user in the set
@@ -119,7 +122,8 @@ public:
WriteState(const WriteDescriptor &Desc, unsigned RegID,
bool clearsSuperRegs = false)
: WD(Desc), CyclesLeft(UNKNOWN_CYCLES), RegisterID(RegID),
- ClearsSuperRegs(clearsSuperRegs), DependentWrite(nullptr) {}
+ ClearsSuperRegs(clearsSuperRegs), DependentWrite(nullptr),
+ NumWriteUsers(0U) {}
WriteState(const WriteState &Other) = delete;
WriteState &operator=(const WriteState &Other) = delete;
@@ -129,11 +133,15 @@ public:
unsigned getLatency() const { return WD.Latency; }
void addUser(ReadState *Use, int ReadAdvance);
- unsigned getNumUsers() const { return Users.size(); }
+
+ unsigned getNumUsers() const { return Users.size() + NumWriteUsers; }
bool clearsSuperRegisters() const { return ClearsSuperRegs; }
const WriteState *getDependentWrite() const { return DependentWrite; }
- void setDependentWrite(const WriteState *Write) { DependentWrite = Write; }
+ void setDependentWrite(WriteState *Other) {
+ DependentWrite = Other;
+ ++Other->NumWriteUsers;
+ }
// On every cycle, update CyclesLeft and notify dependent users.
void cycleEvent();
@@ -330,6 +338,11 @@ public:
unsigned getRCUTokenID() const { return RCUTokenID; }
int getCyclesLeft() const { return CyclesLeft; }
+ bool hasDependentUsers() const {
+ return llvm::any_of(
+ Defs, [](const UniqueDef &Def) { return Def->getNumUsers() > 0; });
+ }
+
bool isDependencyBreaking() const { return IsDepBreaking; }
void setDependencyBreaking() { IsDepBreaking = true; }
OpenPOWER on IntegriCloud