Reorder Type fields to make various isa< > check more concise
authorserge-sans-paille <sguelton@redhat.com>
Tue, 12 May 2020 16:46:32 +0000 (18:46 +0200)
committerserge-sans-paille <sguelton@redhat.com>
Mon, 18 May 2020 12:23:52 +0000 (14:23 +0200)
Depending on the order of fields, some isa < > checks can be faster because of
tests that check a range of type, leading to assembly simplification.

To find a relevant ordering, I... brute-forced the permutation among the derived
types and pick the combination that resulted in the smallest libLLVM-11.so.

On my laptop (x86_64), this reduces the size of libLLVM-11.so from 127344064 bytes to 127335336,
that's 8728 bytes shaved without much effort.

Also removed obsolete comments in the process.

Differential Revision: https://reviews.llvm.org/D79996

llvm/include/llvm/IR/Type.h

index 5d6c0c6..7043775 100644 (file)
@@ -53,29 +53,28 @@ public:
   /// Also update LLVMTypeKind and LLVMGetTypeKind () in the C binding.
   ///
   enum TypeID {
-    // PrimitiveTypes - make sure LastPrimitiveTyID stays up to date.
-    VoidTyID = 0,    ///<  0: type with no size
-    HalfTyID,        ///<  1: 16-bit floating point type
-    BFloatTyID,      ///<  2: 16-bit floating point type (7-bit significand)
-    FloatTyID,       ///<  3: 32-bit floating point type
-    DoubleTyID,      ///<  4: 64-bit floating point type
-    X86_FP80TyID,    ///<  5: 80-bit floating point type (X87)
-    FP128TyID,       ///<  6: 128-bit floating point type (112-bit significand)
-    PPC_FP128TyID,   ///<  7: 128-bit floating point type (two 64-bits, PowerPC)
-    LabelTyID,       ///<  8: Labels
-    MetadataTyID,    ///<  9: Metadata
-    X86_MMXTyID,     ///< 10: MMX vectors (64 bits, X86 specific)
-    TokenTyID,       ///< 11: Tokens
+    // PrimitiveTypes
+    HalfTyID = 0,  ///< 16-bit floating point type
+    BFloatTyID,    ///< 16-bit floating point type (7-bit significand)
+    FloatTyID,     ///< 32-bit floating point type
+    DoubleTyID,    ///< 64-bit floating point type
+    X86_FP80TyID,  ///< 80-bit floating point type (X87)
+    FP128TyID,     ///< 128-bit floating point type (112-bit significand)
+    PPC_FP128TyID, ///< 128-bit floating point type (two 64-bits, PowerPC)
+    VoidTyID,      ///< type with no size
+    LabelTyID,     ///< Labels
+    MetadataTyID,  ///< Metadata
+    X86_MMXTyID,   ///< MMX vectors (64 bits, X86 specific)
+    TokenTyID,     ///< Tokens
 
     // Derived types... see DerivedTypes.h file.
-    // Make sure FirstDerivedTyID stays up to date!
-    IntegerTyID,       ///< 12: Arbitrary bit width integers
-    FunctionTyID,      ///< 13: Functions
-    StructTyID,        ///< 14: Structures
-    ArrayTyID,         ///< 15: Arrays
-    PointerTyID,       ///< 16: Pointers
-    FixedVectorTyID,   ///< 17: Fixed width SIMD vector type
-    ScalableVectorTyID ///< 18: Scalable SIMD vector type
+    IntegerTyID,       ///< Arbitrary bit width integers
+    FunctionTyID,      ///< Functions
+    PointerTyID,       ///< Pointers
+    StructTyID,        ///< Structures
+    ArrayTyID,         ///< Arrays
+    FixedVectorTyID,   ///< Fixed width SIMD vector type
+    ScalableVectorTyID ///< Scalable SIMD vector type
   };
 
 private: