[llvm] r262856 - [MachineRegisterInfo] Get rid of the global-isel ifdefs.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 13:22:10 PST 2016
Author: qcolombet
Date: Mon Mar 7 15:22:09 2016
New Revision: 262856
URL: http://llvm.org/viewvc/llvm-project?rev=262856&view=rev
Log:
[MachineRegisterInfo] Get rid of the global-isel ifdefs.
One additional pointer is not a big deal size-wise and it makes
the code much nicer!
Modified:
llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=262856&r1=262855&r2=262856&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Mon Mar 7 15:22:09 2016
@@ -105,10 +105,17 @@ private:
/// started.
BitVector ReservedRegs;
-#ifdef LLVM_BUILD_GLOBAL_ISEL
+ typedef DenseMap<unsigned, unsigned> VRegToSizeMap;
/// Map generic virtual registers to their actual size.
- DenseMap<unsigned, unsigned> VRegToSize;
-#endif
+ mutable std::unique_ptr<VRegToSizeMap> VRegToSize;
+
+ /// Accessor for VRegToSize. This accessor should only be used
+ /// by global-isel related work.
+ VRegToSizeMap &getVRegToSize() const {
+ if (!VRegToSize)
+ VRegToSize.reset(new VRegToSizeMap);
+ return *VRegToSize.get();
+ }
/// Keep track of the physical registers that are live in to the function.
/// Live in values are typically arguments in registers. LiveIn values are
@@ -592,7 +599,6 @@ public:
///
unsigned createVirtualRegister(const TargetRegisterClass *RegClass);
-#ifdef LLVM_BUILD_GLOBAL_ISEL
/// Get the size of \p VReg or 0 if VReg is not a generic
/// (target independent) virtual register.
unsigned getSize(unsigned VReg) const;
@@ -600,7 +606,6 @@ public:
/// Create and return a new generic virtual register with a size of \p Size.
/// \pre Size > 0.
unsigned createGenericVirtualRegister(unsigned Size);
-#endif
/// getNumVirtRegs - Return the number of virtual registers created.
///
Modified: llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp?rev=262856&r1=262855&r2=262856&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp Mon Mar 7 15:22:09 2016
@@ -103,12 +103,10 @@ MachineRegisterInfo::createVirtualRegist
return Reg;
}
-#ifdef LLVM_BUILD_GLOBAL_ISEL
unsigned
MachineRegisterInfo::getSize(unsigned VReg) const {
- DenseMap<unsigned, unsigned>::const_iterator SizeIt =
- VRegToSize.find(VReg);
- return SizeIt != VRegToSize.end()? SizeIt->second: 0;
+ VRegToSizeMap::const_iterator SizeIt = getVRegToSize().find(VReg);
+ return SizeIt != getVRegToSize().end() ? SizeIt->second : 0;
}
unsigned
@@ -120,13 +118,12 @@ MachineRegisterInfo::createGenericVirtua
VRegInfo.grow(Reg);
// FIXME: Should we use a dummy register class?
VRegInfo[Reg].first = nullptr;
- VRegToSize[Reg] = Size;
+ getVRegToSize()[Reg] = Size;
RegAllocHints.grow(Reg);
if (TheDelegate)
TheDelegate->MRI_NoteNewVirtualRegister(Reg);
return Reg;
}
-#endif // LLVM_BUILD_GLOBAL_ISEL
/// clearVirtRegs - Remove all virtual registers (after physreg assignment).
void MachineRegisterInfo::clearVirtRegs() {
More information about the llvm-commits
mailing list