Skip to content

[MCA] Extend -instruction-tables option with verbosity levels #130574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion llvm/docs/CommandGuide/llvm-mca.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,32 @@ option specifies "``-``", then the output will also be sent to standard output.

Enable all the view.

.. option:: -instruction-tables
.. option:: -instruction-tables=<level>

Prints resource pressure information based on the static information
available from the processor model. This differs from the resource pressure
view because it doesn't require that the code is simulated. It instead prints
the theoretical uniform distribution of resource pressure for every
instruction in sequence.

The choice of `<level>` controls number of printed information.
`<level>` may be `none` (default), `normal`, `full`.
Note: If the option is used without `<label>`, default is `normal` (legacy).

When `<level>` is `full`, additional information are:
- `<Bypass Latency>`: Latency when a bypass is implemented between operands
in pipelines (see SchedReadAdvance).
- `<LLVM Opcode Name>`: mnemonic plus operands identifier.
- `<Resources units>`: Used resources associated with LLVM Opcode.
- `<instruction comment>`: reports comment if any from source assembly.

`<Resources units>` syntax can be:
- <Resource Name>: ReleaseAtCycle is 1.
- <Resource Name>[<ReleaseAtCycle>]: ReleaseAtCycle is greater than 1
and AcquireAtCycle is 0.
- <Resource Name>[<AcquireAtCycle>,<ReleaseAtCycle>]: ReleaseAtCycle
is greater than 1 and AcquireAtCycle is greater than 0.

.. option:: -bottleneck-analysis

Print information about bottlenecks that affect the throughput. This analysis
Expand Down
4 changes: 4 additions & 0 deletions llvm/include/llvm/MC/MCSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ struct MCSchedModel {
static unsigned getForwardingDelayCycles(ArrayRef<MCReadAdvanceEntry> Entries,
unsigned WriteResourceIdx = 0);

/// Returns the bypass delay cycle for the maximum latency write cycle
static unsigned getBypassDelayCycles(const MCSubtargetInfo &STI,
const MCSchedClassDesc &SCDesc);

/// Returns the default initialized model.
static const MCSchedModel Default;
};
Expand Down
34 changes: 34 additions & 0 deletions llvm/lib/MC/MCSchedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,37 @@ MCSchedModel::getForwardingDelayCycles(ArrayRef<MCReadAdvanceEntry> Entries,

return std::abs(DelayCycles);
}

unsigned MCSchedModel::getBypassDelayCycles(const MCSubtargetInfo &STI,
const MCSchedClassDesc &SCDesc) {

ArrayRef<MCReadAdvanceEntry> Entries = STI.getReadAdvanceEntries(SCDesc);
if (Entries.empty())
return 0;

unsigned MaxLatency = 0;
unsigned WriteResourceID = 0;
unsigned DefEnd = SCDesc.NumWriteLatencyEntries;

for (unsigned DefIdx = 0; DefIdx != DefEnd; ++DefIdx) {
// Lookup the definition's write latency in SubtargetInfo.
const MCWriteLatencyEntry *WLEntry =
STI.getWriteLatencyEntry(&SCDesc, DefIdx);
unsigned Cycles = 0;
// If latency is Invalid (<0), consider 0 cycle latency
if (WLEntry->Cycles > 0)
Cycles = (unsigned)WLEntry->Cycles;
if (Cycles > MaxLatency) {
MaxLatency = Cycles;
WriteResourceID = WLEntry->WriteResourceID;
}
}

for (const MCReadAdvanceEntry &E : Entries) {
if (E.WriteResourceID == WriteResourceID)
return E.Cycles;
}

// Unable to find WriteResourceID in MCReadAdvanceEntry Entries
return 0;
}
4,958 changes: 2,491 additions & 2,467 deletions llvm/test/tools/llvm-mca/AArch64/Neoverse/V1-sve-instructions.s

Large diffs are not rendered by default.

Loading
Loading