diff options
| author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-09-24 12:45:26 +0000 |
|---|---|---|
| committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-09-24 12:45:26 +0000 |
| commit | 86502ddeaa6f6a5fb7bd78b4df264012e5d43a4d (patch) | |
| tree | cafcd5520b84579c1551624d3fc8eb4d0edab7be /llvm | |
| parent | 7b39a085d93f9b8d042c0e2aa8733d763efa94f0 (diff) | |
| download | bcm5719-llvm-86502ddeaa6f6a5fb7bd78b4df264012e5d43a4d.tar.gz bcm5719-llvm-86502ddeaa6f6a5fb7bd78b4df264012e5d43a4d.zip | |
[llvm-mca] Improve code comments in LSUnit.{h, cpp}. NFC
llvm-svn: 342877
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/tools/llvm-mca/include/HardwareUnits/LSUnit.h | 28 | ||||
| -rw-r--r-- | llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp | 12 |
2 files changed, 25 insertions, 15 deletions
diff --git a/llvm/tools/llvm-mca/include/HardwareUnits/LSUnit.h b/llvm/tools/llvm-mca/include/HardwareUnits/LSUnit.h index b65f59be685..5f78791b2c5 100644 --- a/llvm/tools/llvm-mca/include/HardwareUnits/LSUnit.h +++ b/llvm/tools/llvm-mca/include/HardwareUnits/LSUnit.h @@ -41,31 +41,31 @@ struct InstrDesc; /// This class optimistically assumes that loads don't alias store operations. /// Under this assumption, younger loads are always allowed to pass older /// stores (this would only affects rule 4). -/// Essentially, this LSUnit doesn't attempt to run any sort alias analysis to -/// predict when loads and stores don't alias with eachother. +/// Essentially, this class doesn't perform any sort alias analysis to +/// identify aliasing loads and stores. /// /// To enforce aliasing between loads and stores, flag `AssumeNoAlias` must be /// set to `false` by the constructor of LSUnit. /// -/// In the case of write-combining memory, rule 2. could be relaxed to allow -/// reordering of non-aliasing store operations. At the moment, this is not -/// allowed. -/// To put it in another way, there is no option to specify a different memory -/// type for memory operations (example: write-through, write-combining, etc.). -/// Also, there is no way to weaken the memory model, and this unit currently -/// doesn't support write-combining behavior. +/// Note that this class doesn't know about the existence of different memory +/// types for memory operations (example: write-through, write-combining, etc.). +/// Derived classes are responsible for implementing that extra knowledge, and +/// provide different sets of rules for loads and stores by overriding method +/// `isReady()`. +/// To emulate a write-combining memory type, rule 2. must be relaxed in a +/// derived class to enable the reordering of non-aliasing store operations. /// -/// No assumptions are made on the size of the store buffer. -/// As mentioned before, this class doesn't perform alias analysis. -/// Consequently, LSUnit doesn't know how to identify cases where -/// store-to-load forwarding may occur. +/// No assumptions are made by this class on the size of the store buffer. This +/// class doesn't know how to identify cases where store-to-load forwarding may +/// occur. /// /// 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 cache hierarchy and memory types. +/// cache hierarchy and memory types. /// It only knows if an instruction "mayLoad" and/or "mayStore". For loads, the /// 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). +/// Derived classes may expand this knowledge. /// /// Class MCInstrDesc in LLVM doesn't know about serializing operations, nor /// memory-barrier like instructions. diff --git a/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp b/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp index b845c5b43fe..aca90165af2 100644 --- a/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp +++ b/llvm/tools/llvm-mca/lib/HardwareUnits/LSUnit.cpp @@ -89,25 +89,32 @@ bool LSUnit::isReady(const InstRef &IR) const { if (IsALoad && !LoadBarriers.empty()) { unsigned LoadBarrierIndex = *LoadBarriers.begin(); + // A younger load cannot pass a older load barrier. if (Index > LoadBarrierIndex) return false; + // A load barrier cannot pass a older load. if (Index == LoadBarrierIndex && Index != *LoadQueue.begin()) return false; } if (IsAStore && !StoreBarriers.empty()) { unsigned StoreBarrierIndex = *StoreBarriers.begin(); + // A younger store cannot pass a older store barrier. if (Index > StoreBarrierIndex) return false; + // A store barrier cannot pass a older store. if (Index == StoreBarrierIndex && Index != *StoreQueue.begin()) 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) return true; 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()) return false; } @@ -123,6 +130,9 @@ bool LSUnit::isReady(const InstRef &IR) const { return true; // There is at least one younger load. + // + // A store may not pass a previous load. + // A load may pass a previous load. return !IsAStore; } |

