[llvm] r272083 - [RegisterBankInfo] Move a hidden function into a static method. NFC.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 7 18:04:32 PDT 2016
Author: qcolombet
Date: Tue Jun 7 20:04:32 2016
New Revision: 272083
URL: http://llvm.org/viewvc/llvm-project?rev=272083&view=rev
Log:
[RegisterBankInfo] Move a hidden function into a static method. NFC.
This will allow code reuse in the coming commits.
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h?rev=272083&r1=272082&r2=272083&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h Tue Jun 7 20:04:32 2016
@@ -415,6 +415,15 @@ public:
/// \post !returnedVal.empty().
InstructionMappings getInstrPossibleMappings(const MachineInstr &MI) const;
+ /// Get the size in bits of \p Reg.
+ /// Utility method to get the size of any registers. Unlike
+ /// MachineRegisterInfo::getSize, the register does not need to be a
+ /// virtual register.
+ ///
+ /// \pre \p Reg != 0 (NoRegister).
+ static unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI,
+ const TargetRegisterInfo &TRI);
+
/// Check that information hold by this instance make sense for the
/// given \p TRI.
///
Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp?rev=272083&r1=272082&r2=272083&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp Tue Jun 7 20:04:32 2016
@@ -35,30 +35,6 @@ using namespace llvm;
const unsigned RegisterBankInfo::DefaultMappingID = UINT_MAX;
const unsigned RegisterBankInfo::InvalidMappingID = UINT_MAX - 1;
-/// Get the size in bits of the \p Reg.
-///
-/// \pre \p Reg != 0 (NoRegister).
-static unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI,
- const TargetRegisterInfo &TRI) {
- const TargetRegisterClass *RC = nullptr;
- if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
- // The size is not directly available for physical registers.
- // Instead, we need to access a register class that contains Reg and
- // get the size of that register class.
- RC = TRI.getMinimalPhysRegClass(Reg);
- } else {
- unsigned RegSize = MRI.getSize(Reg);
- // If Reg is not a generic register, query the register class to
- // get its size.
- if (RegSize)
- return RegSize;
- // Since Reg is not a generic register, it must have a register class.
- RC = MRI.getRegClass(Reg);
- }
- assert(RC && "Unable to deduce the register class");
- return RC->getSize() * 8;
-}
-
//------------------------------------------------------------------------------
// RegisterBankInfo implementation.
//------------------------------------------------------------------------------
@@ -356,6 +332,28 @@ RegisterBankInfo::getInstrAlternativeMap
return InstructionMappings();
}
+unsigned RegisterBankInfo::getSizeInBits(unsigned Reg,
+ const MachineRegisterInfo &MRI,
+ const TargetRegisterInfo &TRI) {
+ const TargetRegisterClass *RC = nullptr;
+ if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
+ // The size is not directly available for physical registers.
+ // Instead, we need to access a register class that contains Reg and
+ // get the size of that register class.
+ RC = TRI.getMinimalPhysRegClass(Reg);
+ } else {
+ unsigned RegSize = MRI.getSize(Reg);
+ // If Reg is not a generic register, query the register class to
+ // get its size.
+ if (RegSize)
+ return RegSize;
+ // Since Reg is not a generic register, it must have a register class.
+ RC = MRI.getRegClass(Reg);
+ }
+ assert(RC && "Unable to deduce the register class");
+ return RC->getSize() * 8;
+}
+
//------------------------------------------------------------------------------
// Helper classes implementation.
//------------------------------------------------------------------------------
More information about the llvm-commits
mailing list