//===--------- HexagonCopyHoisting.cpp - Hexagon Copy Hoisting ----------===// // // 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 // //===----------------------------------------------------------------------===// // The purpose of this pass is to move the copy instructions that are // present in all the successor of a basic block (BB) to the end of BB. //===----------------------------------------------------------------------===// #include "HexagonTargetMachine.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/CodeGen/LiveInterval.h" #include "llvm/CodeGen/LiveIntervals.h" #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #define DEBUG_TYPE … usingnamespacellvm; static cl::opt<std::string> CPHoistFn("cphoistfn", cl::Hidden, cl::desc(""), cl::init("")); namespace llvm { void initializeHexagonCopyHoistingPass(PassRegistry &Registry); FunctionPass *createHexagonCopyHoisting(); } // namespace llvm namespace { class HexagonCopyHoisting : public MachineFunctionPass { … }; } // namespace char HexagonCopyHoisting::ID = …; namespace llvm { char &HexagonCopyHoistingID = …; } // namespace llvm bool HexagonCopyHoisting::runOnMachineFunction(MachineFunction &Fn) { … } //===----------------------------------------------------------------------===// // Save all COPY instructions for each basic block in CopyMIList vector. //===----------------------------------------------------------------------===// void HexagonCopyHoisting::collectCopyInst() { … } void HexagonCopyHoisting::addMItoCopyList(MachineInstr *MI) { … } //===----------------------------------------------------------------------===// // Look at the COPY instructions of all the successors of BB. If the same // instruction is present in every successor and can be safely moved, // pull it into BB. //===----------------------------------------------------------------------===// bool HexagonCopyHoisting::analyzeCopy(MachineBasicBlock *BB) { … } bool HexagonCopyHoisting::isSafetoMove(MachineInstr *CandMI) { … } void HexagonCopyHoisting::moveCopyInstr(MachineBasicBlock *DestBB, std::pair<Register, Register> Key, MachineInstr *MI) { … } //===----------------------------------------------------------------------===// // Public Constructor Functions //===----------------------------------------------------------------------===// INITIALIZE_PASS(…) FunctionPass *llvm::createHexagonCopyHoisting() { … }