LLVM 22.0.0git
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
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 FirstStackSlot = 1u << 30
 
static constexpr unsigned VirtualRegFlag = 1u << 31
 

Detailed Description

Wrapper class representing virtual and physical registers.

Should be passed by value.

Definition at line 19 of file Register.h.

Constructor & Destructor Documentation

◆ Register() [1/2]

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

Definition at line 23 of file Register.h.

◆ Register() [2/2]

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

Definition at line 24 of file Register.h.

Member Function Documentation

◆ asMCReg()

MCRegister llvm::Register::asMCReg ( ) const
inline

◆ id()

constexpr unsigned llvm::Register::id ( ) const
inlineconstexpr

◆ index2StackSlot()

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

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

Definition at line 48 of file Register.h.

References assert(), and FirstStackSlot.

Referenced by llvm::LiveStacks::getOrCreateInterval(), llvm::rdf::PhysicalRegisterInfo::getRegMaskId(), and llvm::ReachingDefAnalysis::printAllReachingDefs().

◆ index2VirtReg()

static Register llvm::Register::index2VirtReg ( unsigned  Index)
inlinestatic

◆ isPhysical()

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

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

Definition at line 78 of file Register.h.

References isPhysicalRegister().

Referenced by llvm::DwarfExpression::addMachineReg(), llvm::MachineInstr::addRegisterDead(), llvm::MachineInstr::addRegisterKilled(), llvm::AnalyzePhysRegInBundle(), asMCReg(), blockPrologueInterferes(), canFoldCopy(), llvm::canReplaceReg(), llvm::X86InstrInfo::classifyLEAReg(), collectRegDefs(), llvm::TargetInstrInfo::commuteInstructionImpl(), llvm::TargetRegisterClass::contains(), llvm::X86InstrInfo::describeLoadedValue(), llvm::GIMatchTableExecutor::executeMatchTable(), llvm::MachineInstr::findRegisterDefOperandIdx(), llvm::CoalescerPair::flip(), llvm::SIInstrInfo::foldImmediate(), llvm::X86InstrInfo::foldMemoryOperandImpl(), foldVGPRCopyIntoRegSequence(), llvm::BitTracker::MachineEvaluator::getCell(), llvm::AArch64RegisterBankInfo::getInstrMapping(), llvm::SIInstrInfo::getInstructionUniformity(), getMopState(), llvm::HexagonInstrInfo::getOperandLatency(), llvm::SIRegisterInfo::getRegAllocationHints(), llvm::ARMBaseRegisterInfo::getRegAllocationHints(), llvm::TargetRegisterInfo::getRegAllocationHints(), llvm::BitTracker::MachineEvaluator::getRegBitWidth(), llvm::getRegState(), llvm::X86InstrInfo::getUndefRegClearance(), INITIALIZE_PASS(), llvm::CoalescerPair::isCoalescable(), isIdenticalOp(), isLibCallInTailPosition(), isLocalCopy(), isMatchingStartStopPair(), 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::MachineOperand::print(), llvm::TargetRegisterInfo::regsOverlap(), llvm::MachineRegisterInfo::replaceRegWith(), selectCopy(), storeRegPairToStackSlot(), llvm::Thumb1InstrInfo::storeRegToStackSlot(), llvm::MachineInstr::substituteRegister(), llvm::SIInstrInfo::verifyInstruction(), and llvm::VirtRegAuxInfo::weightCalcHelper().

◆ isPhysicalRegister()

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

◆ isStack()

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

Return true if this is a stack slot.

Definition at line 43 of file Register.h.

References FirstStackSlot, and VirtualRegFlag.

Referenced by llvm::rdf::RegisterRef::isMaskId(), and stackSlotIndex().

◆ isValid()

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

Definition at line 107 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::AArch64TargetLowering::changeStreamingMode(), llvm::X86InstrInfo::classifyLEAReg(), llvm::WebAssemblyDebugValueManager::cloneSink(), copySubReg(), 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(), llvm::VirtRegMap::hasPreferredPhys(), INITIALIZE_PASS(), 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()

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

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

