35#define DEBUG_TYPE "wasm-replace-phys-regs"
45 return "WebAssembly Replace Physical Registers";
57char WebAssemblyReplacePhysRegsLegacy::ID = 0;
59 "Replace physical registers with virtual registers",
false,
63 return new WebAssemblyReplacePhysRegsLegacy();
68 dbgs() <<
"********** Replace Physical Registers **********\n"
69 <<
"********** Function: " << MF.
getName() <<
'\n';
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 <<
" ("
96 <<
Register(VReg).virtRegIndex() <<
")\n";
109bool WebAssemblyReplacePhysRegsLegacy::runOnMachineFunction(
112 "LiveIntervals shouldn't be active yet!");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file provides WebAssembly-specific target descriptions.
This file declares WebAssembly-specific per-machine-function information.
static bool replacePhysRegs(MachineFunction &MF)
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.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
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.
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,...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Represent a constant reference to a string, i.e.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Pass manager infrastructure for declaring and invalidating analyses.
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...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createWebAssemblyReplacePhysRegsLegacyPass()
LLVM_ABI char & LiveIntervalsID
LiveIntervals - This analysis keeps track of the live ranges of virtual and physical registers.
MCRegisterClass TargetRegisterClass