aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-mca
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-07-06 13:46:10 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-07-06 13:46:10 +0000
commit2d706a67e357c2e959b9eb7f426f2f287de4a241 (patch)
treeb0ccbbac44d8d9cafd6591158dfb0f529535c74f /tools/llvm-mca
parent023b04f4507adc477a5fb81c8f2f5ccc697f4121 (diff)
[llvm-mca] A write latency cannot be a negative value. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-mca')
-rw-r--r--tools/llvm-mca/InstrBuilder.cpp6
-rw-r--r--tools/llvm-mca/Instruction.cpp4
-rw-r--r--tools/llvm-mca/Instruction.h10
3 files changed, 10 insertions, 10 deletions
diff --git a/tools/llvm-mca/InstrBuilder.cpp b/tools/llvm-mca/InstrBuilder.cpp
index b1ed2daac38..5b6b31b2eda 100644
--- a/tools/llvm-mca/InstrBuilder.cpp
+++ b/tools/llvm-mca/InstrBuilder.cpp
@@ -196,7 +196,8 @@ static void populateWrites(InstrDesc &ID, const MCInst &MCI,
const MCWriteLatencyEntry &WLE =
*STI.getWriteLatencyEntry(&SCDesc, CurrentDef);
// Conservatively default to MaxLatency.
- Write.Latency = WLE.Cycles == -1 ? ID.MaxLatency : WLE.Cycles;
+ Write.Latency = WLE.Cycles < 0 ? ID.MaxLatency
+ : static_cast<unsigned>(WLE.Cycles);
Write.SClassOrWriteResourceID = WLE.WriteResourceID;
} else {
// Assign a default latency for this write.
@@ -225,7 +226,8 @@ static void populateWrites(InstrDesc &ID, const MCInst &MCI,
const MCWriteLatencyEntry &WLE =
*STI.getWriteLatencyEntry(&SCDesc, Index);
// Conservatively default to MaxLatency.
- Write.Latency = WLE.Cycles == -1 ? ID.MaxLatency : WLE.Cycles;
+ Write.Latency = WLE.Cycles < 0 ? ID.MaxLatency
+ : static_cast<unsigned>(WLE.Cycles);
Write.SClassOrWriteResourceID = WLE.WriteResourceID;
} else {
// Assign a default latency for this write.
diff --git a/tools/llvm-mca/Instruction.cpp b/tools/llvm-mca/Instruction.cpp
index dbf2d5ffecf..53f0d67bf77 100644
--- a/tools/llvm-mca/Instruction.cpp
+++ b/tools/llvm-mca/Instruction.cpp
@@ -41,7 +41,7 @@ void ReadState::writeStartEvent(unsigned Cycles) {
void WriteState::onInstructionIssued() {
assert(CyclesLeft == UNKNOWN_CYCLES);
// Update the number of cycles left based on the WriteDescriptor info.
- CyclesLeft = WD.Latency;
+ CyclesLeft = getLatency();
// Now that the time left before write-back is known, notify
// all the users.
@@ -93,7 +93,7 @@ void ReadState::cycleEvent() {
#ifndef NDEBUG
void WriteState::dump() const {
- dbgs() << "{ OpIdx=" << WD.OpIndex << ", Lat=" << WD.Latency << ", RegID "
+ dbgs() << "{ OpIdx=" << WD.OpIndex << ", Lat=" << getLatency() << ", RegID "
<< getRegisterID() << ", Cycles Left=" << getCyclesLeft() << " }";
}
diff --git a/tools/llvm-mca/Instruction.h b/tools/llvm-mca/Instruction.h
index c2d1761a200..3588fb0ba60 100644
--- a/tools/llvm-mca/Instruction.h
+++ b/tools/llvm-mca/Instruction.h
@@ -28,11 +28,6 @@
namespace mca {
-struct WriteDescriptor;
-struct ReadDescriptor;
-class WriteState;
-class ReadState;
-
constexpr int UNKNOWN_CYCLES = -512;
/// A register write descriptor.
@@ -42,7 +37,7 @@ struct WriteDescriptor {
// a bitwise not of the OpIndex.
int OpIndex;
// Write latency. Number of cycles before write-back stage.
- int Latency;
+ unsigned Latency;
// This field is set to a value different than zero only if this
// is an implicit definition.
unsigned RegisterID;
@@ -81,6 +76,8 @@ struct ReadDescriptor {
bool isImplicitRead() const { return OpIndex < 0; };
};
+class ReadState;
+
/// Tracks uses of a register definition (e.g. register write).
///
/// Each implicit/explicit register write is associated with an instance of
@@ -123,6 +120,7 @@ public:
int getCyclesLeft() const { return CyclesLeft; }
unsigned getWriteResourceID() const { return WD.SClassOrWriteResourceID; }
unsigned getRegisterID() const { return RegisterID; }
+ unsigned getLatency() const { return WD.Latency; }
void addUser(ReadState *Use, int ReadAdvance);
unsigned getNumUsers() const { return Users.size(); }