//== llvm/CodeGen/GlobalISel/LoadStoreOpt.h - LoadStoreOpt -------*- C++ -*-==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // /// This is an optimization pass for GlobalISel generic memory operations. /// Specifically, it focuses on merging stores and loads to consecutive /// addresses. //===----------------------------------------------------------------------===// #ifndef LLVM_CODEGEN_GLOBALISEL_LOADSTOREOPT_H #define LLVM_CODEGEN_GLOBALISEL_LOADSTOREOPT_H #include "llvm/ADT/BitVector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionPass.h" namespace llvm { // Forward declarations. class AnalysisUsage; class GStore; class LegalizerInfo; class MachineBasicBlock; class MachineInstr; class TargetLowering; struct LegalityQuery; class MachineRegisterInfo; namespace GISelAddressing { /// Helper struct to store a base, index and offset that forms an address class BaseIndexOffset { … }; /// Returns a BaseIndexOffset which describes the pointer in \p Ptr. BaseIndexOffset getPointerInfo(Register Ptr, MachineRegisterInfo &MRI); /// Compute whether or not a memory access at \p MI1 aliases with an access at /// \p MI2 \returns true if either alias/no-alias is known. Sets \p IsAlias /// accordingly. bool aliasIsKnownForLoadStore(const MachineInstr &MI1, const MachineInstr &MI2, bool &IsAlias, MachineRegisterInfo &MRI); /// Returns true if the instruction \p MI may alias \p Other. /// This function uses multiple strategies to detect aliasing, whereas /// aliasIsKnownForLoadStore just looks at the addresses of load/stores and is /// tries to reason about base/index/offsets. bool instMayAlias(const MachineInstr &MI, const MachineInstr &Other, MachineRegisterInfo &MRI, AliasAnalysis *AA); } // namespace GISelAddressing usingnamespaceGISelAddressing; class LoadStoreOpt : public MachineFunctionPass { … }; } // End namespace llvm. #endif