LLVM 22.0.0git
llvm::Register Class Reference

Wrapper class representing virtual and physical registers. More...

#include "llvm/CodeGen/Register.h"

Public Member Functions

constexpr Register (unsigned Val=0)
constexpr Register (MCRegister Val)
constexpr bool isStack () const
 Return true if this is a stack slot.
constexpr bool isVirtual () const
 Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical () const
 Return true if the specified register number is in the physical register namespace.
unsigned virtRegIndex () const
 Convert a virtual register number to a 0-based index.
int stackSlotIndex () const
 Compute the frame index from a register value representing a stack slot.
constexpr operator unsigned () const
constexpr unsigned id () const
constexpr operator MCRegister () const
MCRegister asMCReg () const
 Utility to check-convert this value to a MCRegister.
constexpr bool isValid () const
constexpr bool operator== (const Register &Other) const
 Comparisons between register objects.
constexpr bool operator!= (const Register &Other) const
constexpr bool operator== (const MCRegister &Other) const
constexpr bool operator!= (const MCRegister &Other) const
constexpr bool operator== (unsigned Other) const
 Comparisons against register constants.
constexpr bool operator!= (unsigned Other) const
constexpr bool operator== (int Other) const
constexpr bool operator!= (int Other) const
constexpr bool operator== (MCPhysReg Other) const
constexpr bool operator!= (MCPhysReg Other) const
Registeroperator++ ()
 Operators to move from one register to another nearby register by adding an offset.
Register operator++ (int)
Registeroperator+= (unsigned RHS)

Static Public Member Functions

static Register index2StackSlot (int FI)
 Convert a non-negative frame index to a stack slot register value.
static constexpr bool isPhysicalRegister (unsigned Reg)
 Return true if the specified register number is in the physical register namespace.
static constexpr bool isVirtualRegister (unsigned Reg)
 Return true if the specified register number is in the virtual register namespace.
static Register index2VirtReg (unsigned Index)
 Convert a 0-based index to a virtual register number.

Static Public Attributes

static constexpr unsigned MaxFrameIndexBitwidth = 30
static constexpr unsigned StackSlotZero = 1u << MaxFrameIndexBitwidth
static constexpr const unsigned StackSlotMask = StackSlotZero - 1
static constexpr unsigned VirtualRegFlag = 1u << 31

Detailed Description

Wrapper class representing virtual and physical registers.

Should be passed by value.

Definition at line 20 of file Register.h.

Constructor & Destructor Documentation

◆ Register() [1/2]

llvm::Register::Register ( unsigned Val = 0)
inlineconstexpr

◆ Register() [2/2]

llvm::Register::Register ( MCRegister Val)
inlineconstexpr

Definition at line 25 of file Register.h.

References id().

Member Function Documentation

◆ asMCReg()

◆ id()

◆ index2StackSlot()

Register llvm::Register::index2StackSlot ( int FI)
inlinestatic

Convert a non-negative frame index to a stack slot register value.

Definition at line 51 of file Register.h.

References assert(), llvm::isInt(), Register(), Register, StackSlotMask, and StackSlotZero.

Referenced by llvm::LiveStacks::getOrCreateInterval(), llvm::rdf::PhysicalRegisterInfo::getRegMaskId(), and llvm::ReachingDefInfo::print().

◆ index2VirtReg()

◆ isPhysical()

bool llvm::Register::isPhysical ( ) const
inlineconstexpr

Return true if the specified register number is in the physical register namespace.

Definition at line 83 of file Register.h.

References isPhysicalRegister().

