//===-- WebAssemblyReplacePhysRegs.cpp - Replace phys regs with virt regs -===// // // 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 // //===----------------------------------------------------------------------===// /// /// \file /// This file implements a pass that replaces physical registers with /// virtual registers. /// /// LLVM expects certain physical registers, such as a stack pointer. However, /// WebAssembly doesn't actually have such physical registers. This pass is run /// once LLVM no longer needs these registers, and replaces them with virtual /// registers, so they can participate in register stackifying and coloring in /// the normal way. /// //===----------------------------------------------------------------------===// #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" #include "WebAssembly.h" #include "WebAssemblyMachineFunctionInfo.h" #include "WebAssemblySubtarget.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … namespace { class WebAssemblyReplacePhysRegs final : public MachineFunctionPass { … }; } // end anonymous namespace char WebAssemblyReplacePhysRegs::ID = …; INITIALIZE_PASS(…) FunctionPass *llvm::createWebAssemblyReplacePhysRegs() { … } bool WebAssemblyReplacePhysRegs::runOnMachineFunction(MachineFunction &MF) { … }