|
| 1 | +//===- Spill2Reg.cpp - Spill To Register Optimization ---------------------===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +// |
| 9 | +// |
| 10 | +/// \file This file implements Spill2Reg, an optimization which selectively |
| 11 | +/// replaces spills/reloads to/from the stack with register copies to/from the |
| 12 | +/// vector register file. This works even on targets where load/stores have |
| 13 | +/// similar latency to register copies because it can free up memory units which |
| 14 | +/// helps avoid back-end stalls. |
| 15 | +/// |
| 16 | +//===----------------------------------------------------------------------===// |
| 17 | + |
| 18 | +#include "llvm/CodeGen/MachineFunctionPass.h" |
| 19 | +#include "llvm/CodeGen/Passes.h" |
| 20 | +#include "llvm/InitializePasses.h" |
| 21 | +#include "llvm/Support/CommandLine.h" |
| 22 | + |
| 23 | +using namespace llvm; |
| 24 | + |
| 25 | +namespace { |
| 26 | + |
| 27 | +class Spill2Reg : public MachineFunctionPass { |
| 28 | +public: |
| 29 | + static char ID; |
| 30 | + Spill2Reg() : MachineFunctionPass(ID) { |
| 31 | + initializeSpill2RegPass(*PassRegistry::getPassRegistry()); |
| 32 | + } |
| 33 | + void getAnalysisUsage(AnalysisUsage &AU) const override; |
| 34 | + void releaseMemory() override; |
| 35 | + bool runOnMachineFunction(MachineFunction &) override; |
| 36 | +}; |
| 37 | + |
| 38 | +} // namespace |
| 39 | + |
| 40 | +void Spill2Reg::getAnalysisUsage(AnalysisUsage &AU) const { |
| 41 | + AU.setPreservesCFG(); |
| 42 | + MachineFunctionPass::getAnalysisUsage(AU); |
| 43 | +} |
| 44 | + |
| 45 | +void Spill2Reg::releaseMemory() {} |
| 46 | + |
| 47 | +bool Spill2Reg::runOnMachineFunction(MachineFunction &MFn) { |
| 48 | + llvm_unreachable("Unimplemented"); |
| 49 | +} |
| 50 | + |
| 51 | +char Spill2Reg::ID = 0; |
| 52 | + |
| 53 | +char &llvm::Spill2RegID = Spill2Reg::ID; |
| 54 | + |
| 55 | +INITIALIZE_PASS_BEGIN(Spill2Reg, "spill2reg", "Spill2Reg", false, false) |
| 56 | +INITIALIZE_PASS_END(Spill2Reg, "spill2reg", "Spill2Reg", false, false) |
0 commit comments