Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:42

0001 //===- MergedLoadStoreMotion.h - merge and hoist/sink load/stores ---------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 //! \file
0010 //! This pass performs merges of loads and stores on both sides of a
0011 //  diamond (hammock). It hoists the loads and sinks the stores.
0012 //
0013 // The algorithm iteratively hoists two loads to the same address out of a
0014 // diamond (hammock) and merges them into a single load in the header. Similar
0015 // it sinks and merges two stores to the tail block (footer). The algorithm
0016 // iterates over the instructions of one side of the diamond and attempts to
0017 // find a matching load/store on the other side. It hoists / sinks when it
0018 // thinks it safe to do so.  This optimization helps with eg. hiding load
0019 // latencies, triggering if-conversion, and reducing static code size.
0020 //
0021 //===----------------------------------------------------------------------===//
0022 
0023 #ifndef LLVM_TRANSFORMS_SCALAR_MERGEDLOADSTOREMOTION_H
0024 #define LLVM_TRANSFORMS_SCALAR_MERGEDLOADSTOREMOTION_H
0025 
0026 #include "llvm/ADT/STLFunctionalExtras.h"
0027 #include "llvm/IR/PassManager.h"
0028 
0029 namespace llvm {
0030 class Function;
0031 struct MergedLoadStoreMotionOptions {
0032   bool SplitFooterBB;
0033   MergedLoadStoreMotionOptions(bool SplitFooterBB = false)
0034       : SplitFooterBB(SplitFooterBB) {}
0035 
0036   MergedLoadStoreMotionOptions &splitFooterBB(bool SFBB) {
0037     SplitFooterBB = SFBB;
0038     return *this;
0039   }
0040 };
0041 
0042 class MergedLoadStoreMotionPass
0043     : public PassInfoMixin<MergedLoadStoreMotionPass> {
0044   MergedLoadStoreMotionOptions Options;
0045 
0046 public:
0047   MergedLoadStoreMotionPass()
0048       : MergedLoadStoreMotionPass(MergedLoadStoreMotionOptions()) {}
0049   MergedLoadStoreMotionPass(const MergedLoadStoreMotionOptions &PassOptions)
0050       : Options(PassOptions) {}
0051   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
0052   void printPipeline(raw_ostream &OS,
0053                      function_ref<StringRef(StringRef)> MapClassName2PassName);
0054 };
0055 }
0056 
0057 #endif // LLVM_TRANSFORMS_SCALAR_MERGEDLOADSTOREMOTION_H