1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[llvm-mca] Improve code comments in LSUnit.{h, cpp}. NFC

llvm-svn: 342877
This commit is contained in:
Andrea Di Biagio 2018-09-24 12:45:26 +00:00
parent d5015b6840
commit 3ca5d7eab8
2 changed files with 25 additions and 15 deletions

View File

@ -41,31 +41,31 @@ struct InstrDesc;
/// This class optimistically assumes that loads don't alias store operations. /// This class optimistically assumes that loads don't alias store operations.
/// Under this assumption, younger loads are always allowed to pass older /// Under this assumption, younger loads are always allowed to pass older
/// stores (this would only affects rule 4). /// stores (this would only affects rule 4).
/// Essentially, this LSUnit doesn't attempt to run any sort alias analysis to /// Essentially, this class doesn't perform any sort alias analysis to
/// predict when loads and stores don't alias with eachother. /// identify aliasing loads and stores.
/// ///
/// To enforce aliasing between loads and stores, flag `AssumeNoAlias` must be /// To enforce aliasing between loads and stores, flag `AssumeNoAlias` must be
/// set to `false` by the constructor of LSUnit. /// set to `false` by the constructor of LSUnit.
/// ///
/// In the case of write-combining memory, rule 2. could be relaxed to allow /// Note that this class doesn't know about the existence of different memory
/// reordering of non-aliasing store operations. At the moment, this is not /// types for memory operations (example: write-through, write-combining, etc.).
/// allowed. /// Derived classes are responsible for implementing that extra knowledge, and
/// To put it in another way, there is no option to specify a different memory /// provide different sets of rules for loads and stores by overriding method
/// type for memory operations (example: write-through, write-combining, etc.). /// `isReady()`.
/// Also, there is no way to weaken the memory model, and this unit currently /// To emulate a write-combining memory type, rule 2. must be relaxed in a
/// doesn't support write-combining behavior. /// derived class to enable the reordering of non-aliasing store operations.
/// ///
/// No assumptions are made on the size of the store buffer. /// No assumptions are made by this class on the size of the store buffer. This
/// As mentioned before, this class doesn't perform alias analysis. /// class doesn't know how to identify cases where store-to-load forwarding may
/// Consequently, LSUnit doesn't know how to identify cases where /// occur.
/// store-to-load forwarding may occur.
/// ///
/// LSUnit doesn't attempt to predict whether a load or store hits or misses /// LSUnit doesn't attempt to predict whether a load or store hits or misses
/// the L1 cache. To be more specific, LSUnit doesn't know anything about /// the L1 cache. To be more specific, LSUnit doesn't know anything about
/// the cache hierarchy and memory types. /// cache hierarchy and memory types.
/// It only knows if an instruction "mayLoad" and/or "mayStore". For loads, the /// It only knows if an instruction "mayLoad" and/or "mayStore". For loads, the
/// scheduling model provides an "optimistic" load-to-use latency (which usually /// scheduling model provides an "optimistic" load-to-use latency (which usually
/// matches the load-to-use latency for when there is a hit in the L1D). /// matches the load-to-use latency for when there is a hit in the L1D).
/// Derived classes may expand this knowledge.
/// ///
/// Class MCInstrDesc in LLVM doesn't know about serializing operations, nor /// Class MCInstrDesc in LLVM doesn't know about serializing operations, nor
/// memory-barrier like instructions. /// memory-barrier like instructions.

View File

@ -89,25 +89,32 @@ bool LSUnit::isReady(const InstRef &IR) const {
if (IsALoad && !LoadBarriers.empty()) { if (IsALoad && !LoadBarriers.empty()) {
unsigned LoadBarrierIndex = *LoadBarriers.begin(); unsigned LoadBarrierIndex = *LoadBarriers.begin();
// A younger load cannot pass a older load barrier.
if (Index > LoadBarrierIndex) if (Index > LoadBarrierIndex)
return false; return false;
// A load barrier cannot pass a older load.
if (Index == LoadBarrierIndex && Index != *LoadQueue.begin()) if (Index == LoadBarrierIndex && Index != *LoadQueue.begin())
return false; return false;
} }
if (IsAStore && !StoreBarriers.empty()) { if (IsAStore && !StoreBarriers.empty()) {
unsigned StoreBarrierIndex = *StoreBarriers.begin(); unsigned StoreBarrierIndex = *StoreBarriers.begin();
// A younger store cannot pass a older store barrier.
if (Index > StoreBarrierIndex) if (Index > StoreBarrierIndex)
return false; return false;
// A store barrier cannot pass a older store.
if (Index == StoreBarrierIndex && Index != *StoreQueue.begin()) if (Index == StoreBarrierIndex && Index != *StoreQueue.begin())
return false; return false;
} }
// A load may not pass a previous store unless flag 'NoAlias' is set.
// A load may pass a previous load.
if (NoAlias && IsALoad) if (NoAlias && IsALoad)
return true; return true;
if (StoreQueue.size()) { if (StoreQueue.size()) {
// Check if this memory operation is younger than the older store. // A load may not pass a previous store.
// A store may not pass a previous store.
if (Index > *StoreQueue.begin()) if (Index > *StoreQueue.begin())
return false; return false;
} }
@ -123,6 +130,9 @@ bool LSUnit::isReady(const InstRef &IR) const {
return true; return true;
// There is at least one younger load. // There is at least one younger load.
//
// A store may not pass a previous load.
// A load may pass a previous load.
return !IsAStore; return !IsAStore;
} }