Referenced by llvm::DwarfExpression::addMachineReg(), llvm::MachineInstr::addRegisterDead(), llvm::MachineInstr::addRegisterKilled(), llvm::AnalyzePhysRegInBundle(), asMCReg(), canFoldCopy(), llvm::canReplaceReg(), llvm::X86InstrInfo::classifyLEAReg(), collectRegDefs(), llvm::TargetInstrInfo::commuteInstructionImpl(), llvm::TargetRegisterClass::contains(), llvm::X86InstrInfo::describeLoadedValue(), llvm::SIRegisterInfo::eliminateFrameIndex(), llvm::GIMatchTableExecutor::executeMatchTable(), llvm::MachineInstr::findRegisterDefOperandIdx(), llvm::SIInstrInfo::foldImmediate(), llvm::X86InstrInfo::foldMemoryOperandImpl(), foldVGPRCopyIntoRegSequence(), llvm::BitTracker::MachineEvaluator::getCell(), llvm::AArch64RegisterBankInfo::getInstrMapping(), llvm::SIInstrInfo::getInstructionUniformity(), getMopState(), llvm::HexagonInstrInfo::getOperandLatency(), llvm::ARMBaseRegisterInfo::getRegAllocationHints(), llvm::RISCVRegisterInfo::getRegAllocationHints(), llvm::SIRegisterInfo::getRegAllocationHints(), llvm::SystemZRegisterInfo::getRegAllocationHints(), llvm::TargetRegisterInfo::getRegAllocationHints(), llvm::X86RegisterInfo::getRegAllocationHints(), llvm::BitTracker::MachineEvaluator::getRegBitWidth(), llvm::getRegState(), llvm::X86InstrInfo::getUndefRegClearance(), INITIALIZE_PASS(), isIdenticalOp(), isLibCallInTailPosition(), isLocalCopy(), isMatchingStartStopPair(), isPhysical(), llvm::SITargetLowering::legalizeTargetIndependentNode(), llvm::ARMBaseInstrInfo::loadRegFromStackSlot(), llvm::Thumb1InstrInfo::loadRegFromStackSlot(), llvm::Thumb2InstrInfo::loadRegFromStackSlot(), loadRegPairFromStackSlot(), lookUpCopyChain(), llvm::TargetInstrInfo::lowerCopy(), MIIsInTerminatorSequence(), llvm::SIInstrInfo::moveToVALUImpl(), llvm::SIInstrInfo::optimizeCompareInstr(), llvm::X86InstrInfo::optimizeCompareInstr(), llvm::PeelSingleBlockLoop(), llvm::TargetRegisterInfo::regsOverlap(), llvm::MachineRegisterInfo::replaceRegWith(), selectCopy(), selectCopy(), selectCopy(), storeRegPairToStackSlot(), llvm::Thumb1InstrInfo::storeRegToStackSlot(), llvm::MachineInstr::substituteRegister(), and llvm::SIInstrInfo::verifyInstruction().

◆ isPhysicalRegister()

constexpr bool llvm::Register::isPhysicalRegister ( unsigned Reg)
inlinestaticconstexpr

◆ isStack()

bool llvm::Register::isStack ( ) const
inlineconstexpr

Return true if this is a stack slot.

Definition at line 46 of file Register.h.

References StackSlotZero, and VirtualRegFlag.

Referenced by stackSlotIndex().

◆ isValid()

bool llvm::Register::isValid ( ) const
inlineconstexpr

Definition at line 112 of file Register.h.

References llvm::MCRegister::NoRegister.

Referenced by addConstantsToTrack(), llvm::GISelAddressing::aliasIsKnownForLoadStore(), asMCReg(), llvm::HexagonFrameLowering::assignCalleeSavedSpillSlots(), llvm::buildAtomicCompareExchangeInst(), llvm::buildBarrierInst(), llvm::SPIRVGlobalRegistry::buildConstantFP(), llvm::SPIRVGlobalRegistry::buildConstantInt(), llvm::SPIRVGlobalRegistry::buildConstantSampler(), llvm::buildMemSemanticsReg(), llvm::buildNDRange(), llvm::buildScopeReg(), llvm::LegalizerHelper::buildVariableShiftPart(), llvm::AArch64TargetLowering::changeStreamingMode(), llvm::X86InstrInfo::classifyLEAReg(), llvm::WebAssemblyDebugValueManager::cloneSink(), copySubReg(), describeORRLoadedValue(), llvm::SIRegisterInfo::eliminateFrameIndex(), llvm::X86FrameLowering::emitEpilogue(), llvm::HexagonDAGToDAGISel::emitFunctionEntryCode(), llvm::X86FrameLowering::emitPrologue(), findLoopIncrementValue(), generateAssignInstrs(), llvm::generateGroupInst(), llvm::SIInstrInfo::getAddNoCarry(), llvm::SPIRVGlobalRegistry::getOrCreateConstNullPtr(), llvm::SPIRVGlobalRegistry::getOrCreateUndef(), llvm::X86TargetLowering::getRegForInlineAsmConstraint(), llvm::HexagonRegisterInfo::getReservedRegs(), getTestBitReg(), getTruncStoreByteOffset(), INITIALIZE_PASS(), llvm::RISCVInstrInfo::insertIndirectBranch(), insertInlineAsmProcess(), isCandidate(), llvm::AMDGPULegalizerInfo::legalizeAddrSpaceCast(), llvm::AArch64InstrInfo::loadRegFromStackSlot(), llvm::SPIRVCallLowering::lowerCall(), llvm::PhiLoweringHelper::lowerPhis(), llvm::CombinerHelper::matchCombineAnyExtTrunc(), llvm::CombinerHelper::matchHoistLogicOpWithSameOpcodeHands(), operator++(), operator+=(), popRegsFromStack(), and processNewInstrs().

