OSDN Git Service

MC/Mach-O: Shuffle enums a bit to make it harder to inadvertently use the wrong
[android-x86/external-llvm.git] / include / llvm / MC / MCMachObjectWriter.h
1 //===-- llvm/MC/MCMachObjectWriter.h - Mach Object Writer -------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_MC_MCMACHOBJECTWRITER_H
11 #define LLVM_MC_MCMACHOBJECTWRITER_H
12
13 #include "llvm/MC/MCObjectWriter.h"
14 #include "llvm/Support/DataTypes.h"
15
16 namespace llvm {
17
18 class MCMachObjectTargetWriter {
19   const unsigned Is64Bit : 1;
20   const uint32_t CPUType;
21   const uint32_t CPUSubtype;
22   // FIXME: Remove this, we should just always use it once we no longer care
23   // about Darwin 'as' compatibility.
24   const unsigned UseAggressiveSymbolFolding : 1;
25   unsigned LocalDifference_RIT;
26
27 protected:
28   MCMachObjectTargetWriter(bool Is64Bit_, uint32_t CPUType_,
29                            uint32_t CPUSubtype_,
30                            bool UseAggressiveSymbolFolding_ = false);
31
32   void setLocalDifferenceRelocationType(unsigned Type) {
33     LocalDifference_RIT = Type;
34   }
35
36 public:
37   virtual ~MCMachObjectTargetWriter();
38
39   /// @name Accessors
40   /// @{
41
42   bool is64Bit() const { return Is64Bit; }
43   bool useAggressiveSymbolFolding() const { return UseAggressiveSymbolFolding; }
44   uint32_t getCPUType() const { return CPUType; }
45   uint32_t getCPUSubtype() const { return CPUSubtype; }
46   unsigned getLocalDifferenceRelocationType() const {
47     return LocalDifference_RIT;
48   }
49
50   /// @}
51 };
52
53 /// \brief Construct a new Mach-O writer instance.
54 ///
55 /// This routine takes ownership of the target writer subclass.
56 ///
57 /// \param MOTW - The target specific Mach-O writer subclass.
58 /// \param OS - The stream to write to.
59 /// \returns The constructed object writer.
60 MCObjectWriter *createMachObjectWriter(MCMachObjectTargetWriter *MOTW,
61                                        raw_ostream &OS, bool IsLittleEndian);
62
63 } // End llvm namespace
64
65 #endif