32#define DEBUG_TYPE "wasm-replace-phys-regs"
42 return "WebAssembly Replace Physical Registers";
54char WebAssemblyReplacePhysRegs::ID = 0;
56 "Replace physical registers with virtual registers",
false,
60 return new WebAssemblyReplacePhysRegs();
63bool WebAssemblyReplacePhysRegs::runOnMachineFunction(
MachineFunction &MF) {
65 dbgs() <<
"********** Replace Physical Registers **********\n"
66 <<
"********** Function: " << MF.
getName() <<
'\n';
74 "LiveIntervals shouldn't be active yet!");
76 for (
unsigned PReg = WebAssembly::NoRegister + 1;
77 PReg < WebAssembly::NUM_TARGET_REGS; ++PReg) {
79 if (PReg == WebAssembly::VALUE_STACK || PReg == WebAssembly::ARGUMENTS)
84 unsigned VReg = WebAssembly::NoRegister;
87 if (!MO.isImplicit()) {
88 if (VReg == WebAssembly::NoRegister) {
89 VReg =
MRI.createVirtualRegister(RC);
90 if (PReg ==
TRI.getFrameRegister(MF)) {
92 assert(!FI->isFrameBaseVirtual());
93 FI->setFrameBaseVreg(VReg);
95 dbgs() <<
"replacing preg " << PReg <<
" with " << VReg <<
" ("
unsigned const MachineRegisterInfo * MRI
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file provides WebAssembly-specific target descriptions.
This file declares WebAssembly-specific per-machine-function information.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
Represent the analysis usage information of a pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass class - This class is used to implement most global optimizations.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
static unsigned virtReg2Index(Register Reg)
Convert a virtual register number to a 0-based index.
StringRef - Represent a constant reference to a string, i.e.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
FunctionPass * createWebAssemblyReplacePhysRegs()
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
char & LiveIntervalsID
LiveIntervals - This analysis keeps track of the live ranges of virtual and physical registers.