◆ isVirtual()

bool llvm::Register::isVirtual ( ) const
inlineconstexpr

Return true if the specified register number is in the virtual register namespace.

Definition at line 79 of file Register.h.

References isVirtualRegister().

Referenced by llvm::MachineRegisterInfo::addRegAllocationHint(), llvm::Combiner::WorkListMaintainerImpl< Lvl >::addUsersToWorkList(), llvm::RegisterOperands::adjustLaneLiveness(), llvm::RegAllocBase::allocatePhysRegs(), llvm::VirtRegMap::assignVirt2Phys(), llvm::VirtRegMap::assignVirt2StackSlot(), llvm::VirtRegMap::assignVirt2StackSlot(), attemptDebugCopyProp(), llvm::SIInstrInfo::buildExtractSubReg(), llvm::AMDGPULegalizerInfo::buildLoadInputValue(), canCombine(), canCombine(), canCombine(), canCombineFPFusedMultiply(), canFoldCopy(), llvm::AArch64InstrInfo::canFoldIntoAddrMode(), llvm::X86InstrInfo::classifyLEAReg(), llvm::VirtRegMap::clearVirt(), cloneInstr(), llvm::PPCInstrInfo::combineRLWINM(), llvm::TargetInstrInfo::commuteInstructionImpl(), llvm::GISelValueTracking::computeKnownBitsImpl(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), llvm::VirtRegAuxInfo::copyHint(), llvm::WebAssemblyInstrInfo::copyPhysReg(), llvm::ARMBaseRegisterInfo::eliminateFrameIndex(), llvm::WebAssemblyRegisterInfo::eliminateFrameIndex(), llvm::R600TargetLowering::EmitInstrWithCustomInserter(), llvm::ThumbRegisterInfo::emitLoadConstPool(), llvm::PPCTargetLowering::EmitPartwordAtomicBinary(), emitPseudoXVINSGR2VR(), emitThumbRegPlusImmInReg(), llvm::FastISel::fastEmitInst_extractsubreg(), findLoopIncrementValue(), findRedundantFlagInstr(), llvm::SIInstrInfo::foldImmediate(), llvm::SystemZInstrInfo::foldImmediate(), llvm::AArch64InstrInfo::foldMemoryOperandImpl(), llvm::SIInstrInfo::foldMemoryOperandImpl(), llvm::SystemZInstrInfo::foldMemoryOperandImpl(), genFNegatedMAD(), genFusedMultiply(), genMaddR(), getCallTargetRegOpnd(), llvm::BitTracker::MachineEvaluator::getCell(), getCopyRegClasses(), getDefRegMask(), llvm::NVPTXRegisterInfo::getDwarfRegNumForVirtReg(), getEffectiveImm(), llvm::PPCInstrInfo::getFMAPatterns(), getFMULPatterns(), llvm::MachineInstrExpressionTrait::getHashValue(), getIndVarInfo(), llvm::AMDGPURegisterBankInfo::getInstrMapping(), getLanesWithProperty(), getLanesWithProperty(), llvm::SIInstrInfo::getLiveRangeSplitOpcode(), llvm::VirtRegMap::getPhys(), llvm::MachineRegisterInfo::getRegAllocationHint(), llvm::MachineRegisterInfo::getRegAllocationHints(), llvm::PPCRegisterInfo::getRegAllocationHints(), llvm::TargetRegisterInfo::getRegAllocationHints(), llvm::BitTracker::MachineEvaluator::getRegBitWidth(), llvm::VirtRegMap::getShape(), llvm::MachineRegisterInfo::getSimpleHint(), llvm::VirtRegMap::getStackSlot(), llvm::getVRegSubRegDef(), hasAllNBitUsers(), hasAllNBitUsers(), llvm::RISCVInstrInfo::hasReassociableOperands(), llvm::TargetInstrInfo::hasReassociableOperands(), hasSameValue(), INITIALIZE_PASS(), llvm::RegPressureTracker::initLiveThru(), llvm::AArch64InstrInfo::insertSelect(), isAGPRCopy(), llvm::WebAssembly::isChild(), isCopyFeedingInvariantStore(), llvm::MachineInstr::isIdenticalTo(), isLibCallInTailPosition(), llvm::TargetInstrInfo::isReMaterializableImpl(), isSignExtendedW(), isSignExtendedW(), isTileRegDef(), isVirtualRegisterOperand(), IsWritingToVCCR(), llvm::SIInstrInfo::legalizeOperands(), llvm::AArch64InstrInfo::loadRegFromStackSlot(), llvm::SIInstrInfo::loadRegFromStackSlot(), llvm::Thumb2InstrInfo::loadRegFromStackSlot(), llvm::TargetRegisterInfo::lookThruCopyLike(), llvm::TargetRegisterInfo::lookThruSingleUseCopyChain(), llvm::LiveDebugVariables::LDVImpl::mapVirtReg(), MatchingStackOffset(), llvm::SwingSchedulerDAG::mayOverlapInLaterIter(), llvm::BitTracker::RegisterCell::meet(), llvm::SIInstrInfo::moveToVALUImpl(), oneUseDominatesOtherUses(), llvm::PPCInstrInfo::optimizeCompareInstr(), llvm::AArch64InstrInfo::optimizeCondBranch(), llvm::Thumb2InstrInfo::optimizeSelect(), llvm::ARMBaseInstrInfo::produceSameValue(), llvm::PPCInstrInfo::promoteInstr32To64ForElimEXTSW(), llvm::PSetIterator::PSetIterator(), llvm::BitTracker::MachineEvaluator::putCell(), llvm::TargetInstrInfo::reassociateOps(), llvm::RegPressureTracker::recede(), llvm::WebAssemblyAsmPrinter::regToString(), llvm::SIInstrInfo::regUsesConstantBus(), rescheduleCanonically(), llvm::rewriteT2FrameIndex(), llvm::SelectionDAGISel::runOnMachineFunction(), llvm::InstructionSelect::selectMachineFunction(), llvm::MachineRegisterInfo::setRegAllocationHint(), llvm::MachineRegisterInfo::shouldTrackSubRegLiveness(), llvm::LiveIntervals::shrinkToUses(), llvm::stableHashValue(), llvm::AArch64InstrInfo::storeRegToStackSlot(), llvm::SIInstrInfo::storeRegToStackSlot(), llvm::Thumb2InstrInfo::storeRegToStackSlot(), tryChangeVGPRtoSGPRinCopy(), llvm::LegalizationArtifactCombiner::tryCombineInstruction(), llvm::ARMBaseRegisterInfo::updateRegAllocHint(), llvm::SIInstrInfo::usesConstantBus(), llvm::SIInstrInfo::verifyInstruction(), virtRegIndex(), and llvm::VirtRegAuxInfo::weightCalcHelper().

