LLVM: lib/Target/WebAssembly/WebAssemblyRegStackify.cpp File Reference (original) (raw)
This file implements a register stacking pass. More...
Go to the source code of this file.
This file implements a register stacking pass.
This pass reorders instructions to put register uses and defs in an order such that they form single-use expression trees. Registers fitting this form are then marked as "stackified", meaning references to them are replaced by "push" and "pop" from the value stack.
This is primarily a code size optimization, since temporary values on the value stack don't need to be named.
Definition in file WebAssemblyRegStackify.cpp.
◆ DEBUG_TYPE
#define DEBUG_TYPE "wasm-reg-stackify"
◆ convertImplicitDefToConstZero()
Definition at line 96 of file WebAssemblyRegStackify.cpp.
References assert(), llvm::MachineOperand::CreateFPImm(), llvm::MachineOperand::CreateImm(), llvm::Function::getContext(), llvm::Type::getDoubleTy(), llvm::Type::getFloatTy(), llvm::MachineFunction::getFunction(), llvm::Constant::getNullValue(), llvm_unreachable, MI, MRI, and TII.
◆ getPrevNonDebugInst()
◆ getTeeOpcode()
◆ getVRegDef()
◆ hasOneNonDBGUse()
◆ imposeStackOrdering()
◆ INITIALIZE_PASS()
◆ isSafeToMove()
Definition at line 311 of file WebAssemblyRegStackify.cpp.
References assert(), D, llvm::MachineInstr::defs(), llvm::drop_begin(), llvm::SmallVectorBase< Size_T >::empty(), llvm::MachineBasicBlock::end(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getParent(), I, llvm::WebAssembly::isCatch(), MBB, MRI, llvm::MachineInstr::operands(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), query(), llvm::Read, and llvm::Write.
◆ moveAndTeeForMultiUse()
A multiple-use def in the same block with no intervening memory or register dependencies; move the def down, nest it with the current instruction, and insert a tee to satisfy the rest of the uses.
As an illustration, rewrite this:
Reg = INST ... // Def INST ..., Reg, ... // Insert INST ..., Reg, ... INST ..., Reg, ...
to this:
DefReg = INST ... // Def (to become the new Insert) TeeReg, Reg = TEE_... DefReg INST ..., TeeReg, ... // Insert INST ..., Reg, ... INST ..., Reg, ...
with DefReg and TeeReg stackified. This eliminates a local.get from the resulting code.
Definition at line 633 of file WebAssemblyRegStackify.cpp.
References llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), llvm::WebAssemblyDebugValueManager::cloneSink(), llvm::LiveIntervals::createAndComputeVirtRegInterval(), llvm::dbgs(), llvm::VNInfo::def, llvm::RegState::Define, llvm::MachineInstr::dump(), llvm::LiveRange::FindSegmentContaining(), llvm::LiveIntervals::getInstructionIndex(), llvm::LiveIntervals::getInterval(), llvm::SlotIndex::getRegSlot(), getTeeOpcode(), llvm::getUndefRegState(), llvm::LiveRange::getVNInfoAt(), llvm::LiveIntervals::handleMove(), I, imposeStackOrdering(), llvm::LiveIntervals::InsertMachineInstrInMaps(), llvm::MachineOperand::isDead(), LLVM_DEBUG, MBB, MRI, shrinkToUses(), llvm::WebAssemblyDebugValueManager::sink(), llvm::WebAssemblyFunctionInfo::stackifyVReg(), TII, and llvm::WebAssemblyDebugValueManager::updateReg().
◆ moveForSingleUse()
A single-use def in the same block with no intervening memory or register dependencies; move the def down and nest it with the current instruction.
Definition at line 521 of file WebAssemblyRegStackify.cpp.
References llvm::LiveIntervals::createAndComputeVirtRegInterval(), llvm::dbgs(), llvm::LiveIntervals::getInstructionIndex(), llvm::LiveIntervals::getInterval(), llvm::SlotIndex::getRegSlot(), llvm::LiveIntervals::handleMove(), imposeStackOrdering(), LLVM_DEBUG, MRI, llvm::LiveRange::removeSegment(), llvm::WebAssemblyDebugValueManager::sink(), llvm::WebAssemblyFunctionInfo::stackifyVReg(), and llvm::WebAssemblyDebugValueManager::updateReg().
◆ oneUseDominatesOtherUses()
Test whether OneUse, a use of Reg, dominates all of Reg's other uses.
Definition at line 433 of file WebAssemblyRegStackify.cpp.
References assert(), llvm::MachineDominatorTree::dominates(), llvm::MachineInstr::getDesc(), llvm::LiveIntervals::getInstructionIndex(), llvm::LiveIntervals::getInterval(), llvm::MCInstrDesc::getNumDefs(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getParent(), llvm::MachineOperand::getReg(), llvm::LiveRange::getVNInfoBefore(), llvm::MachineOperand::isReg(), llvm::Register::isVirtual(), llvm::WebAssemblyFunctionInfo::isVRegStackified(), and MRI.
◆ query()
◆ queryCallee()
◆ rematerializeCheapDef()
A trivially cloneable instruction; clone it and nest the new copy with the current instruction.
Definition at line 570 of file WebAssemblyRegStackify.cpp.
References assert(), llvm::WebAssemblyDebugValueManager::cloneSink(), llvm::LiveIntervals::createAndComputeVirtRegInterval(), llvm::dbgs(), llvm::MachineInstr::dump(), llvm::dump(), llvm::MCRegister::from(), llvm::SlotIndex::getDeadSlot(), llvm::LiveIntervals::getInstructionIndex(), llvm::LiveIntervals::getInterval(), getPrevNonDebugInst(), llvm::SlotIndex::getRegSlot(), Idx, imposeStackOrdering(), llvm::LiveIntervals::InsertMachineInstrInMaps(), IsDead, llvm::LiveRange::liveAt(), LLVM_DEBUG, MRI, llvm::WebAssemblyDebugValueManager::removeDef(), llvm::LiveIntervals::removeInterval(), llvm::LiveIntervals::RemoveMachineInstrFromMaps(), llvm::LiveIntervals::removePhysRegDefAt(), shrinkToUses(), and llvm::WebAssemblyFunctionInfo::stackifyVReg().