From ab46f8119835ca403e9bae0d41b3aa05a12f4731 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Sat, 24 Sep 2016 04:53:58 +0000 Subject: [PATCH] [RegisterBankInfo] Document the design choice for the BreakDown. This adds a comment explaining why we will duplicate PartialMapping to represent the breakdown for complex mappings (mappings with more than one partial mapping), instead of using an array of pointer. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282326 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../CodeGen/GlobalISel/RegisterBankInfo.h | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h index 8ccc0421c54..0d9df7a6f55 100644 --- a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h +++ b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h @@ -84,6 +84,58 @@ public: /// Helper struct that represents how a value is mapped through /// different register banks. + /// + /// \note: So far we do not have any users of the complex mappings + /// (mappings with more than one partial mapping), but when we do, + /// we would have needed to duplicate partial mappings. + /// The alternative could be to use an array of pointers of partial + /// mapping (i.e., PartialMapping **BreakDown) and duplicate the + /// pointers instead. + /// + /// E.g., + /// Let say we have a 32-bit add and a <2 x 32-bit> vadd. We + /// can expand the + /// <2 x 32-bit> add into 2 x 32-bit add. + /// + /// Currently the TableGen-like file would look like: + /// \code + /// PartialMapping[] = { + /// /*32-bit add*/ {0, 32, GPR}, + /// /*2x32-bit add*/ {0, 32, GPR}, {0, 32, GPR}, // <-- Same entry 3x + /// /*<2x32-bit> vadd {0, 64, VPR} + /// }; // PartialMapping duplicated. + /// + /// ValueMapping[] { + /// /*plain 32-bit add*/ {&PartialMapping[0], 1}, + /// /*expanded vadd on 2xadd*/ {&PartialMapping[1], 2}, + /// /*plain <2x32-bit> vadd*/ {&PartialMapping[3], 1} + /// }; + /// \endcode + /// + /// With the array of pointer, we would have: + /// \code + /// PartialMapping[] = { + /// /*32-bit add*/ {0, 32, GPR}, + /// /*<2x32-bit> vadd {0, 64, VPR} + /// }; // No more duplication. + /// + /// BreakDowns[] = { + /// /*AddBreakDown*/ &PartialMapping[0], + /// /*2xAddBreakDown*/ &PartialMapping[0], &PartialMapping[0], + /// /*VAddBreakDown*/ &PartialMapping[1] + /// }; // Addresses of PartialMapping duplicated (smaller). + /// + /// ValueMapping[] { + /// /*plain 32-bit add*/ {&BreakDowns[0], 1}, + /// /*expanded vadd on 2xadd*/ {&BreakDowns[1], 2}, + /// /*plain <2x32-bit> vadd*/ {&BreakDowns[3], 1} + /// }; + /// \endcode + /// + /// Given that a PartialMapping is actually small, the code size + /// impact is actually a degradation. Moreover the compile time will + /// be hit by the additional indirection. + /// If PartialMapping gets bigger we may reconsider. struct ValueMapping { /// How the value is broken down between the different register banks. const PartialMapping *BreakDown; -- 2.50.1