[llvm] 1d7bb2b - [MachO] Give the CPUSubTypeARM64 enum uint32_t type. NFCI.

Ahmed Bougacha via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 27 12:24:32 PDT 2024


Author: Ahmed Bougacha
Date: 2024-08-27T12:21:01-07:00
New Revision: 1d7bb2bbfa1d50663e2883e0e8e1d2b147103013

URL: https://github.com/llvm/llvm-project/commit/1d7bb2bbfa1d50663e2883e0e8e1d2b147103013
DIFF: https://github.com/llvm/llvm-project/commit/1d7bb2bbfa1d50663e2883e0e8e1d2b147103013.diff

LOG: [MachO] Give the CPUSubTypeARM64 enum uint32_t type. NFCI.

We recently added various CPU_SUBTYPE_ARM64E values, notably including
CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK, which is 0x80000000U.
The enum is better off as a uint32_t to accomodate that.

This also hopefully helps silence GCC warnings reported on a ternary in
CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION.

The subtype is already generally treated as a uint32_t elsewhere, so
while there, change the new helpers to explicitly pass/return the
subtype as uint32_t, and the individual narrower components as either
bool or unsigned.

Added: 
    

Modified: 
    llvm/include/llvm/BinaryFormat/MachO.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/BinaryFormat/MachO.h b/llvm/include/llvm/BinaryFormat/MachO.h
index b37651e85a6269..6337a0bbdda870 100644
--- a/llvm/include/llvm/BinaryFormat/MachO.h
+++ b/llvm/include/llvm/BinaryFormat/MachO.h
@@ -1637,25 +1637,25 @@ enum CPUSubTypeARM {
   CPU_SUBTYPE_ARM_V7EM = 16
 };
 
-enum CPUSubTypeARM64 {
+enum CPUSubTypeARM64 : uint32_t {
   CPU_SUBTYPE_ARM64_ALL = 0,
   CPU_SUBTYPE_ARM64_V8 = 1,
   CPU_SUBTYPE_ARM64E = 2,
 
   // arm64e uses the capability bits to encode ptrauth ABI information.
   // Bit 63 marks the binary as Versioned.
-  CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK = 0x80000000,
+  CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK = 0x80000000U,
   // Bit 62 marks the binary as using a kernel ABI.
-  CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK = 0x40000000,
+  CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK = 0x40000000U,
   // Bits [59:56] hold the 4-bit ptrauth ABI version.
-  CPU_SUBTYPE_ARM64E_PTRAUTH_MASK = 0x0f000000,
+  CPU_SUBTYPE_ARM64E_PTRAUTH_MASK = 0x0f000000U,
 };
 
-inline int CPU_SUBTYPE_ARM64E_PTRAUTH_VERSION(unsigned ST) {
+inline unsigned CPU_SUBTYPE_ARM64E_PTRAUTH_VERSION(uint32_t ST) {
   return (ST & CPU_SUBTYPE_ARM64E_PTRAUTH_MASK) >> 24;
 }
 
-inline unsigned
+inline uint32_t
 CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION(unsigned PtrAuthABIVersion,
                                         bool PtrAuthKernelABIVersion) {
   assert((PtrAuthABIVersion <= 0xF) &&
@@ -1666,11 +1666,11 @@ CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION(unsigned PtrAuthABIVersion,
          (PtrAuthABIVersion << 24);
 }
 
-inline unsigned CPU_SUBTYPE_ARM64E_IS_VERSIONED_PTRAUTH_ABI(unsigned ST) {
+inline bool CPU_SUBTYPE_ARM64E_IS_VERSIONED_PTRAUTH_ABI(uint32_t ST) {
   return ST & CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK;
 }
 
-inline unsigned CPU_SUBTYPE_ARM64E_IS_KERNEL_PTRAUTH_ABI(unsigned ST) {
+inline bool CPU_SUBTYPE_ARM64E_IS_KERNEL_PTRAUTH_ABI(uint32_t ST) {
   return ST & CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK;
 }
 


        


More information about the llvm-commits mailing list