◆ isVirtualRegister()

◆ operator MCRegister()

llvm::Register::operator MCRegister ( ) const
inlineconstexpr

Definition at line 102 of file Register.h.

◆ operator unsigned()

llvm::Register::operator unsigned ( ) const
inlineconstexpr

Definition at line 98 of file Register.h.

◆ operator!=() [1/5]

bool llvm::Register::operator!= ( const MCRegister & Other) const
inlineconstexpr

Definition at line 124 of file Register.h.

References llvm::Other.

◆ operator!=() [2/5]

bool llvm::Register::operator!= ( const Register & Other) const
inlineconstexpr

Definition at line 118 of file Register.h.

References llvm::Other, and Register().

◆ operator!=() [3/5]

bool llvm::Register::operator!= ( int Other) const
inlineconstexpr

Definition at line 134 of file Register.h.

References llvm::Other.

◆ operator!=() [4/5]

bool llvm::Register::operator!= ( MCPhysReg Other) const
inlineconstexpr

Definition at line 139 of file Register.h.

References llvm::Other.

◆ operator!=() [5/5]

bool llvm::Register::operator!= ( unsigned Other) const
inlineconstexpr

Definition at line 132 of file Register.h.

References llvm::Other.

◆ operator++() [1/2]

Register & llvm::Register::operator++ ( )
inline

