Skip to content

Commit 1d7bb2b

Browse files
committed
[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.
1 parent b2dd840 commit 1d7bb2b

File tree

1 file changed

+8
-8
lines changed
  • llvm/include/llvm/BinaryFormat

1 file changed

+8
-8
lines changed

llvm/include/llvm/BinaryFormat/MachO.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,25 +1637,25 @@ enum CPUSubTypeARM {
16371637
CPU_SUBTYPE_ARM_V7EM = 16
16381638
};
16391639

1640-
enum CPUSubTypeARM64 {
1640+
enum CPUSubTypeARM64 : uint32_t {
16411641
CPU_SUBTYPE_ARM64_ALL = 0,
16421642
CPU_SUBTYPE_ARM64_V8 = 1,
16431643
CPU_SUBTYPE_ARM64E = 2,
16441644

16451645
// arm64e uses the capability bits to encode ptrauth ABI information.
16461646
// Bit 63 marks the binary as Versioned.
1647-
CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK = 0x80000000,
1647+
CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK = 0x80000000U,
16481648
// Bit 62 marks the binary as using a kernel ABI.
1649-
CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK = 0x40000000,
1649+
CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK = 0x40000000U,
16501650
// Bits [59:56] hold the 4-bit ptrauth ABI version.
1651-
CPU_SUBTYPE_ARM64E_PTRAUTH_MASK = 0x0f000000,
1651+
CPU_SUBTYPE_ARM64E_PTRAUTH_MASK = 0x0f000000U,
16521652
};
16531653

1654-
inline int CPU_SUBTYPE_ARM64E_PTRAUTH_VERSION(unsigned ST) {
1654+
inline unsigned CPU_SUBTYPE_ARM64E_PTRAUTH_VERSION(uint32_t ST) {
16551655
return (ST & CPU_SUBTYPE_ARM64E_PTRAUTH_MASK) >> 24;
16561656
}
16571657

1658-
inline unsigned
1658+
inline uint32_t
16591659
CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION(unsigned PtrAuthABIVersion,
16601660
bool PtrAuthKernelABIVersion) {
16611661
assert((PtrAuthABIVersion <= 0xF) &&
@@ -1666,11 +1666,11 @@ CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION(unsigned PtrAuthABIVersion,
16661666
(PtrAuthABIVersion << 24);
16671667
}
16681668

1669-
inline unsigned CPU_SUBTYPE_ARM64E_IS_VERSIONED_PTRAUTH_ABI(unsigned ST) {
1669+
inline bool CPU_SUBTYPE_ARM64E_IS_VERSIONED_PTRAUTH_ABI(uint32_t ST) {
16701670
return ST & CPU_SUBTYPE_ARM64E_VERSIONED_PTRAUTH_ABI_MASK;
16711671
}
16721672

1673-
inline unsigned CPU_SUBTYPE_ARM64E_IS_KERNEL_PTRAUTH_ABI(unsigned ST) {
1673+
inline bool CPU_SUBTYPE_ARM64E_IS_KERNEL_PTRAUTH_ABI(uint32_t ST) {
16741674
return ST & CPU_SUBTYPE_ARM64E_KERNEL_PTRAUTH_ABI_MASK;
16751675
}
16761676

0 commit comments

Comments
 (0)