31 #define DEBUG_TYPE "wasm-reg-numbering" 36 return "WebAssembly Register Numbering";
54 "Assigns WebAssembly register numbers for virtual registers",
58 return new WebAssemblyRegNumbering();
61 bool WebAssemblyRegNumbering::runOnMachineFunction(
MachineFunction &MF) {
63 "********** Function: " 78 int64_t Imm =
MI.getOperand(1).getImm();
80 <<
" -> WAReg " << Imm <<
"\n");
81 MFI.setWAReg(
MI.getOperand(0).getReg(), Imm);
88 unsigned NumStackRegs = 0;
90 unsigned CurReg = MFI.getParams().size();
91 for (
unsigned VRegIdx = 0; VRegIdx < NumVRegs; ++VRegIdx) {
94 if (MRI.use_empty(VReg))
97 if (MFI.isVRegStackified(VReg)) {
99 << (INT32_MIN | NumStackRegs) <<
"\n");
100 MFI.setWAReg(VReg, INT32_MIN | NumStackRegs++);
104 LLVM_DEBUG(
dbgs() <<
"VReg " << VReg <<
" -> WAReg " << CurReg <<
"\n");
105 MFI.setWAReg(VReg, CurReg++);
This builds on the llvm/ADT/GraphTraits.h file to find the strongly connected components (SCCs) of a ...
bool isArgument(unsigned Opc)
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.
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.