Operators to move from one register to another nearby register by adding an offset.

Definition at line 145 of file Register.h.

References assert(), isValid(), and Register().

◆ operator++() [2/2]

Register llvm::Register::operator++ ( int )
inline

Definition at line 151 of file Register.h.

References Register().

◆ operator+=()

Register & llvm::Register::operator+= ( unsigned RHS)
inline

Definition at line 157 of file Register.h.

References assert(), isValid(), Register(), and RHS.

◆ operator==() [1/5]

bool llvm::Register::operator== ( const MCRegister & Other) const
inlineconstexpr

Definition at line 121 of file Register.h.

References llvm::Other.

◆ operator==() [2/5]

bool llvm::Register::operator== ( const Register & Other) const
inlineconstexpr

Comparisons between register objects.

Definition at line 115 of file Register.h.

References llvm::Other, and Register().

◆ operator==() [3/5]

bool llvm::Register::operator== ( int Other) const
inlineconstexpr

Definition at line 133 of file Register.h.

References llvm::Other.

◆ operator==() [4/5]

bool llvm::Register::operator== ( MCPhysReg Other) const
inlineconstexpr

Definition at line 136 of file Register.h.

References llvm::Other.

◆ operator==() [5/5]

bool llvm::Register::operator== ( unsigned Other) const
inlineconstexpr

Comparisons against register constants.

E.g.

  • R == AArch64::WZR
  • R == 0

Definition at line 131 of file Register.h.

References llvm::Other.

◆ stackSlotIndex()

int llvm::Register::stackSlotIndex ( ) const
inline

Compute the frame index from a register value representing a stack slot.

Definition at line 93 of file Register.h.

References assert(), isStack(), llvm::SignExtend32(), and StackSlotMask.

◆ virtRegIndex()

unsigned llvm::Register::virtRegIndex ( ) const
inline

Convert a virtual register number to a 0-based index.

The first virtual register in a function will get the index 0.

Definition at line 87 of file Register.h.

References assert(), isVirtual(), Register(), and VirtualRegFlag.

Referenced by llvm::WebAssemblyFunctionInfo::getWAReg(), llvm::WebAssemblyFunctionInfo::isVRegStackified(), llvm::WebAssemblyFunctionInfo::setWAReg(), llvm::WebAssemblyFunctionInfo::stackifyVReg(), and llvm::WebAssemblyFunctionInfo::unstackifyVReg().

Member Data Documentation

◆ MaxFrameIndexBitwidth

unsigned llvm::Register::MaxFrameIndexBitwidth = 30
staticconstexpr

Definition at line 39 of file Register.h.

◆ StackSlotMask

const unsigned llvm::Register::StackSlotMask = StackSlotZero - 1
staticconstexpr

Definition at line 41 of file Register.h.

Referenced by index2StackSlot(), and stackSlotIndex().

◆ StackSlotZero

unsigned llvm::Register::StackSlotZero = 1u << MaxFrameIndexBitwidth
staticconstexpr

Definition at line 40 of file Register.h.

Referenced by index2StackSlot(), and isStack().

◆ VirtualRegFlag

unsigned llvm::Register::VirtualRegFlag = 1u << 31
staticconstexpr

The documentation for this class was generated from the following file: