Go to the documentation of this file.
29 #define DEBUG_TYPE "wasm-reg-coloring"
38 return "WebAssembly Register Coloring";
58 "Minimize number of registers used",
false,
false)
61 return new WebAssemblyRegColoring();
75 bool WebAssemblyRegColoring::runOnMachineFunction(
MachineFunction &MF) {
77 dbgs() <<
"********** Register Coloring **********\n"
78 <<
"********** Function: " << MF.
getName() <<
'\n';
91 &getAnalysis<MachineBlockFrequencyInfo>();
97 SortedIntervals.
reserve(NumVRegs);
100 for (
unsigned I = 0;
I < NumVRegs; ++
I) {
112 SortedIntervals.push_back(LI);
133 SortedIntervals.size());
134 BitVector UsedColors(SortedIntervals.size());
135 bool Changed =
false;
136 for (
size_t I = 0,
E = SortedIntervals.size();
I <
E; ++
I) {
138 unsigned Old = LI->
reg();
144 for (
unsigned C : UsedColors.set_bits()) {
148 if (!OtherLI->empty() && OtherLI->overlaps(*LI))
155 unsigned New = SortedIntervals[Color]->reg();
157 Changed |= Old !=
New;
158 UsedColors.set(Color);
159 Assignments[Color].push_back(LI);
170 for (
size_t I = 0,
E = SortedIntervals.size();
I <
E; ++
I) {
171 unsigned Old = SortedIntervals[
I]->reg();
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool exposesReturnsTwice() const
exposesReturnsTwice - Returns true if the function calls setjmp or any other similar functions with a...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void setFrameBaseVreg(unsigned Reg)
FunctionPass * createWebAssemblyRegColoring()
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
(vector float) vec_cmpeq(*A, *B) C
Represent the analysis usage information of a pass.
iterator_range< reg_nodbg_iterator > reg_nodbg_operands(Register Reg) const
MachineOperand class - Representation of each machine instruction operand.
LiveInterval - This class represents the liveness of a register, or stack slot.
bool use_empty(Register RegNo) const
use_empty - Return true if there are no instructions using the specified register.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
This struct contains the mappings from the slot numbers to unnamed metadata nodes,...
bool isVRegStackified(unsigned VReg) const
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
LiveInterval & getInterval(Register Reg)
void setPreservesCFG()
This function should be called by the pass, iff they do not:
StringRef - Represent a constant reference to a string, i.e.
AnalysisUsage & addPreservedID(const void *ID)
if(llvm_vc STREQUAL "") set(fake_version_inc "$
static float computeWeight(const MachineRegisterInfo *MRI, const MachineBlockFrequencyInfo *MBFI, unsigned VReg)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
void setWeight(float Value)
unsigned const MachineRegisterInfo * MRI
void replaceRegWith(Register FromReg, Register ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
INITIALIZE_PASS(WebAssemblyRegColoring, DEBUG_TYPE, "Minimize number of registers used", false, false) FunctionPass *llvm
bool isLiveIn(Register Reg) const
static float getSpillWeight(bool isDef, bool isUse, const MachineBlockFrequencyInfo *MBFI, const MachineInstr &MI)
Calculate the spill weight to assign to a single instruction.
void sort(IteratorTy Start, IteratorTy End)
bool isFrameBaseVirtual() const
char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
FunctionPass class - This class is used to implement most global optimizations.
unsigned getFrameBaseVreg() const
static unsigned virtReg2Index(Register Reg)
Convert a virtual register number to a 0-based index.
AnalysisUsage & addRequired()
void reserve(size_type N)