32 #define DEBUG_TYPE "wasm-reg-numbering" 37 return "WebAssembly Register Numbering";
55 "Assigns WebAssembly register numbers for virtual registers",
59 return new WebAssemblyRegNumbering();
62 bool WebAssemblyRegNumbering::runOnMachineFunction(
MachineFunction &MF) {
64 "********** Function: " 79 int64_t Imm =
MI.getOperand(1).getImm();
81 <<
" -> WAReg " << Imm <<
"\n");
82 MFI.setWAReg(
MI.getOperand(0).getReg(), Imm);
89 unsigned NumStackRegs = 0;
91 unsigned CurReg = MFI.getParams().size();
92 for (
unsigned VRegIdx = 0; VRegIdx < NumVRegs; ++VRegIdx) {
95 if (MRI.use_empty(VReg))
98 if (MFI.isVRegStackified(VReg)) {
100 << (INT32_MIN | NumStackRegs) <<
"\n");
101 MFI.setWAReg(VReg, INT32_MIN | NumStackRegs++);
105 LLVM_DEBUG(
dbgs() <<
"VReg " << VReg <<
" -> WAReg " << CurReg <<
"\n");
106 MFI.setWAReg(VReg, CurReg++);
This builds on the llvm/ADT/GraphTraits.h file to find the strongly connected components (SCCs) of a ...
This class represents lattice values for constants.
static unsigned index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
FunctionPass * createWebAssemblyRegNumbering()
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
This file contains the declaration of the WebAssembly-specific utility functions. ...
unsigned const MachineRegisterInfo * MRI
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
This file provides WebAssembly-specific target descriptions.
Represent the analysis usage information of a pass.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
FunctionPass class - This class is used to implement most global optimizations.
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
static const unsigned UnusedReg
const MachineBasicBlock & front() const
This file declares the WebAssembly-specific subclass of TargetSubtarget.
bool isArgument(const MachineInstr &MI)
void setPreservesCFG()
This function should be called by the pass, iff they do not:
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
This file declares WebAssembly-specific per-machine-function information.
INITIALIZE_PASS(WebAssemblyRegNumbering, DEBUG_TYPE, "Assigns WebAssembly register numbers for virtual registers", false, false) FunctionPass *llvm
StringRef - Represent a constant reference to a string, i.e.