[macho] Allow CPUSubtype to be adjusted before writing it to a file
authorDaniel Sanders <daniel_l_sanders@apple.com>
Fri, 15 Nov 2019 22:58:57 +0000 (14:58 -0800)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Mon, 18 Nov 2019 20:57:39 +0000 (12:57 -0800)
Summary:
It's not always possible for a target to provide a MachO CPUSubtype up
front as is required by the current implementation. Sometimes you need more
information like the particular CPU implementation you are targeting.

Give MCMachObjectTargetWriter subclasses the opportunity to modify the
CPUSubtype after the MCMachObjectTargetWriter is created but before the
object starts being written. Typically this would be done in response to
instructions from a TargetStreamer.

Reviewers: pete

Subscribers: llvm-commits

Tags: #llvm

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

llvm/include/llvm/MC/MCMachObjectWriter.h

index 278aebee99acdc5350a88c3a3d301b3edc47de35..853e5066f0398fdc43f2dccb17f8a1b892950ba0 100644 (file)
@@ -28,7 +28,9 @@ class MachObjectWriter;
 class MCMachObjectTargetWriter : public MCObjectTargetWriter {
   const unsigned Is64Bit : 1;
   const uint32_t CPUType;
-  const uint32_t CPUSubtype;
+protected:
+  uint32_t CPUSubtype;
+public:
   unsigned LocalDifference_RIT;
 
 protected: