This is an archive of the discontinued LLVM Phabricator instance.

[MCSchedule] Add the ability to correctly compute the latency and throughput information for MCInst.
ClosedPublic

Authored by andreadb on May 30 2018, 8:08 AM.

Details

Summary

This patch is required by D47374. to avoid regressing a couple of (x86 btver2 specific) -print-schedule tests.

Scheduling models have recently gained the ability to resolve variant scheduling classes associated with MCInst objects. Before, models were only able to resolve a variant scheduling class from a MachineInstr object.

Patch D47374 exposes that new knowledge to llvm-mca; it also teaches to the x86 target (model btver2) how to correctly compute the latency profile for the so-called "zero latency vector xor idioms".
However, before D47374 is committed, we need to apply some changes to the scheduling model.
This patch extends the MCSchedModel API with new methods that can be used to obtain the latency and reciprocal througput information from an MCInst. These new methods are meant to be used by llc when flag -print-schedule is specified. There are cases where tests contain inline assembly blocks. Inline assembly is parsed end emitted as a sequence of MCInst by the assembly printer. That means, the print-schedule functionality must be able to query the latency/rthroughput associated with MCInst too.
If we don't do this, then we would start losing "-print-schedule" test coverage as soon as the new xor idioms introduced by D47374.

The tablegen SubtargetEmitter changes are required to teach the TargetSubtargetInfo object how to query the latency profile of an MCInst. Note that this should really have been part of patch 2/3 (i.e. r333286). To avoid code duplication, the logic that knows how to "resolve" a variant scheduling classes from a MCInst, is moved to a common place in MC. That logic is shared by the new "resolveVariantSchedClass" methods redefined in override by the tablegen'd GenSubtargetInfo classes.

Please let me know if okay to commit.

Thanks,
Andrea

Diff Detail

Repository
rL LLVM

Event Timeline

andreadb created this revision.May 30 2018, 8:08 AM
RKSimon accepted this revision.May 31 2018, 5:30 AM

LGTM - thanks for the explanation @andreadb

This revision is now accepted and ready to land.May 31 2018, 5:30 AM
This revision was automatically updated to reflect the committed changes.