New "TargetMachOWriterInfo" class. It holds target-specific information
[oota-llvm.git] / include / llvm / Target / TargetMachOWriterInfo.h
1 //===-- llvm/Target/TargetMachOWriterInfo.h - MachO Writer Info--*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Bill Wendling and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the TargetMachOWriterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TARGET_TARGETMACHOWRITERINFO_H
15 #define LLVM_TARGET_TARGETMACHOWRITERINFO_H
16
17 #include "llvm/CodeGen/MachineRelocation.h"
18
19 namespace llvm {
20
21   class MachineBasicBlock;
22
23   //===--------------------------------------------------------------------===//
24   //                        TargetMachOWriterInfo
25   //===--------------------------------------------------------------------===//
26
27   struct TargetMachOWriterInfo {
28     uint32_t CPUType;                 // CPU specifier
29     uint32_t CPUSubType;              // Machine specifier
30
31     // The various CPU_TYPE_* constants are already defined by at least one
32     // system header file and create compilation errors if not respected.
33 #if !defined(CPU_TYPE_I386)
34 #define CPU_TYPE_I386       7
35 #endif
36 #if !defined(CPU_TYPE_X86_64)
37 #define CPU_TYPE_X86_64     (CPU_TYPE_I386 | 0x1000000)
38 #endif
39 #if !defined(CPU_TYPE_ARM)
40 #define CPU_TYPE_ARM        12
41 #endif
42 #if !defined(CPU_TYPE_SPARC)
43 #define CPU_TYPE_SPARC      14
44 #endif
45 #if !defined(CPU_TYPE_POWERPC)
46 #define CPU_TYPE_POWERPC    18
47 #endif
48 #if !defined(CPU_TYPE_POWERPC64)
49 #define CPU_TYPE_POWERPC64  (CPU_TYPE_POWERPC | 0x1000000)
50 #endif
51
52     // Constants for the cputype field
53     // see <mach/machine.h>
54     enum {
55       HDR_CPU_TYPE_I386      = CPU_TYPE_I386,
56       HDR_CPU_TYPE_X86_64    = CPU_TYPE_X86_64,
57       HDR_CPU_TYPE_ARM       = CPU_TYPE_ARM,
58       HDR_CPU_TYPE_SPARC     = CPU_TYPE_SPARC,
59       HDR_CPU_TYPE_POWERPC   = CPU_TYPE_POWERPC,
60       HDR_CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC64
61     };
62       
63 #if !defined(CPU_SUBTYPE_I386_ALL)
64 #define CPU_SUBTYPE_I386_ALL    3
65 #endif
66 #if !defined(CPU_SUBTYPE_X86_64_ALL)
67 #define CPU_SUBTYPE_X86_64_ALL  3
68 #endif
69 #if !defined(CPU_SUBTYPE_ARM_ALL)
70 #define CPU_SUBTYPE_ARM_ALL     0
71 #endif
72 #if !defined(CPU_SUBTYPE_SPARC_ALL)
73 #define CPU_SUBTYPE_SPARC_ALL   0
74 #endif
75 #if !defined(CPU_SUBTYPE_POWERPC_ALL)
76 #define CPU_SUBTYPE_POWERPC_ALL 0
77 #endif
78
79     // Constants for the cpusubtype field
80     // see <mach/machine.h>
81     enum {
82       HDR_CPU_SUBTYPE_I386_ALL    = CPU_SUBTYPE_I386_ALL,
83       HDR_CPU_SUBTYPE_X86_64_ALL  = CPU_SUBTYPE_X86_64_ALL,
84       HDR_CPU_SUBTYPE_ARM_ALL     = CPU_SUBTYPE_ARM_ALL,
85       HDR_CPU_SUBTYPE_SPARC_ALL   = CPU_SUBTYPE_SPARC_ALL,
86       HDR_CPU_SUBTYPE_POWERPC_ALL = CPU_SUBTYPE_POWERPC_ALL
87     };
88
89     TargetMachOWriterInfo(uint32_t cputype, uint32_t cpusubtype)
90       : CPUType(cputype), CPUSubType(cpusubtype) {}
91     virtual ~TargetMachOWriterInfo() {}
92
93     virtual MachineRelocation GetJTRelocation(unsigned Offset,
94                                               MachineBasicBlock *MBB) const;
95
96     virtual const char *getPassName() const {
97       return "Mach-O Writer";
98     }
99   };
100
101 } // end llvm namespace
102
103 #endif // LLVM_TARGET_TARGETMACHOWRITERINFO_H