From bed23081860275c79137f65d592920e7991b8198 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Fri, 31 May 2013 17:08:36 +0000 Subject: Add a way to define the bit range covered by a SubRegIndex. NOTE: If this broke your out-of-tree backend, in *RegisterInfo.td, change the instances of SubRegIndex that have a comps template arg to use the ComposedSubRegIndex class instead. In TableGen land, this adds Size and Offset attributes to SubRegIndex, and the ComposedSubRegIndex class, for which the Size and Offset are computed by TableGen. This also adds an accessor in MCRegisterInfo, and Size/Offsets for the X86 and ARM subreg indices. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183020 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/CodeGenRegisters.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'utils/TableGen/CodeGenRegisters.h') diff --git a/utils/TableGen/CodeGenRegisters.h b/utils/TableGen/CodeGenRegisters.h index ba62db4..c834551 100644 --- a/utils/TableGen/CodeGenRegisters.h +++ b/utils/TableGen/CodeGenRegisters.h @@ -37,6 +37,8 @@ namespace llvm { Record *const TheDef; std::string Name; std::string Namespace; + uint16_t Size; + uint16_t Offset; public: const unsigned EnumValue; @@ -52,6 +54,8 @@ namespace llvm { const std::string &getName() const { return Name; } const std::string &getNamespace() const { return Namespace; } std::string getQualifiedName() const; + uint16_t getSize() const { return Size; } + uint16_t getOffset() const { return Offset; } // Order CodeGenSubRegIndex pointers by EnumValue. struct Less { @@ -79,6 +83,15 @@ namespace llvm { assert(A && B); std::pair Ins = Composed.insert(std::make_pair(A, B)); + // Synthetic subreg indices that aren't contiguous (for instance ARM + // register tuples) don't have a bit range, so it's OK to let + // B->Offset == -1. For the other cases, accumulate the offset and set + // the size here. Only do so if there is no offset yet though. + if ((Offset != (uint16_t)-1 && A->Offset != (uint16_t)-1) && + (B->Offset == (uint16_t)-1)) { + B->Offset = Offset + A->Offset; + B->Size = A->Size; + } return (Ins.second || Ins.first->second == B) ? 0 : Ins.first->second; } -- cgit v1.1