Definition at line 74 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(), attemptDebugCopyProp(), llvm::SIInstrInfo::buildExtractSubReg(), llvm::AMDGPULegalizerInfo::buildLoadInputValue(), 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(), llvm::SIScheduleDAGMI::fillVgprSgprCost(), llvm::MachineFunction::finalizeDebugInstrRefs(), 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(), llvm::PPCInstrInfo::getFMAPatterns(), getFMULPatterns(), llvm::MachineInstrExpressionTrait::getHashValue(), getIndVarInfo(), llvm::AMDGPURegisterBankInfo::getInstrMapping(), getLanesWithProperty(), llvm::SIInstrInfo::getLiveRangeSplitOpcode(), llvm::VirtRegMap::getPhys(), llvm::MachineRegisterInfo::getRegAllocationHint(), llvm::PPCRegisterInfo::getRegAllocationHints(), llvm::TargetRegisterInfo::getRegAllocationHints(), llvm::MachineRegisterInfo::getRegAllocationHints(), llvm::BitTracker::MachineEvaluator::getRegBitWidth(), llvm::VirtRegMap::getShape(), llvm::MachineRegisterInfo::getSimpleHint(), llvm::VirtRegMap::getStackSlot(), llvm::getVRegSubRegDef(), hasAllNBitUsers(), llvm::VirtRegMap::hasPreferredPhys(), llvm::TargetInstrInfo::hasReassociableOperands(), llvm::RISCVInstrInfo::hasReassociableOperands(), hasSameValue(), INITIALIZE_PASS(), llvm::RegPressureTracker::initLiveThru(), isAGPRCopy(), isCopyFeedingInvariantStore(), llvm::MachineInstr::isIdenticalTo(), isLibCallInTailPosition(), llvm::TargetInstrInfo::isReallyTriviallyReMaterializable(), isSignExtendedW(), isTileRegDef(), isVirtualRegisterOperand(), IsWritingToVCCR(), llvm::SIInstrInfo::legalizeOperands(), llvm::AArch64InstrInfo::loadRegFromStackSlot(), llvm::Thumb2InstrInfo::loadRegFromStackSlot(), llvm::SIInstrInfo::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(), rescheduleCanonically(), llvm::rewriteT2FrameIndex(), llvm::SelectionDAGISel::runOnMachineFunction(), llvm::InstructionSelect::selectMachineFunction(), llvm::MachineRegisterInfo::setRegAllocationHint(), llvm::MachineRegisterInfo::shouldTrackSubRegLiveness(), llvm::LiveIntervals::shrinkToUses(), llvm::stableHashValue(), llvm::AArch64InstrInfo::storeRegToStackSlot(), llvm::Thumb2InstrInfo::storeRegToStackSlot(), llvm::SIInstrInfo::storeRegToStackSlot(), tryChangeVGPRtoSGPRinCopy(), llvm::LegalizationArtifactCombiner::tryCombineInstruction(), llvm::ARMBaseRegisterInfo::updateRegAllocHint(), llvm::SIInstrInfo::verifyInstruction(), virtRegIndex(), and llvm::VirtRegAuxInfo::weightCalcHelper().

◆ isVirtualRegister()

static constexpr bool llvm::Register::isVirtualRegister ( unsigned  Reg)
inlinestaticconstexpr

◆ operator MCRegister()

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

Definition at line 97 of file Register.h.

◆ operator unsigned()

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

Definition at line 93 of file Register.h.

◆ operator!=() [1/5]

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

Definition at line 119 of file Register.h.

References llvm::Other.

◆ operator!=() [2/5]

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

Definition at line 113 of file Register.h.

References llvm::Other.

◆ operator!=() [3/5]

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

Definition at line 129 of file Register.h.

References llvm::Other.

◆ operator!=() [4/5]

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

Definition at line 134 of file Register.h.

References llvm::Other.

◆ operator!=() [5/5]

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

Definition at line 127 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 140 of file Register.h.

References assert(), and isValid().

◆ operator++() [2/2]

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

Definition at line 146 of file Register.h.

◆ operator+=()

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

Definition at line 152 of file Register.h.

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

◆ operator==() [1/5]

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

Definition at line 116 of file Register.h.

References llvm::Other.

◆ operator==() [2/5]

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

Comparisons between register objects.

Definition at line 110 of file Register.h.

References llvm::Other.

◆ operator==() [3/5]

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

Definition at line 128 of file Register.h.

References llvm::Other.

◆ operator==() [4/5]

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

Definition at line 131 of file Register.h.

References llvm::Other.

◆ operator==() [5/5]

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

Comparisons against register constants.

E.g.

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

Definition at line 126 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 88 of file Register.h.

References assert(), FirstStackSlot, and isStack().

Referenced by llvm::rdf::PhysicalRegisterInfo::getMaskUnits(), and llvm::rdf::PhysicalRegisterInfo::print().

◆ virtRegIndex()

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

Member Data Documentation

◆ FirstStackSlot

constexpr unsigned llvm::Register::FirstStackSlot = 1u << 30
staticconstexpr

Definition at line 38 of file Register.h.

Referenced by index2StackSlot(), isStack(), and stackSlotIndex().

◆ VirtualRegFlag

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

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