1//===-- ARMBuildAttributes.h - ARM Build Attributes -------------*- 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// This file contains enumerations and support routines for ARM build attributes
11// as defined in ARM ABI addenda document (ABI release 2.08).
12//
13// ELF for the ARM Architecture r2.09 - November 30, 2012
14//
15// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef LLVM_SUPPORT_ARM_BUILD_ATTRIBUTES_H
20#define LLVM_SUPPORT_ARM_BUILD_ATTRIBUTES_H
21
22namespace llvm {
23class StringRef;
24
25namespace ARMBuildAttrs {
26
27enum SpecialAttr {
28  // This is for the .cpu asm attr. It translates into one or more
29  // AttrType (below) entries in the .ARM.attributes section in the ELF.
30  SEL_CPU
31};
32
33enum AttrType {
34  // Rest correspond to ELF/.ARM.attributes
35  File                      = 1,
36  CPU_raw_name              = 4,
37  CPU_name                  = 5,
38  CPU_arch                  = 6,
39  CPU_arch_profile          = 7,
40  ARM_ISA_use               = 8,
41  THUMB_ISA_use             = 9,
42  FP_arch                   = 10,
43  WMMX_arch                 = 11,
44  Advanced_SIMD_arch        = 12,
45  PCS_config                = 13,
46  ABI_PCS_R9_use            = 14,
47  ABI_PCS_RW_data           = 15,
48  ABI_PCS_RO_data           = 16,
49  ABI_PCS_GOT_use           = 17,
50  ABI_PCS_wchar_t           = 18,
51  ABI_FP_rounding           = 19,
52  ABI_FP_denormal           = 20,
53  ABI_FP_exceptions         = 21,
54  ABI_FP_user_exceptions    = 22,
55  ABI_FP_number_model       = 23,
56  ABI_align_needed          = 24,
57  ABI_align_preserved       = 25,
58  ABI_enum_size             = 26,
59  ABI_HardFP_use            = 27,
60  ABI_VFP_args              = 28,
61  ABI_WMMX_args             = 29,
62  ABI_optimization_goals    = 30,
63  ABI_FP_optimization_goals = 31,
64  compatibility             = 32,
65  CPU_unaligned_access      = 34,
66  FP_HP_extension           = 36,
67  ABI_FP_16bit_format       = 38,
68  MPextension_use           = 42, // recoded from 70 (ABI r2.08)
69  DIV_use                   = 44,
70  also_compatible_with      = 65,
71  conformance               = 67,
72  Virtualization_use        = 68,
73
74  /// Legacy Tags
75  Section                   = 2,  // deprecated (ABI r2.09)
76  Symbol                    = 3,  // deprecated (ABI r2.09)
77  ABI_align8_needed         = 24, // renamed to ABI_align_needed (ABI r2.09)
78  ABI_align8_preserved      = 25, // renamed to ABI_align_preserved (ABI r2.09)
79  nodefaults                = 64, // deprecated (ABI r2.09)
80  T2EE_use                  = 66, // deprecated (ABI r2.09)
81  MPextension_use_old       = 70  // recoded to MPextension_use (ABI r2.08)
82};
83
84StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix = true);
85StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix = true);
86int AttrTypeFromString(StringRef Tag);
87
88// Magic numbers for .ARM.attributes
89enum AttrMagic {
90  Format_Version  = 0x41
91};
92
93// Legal Values for CPU_arch, (=6), uleb128
94enum CPUArch {
95  Pre_v4   = 0,
96  v4       = 1,   // e.g. SA110
97  v4T      = 2,   // e.g. ARM7TDMI
98  v5T      = 3,   // e.g. ARM9TDMI
99  v5TE     = 4,   // e.g. ARM946E_S
100  v5TEJ    = 5,   // e.g. ARM926EJ_S
101  v6       = 6,   // e.g. ARM1136J_S
102  v6KZ     = 7,   // e.g. ARM1176JZ_S
103  v6T2     = 8,   // e.g. ARM1156T2F_S
104  v6K      = 9,   // e.g. ARM1136J_S
105  v7       = 10,  // e.g. Cortex A8, Cortex M3
106  v6_M     = 11,  // e.g. Cortex M1
107  v6S_M    = 12,  // v6_M with the System extensions
108  v7E_M    = 13,  // v7_M with DSP extensions
109  v8       = 14   // v8, AArch32
110};
111
112enum CPUArchProfile {               // (=7), uleb128
113  Not_Applicable          = 0,      // pre v7, or cross-profile code
114  ApplicationProfile      = (0x41), // 'A' (e.g. for Cortex A8)
115  RealTimeProfile         = (0x52), // 'R' (e.g. for Cortex R4)
116  MicroControllerProfile  = (0x4D), // 'M' (e.g. for Cortex M3)
117  SystemProfile           = (0x53)  // 'S' Application or real-time profile
118};
119
120// The following have a lot of common use cases
121enum {
122  Not_Allowed = 0,
123  Allowed = 1,
124
125  // Tag_ARM_ISA_use (=8), uleb128
126
127  // Tag_THUMB_ISA_use, (=9), uleb128
128  AllowThumb32 = 2, // 32-bit Thumb (implies 16-bit instructions)
129
130  // Tag_FP_arch (=10), uleb128 (formerly Tag_VFP_arch = 10)
131  AllowFPv2  = 2,     // v2 FP ISA permitted (implies use of the v1 FP ISA)
132  AllowFPv3A = 3,     // v3 FP ISA permitted (implies use of the v2 FP ISA)
133  AllowFPv3B = 4,     // v3 FP ISA permitted, but only D0-D15, S0-S31
134  AllowFPv4A = 5,     // v4 FP ISA permitted (implies use of v3 FP ISA)
135  AllowFPv4B = 6,     // v4 FP ISA was permitted, but only D0-D15, S0-S31
136  AllowFPARMv8A = 7,  // Use of the ARM v8-A FP ISA was permitted
137  AllowFPARMv8B = 8,  // Use of the ARM v8-A FP ISA was permitted, but only
138                      // D0-D15, S0-S31
139
140  // Tag_WMMX_arch, (=11), uleb128
141  AllowWMMXv1 = 1,  // The user permitted this entity to use WMMX v1
142  AllowWMMXv2 = 2,  // The user permitted this entity to use WMMX v2
143
144  // Tag_Advanced_SIMD_arch, (=12), uleb128
145  AllowNeon = 1,      // SIMDv1 was permitted
146  AllowNeon2 = 2,     // SIMDv2 was permitted (Half-precision FP, MAC operations)
147  AllowNeonARMv8 = 3, // ARM v8-A SIMD was permitted
148
149  // Tag_ABI_PCS_RW_data, (=15), uleb128
150  AddressRWPCRel = 1, // Address RW static data PC-relative
151  AddressRWSBRel = 2, // Address RW static data SB-relative
152  AddressRWNone = 3, // No RW static data permitted
153
154  // Tag_ABI_PCS_RO_data, (=14), uleb128
155  AddressROPCRel = 1, // Address RO static data PC-relative
156  AddressRONone = 2, // No RO static data permitted
157
158  // Tag_ABI_PCS_GOT_use, (=17), uleb128
159  AddressDirect = 1, // Address imported data directly
160  AddressGOT = 2, // Address imported data indirectly (via GOT)
161
162  // Tag_ABI_PCS_wchar_t, (=18), uleb128
163  WCharProhibited = 0,  // wchar_t is not used
164  WCharWidth2Bytes = 2, // sizeof(wchar_t) == 2
165  WCharWidth4Bytes = 4, // sizeof(wchar_t) == 4
166
167  // Tag_ABI_FP_denormal, (=20), uleb128
168  PreserveFPSign = 2, // sign when flushed-to-zero is preserved
169
170  // Tag_ABI_FP_number_model, (=23), uleb128
171  AllowRTABI = 2,  // numbers, infinities, and one quiet NaN (see [RTABI])
172  AllowIEE754 = 3, // this code to use all the IEEE 754-defined FP encodings
173
174  // Tag_ABI_enum_size, (=26), uleb128
175  EnumProhibited = 0, // The user prohibited the use of enums when building
176                      // this entity.
177  EnumSmallest = 1,   // Enum is smallest container big enough to hold all
178                      // values.
179  Enum32Bit = 2,      // Enum is at least 32 bits.
180  Enum32BitABI = 3,   // Every enumeration visible across an ABI-complying
181                      // interface contains a value needing 32 bits to encode
182                      // it; other enums can be containerized.
183
184  // Tag_ABI_HardFP_use, (=27), uleb128
185  HardFPImplied = 0,          // FP use should be implied by Tag_FP_arch
186  HardFPSinglePrecision = 1,  // Single-precision only
187
188  // Tag_ABI_VFP_args, (=28), uleb128
189  BaseAAPCS = 0,
190  HardFPAAPCS = 1,
191
192  // Tag_FP_HP_extension, (=36), uleb128
193  AllowHPFP = 1, // Allow use of Half Precision FP
194
195  // Tag_MPextension_use, (=42), uleb128
196  AllowMP = 1, // Allow use of MP extensions
197
198  // Tag_DIV_use, (=44), uleb128
199  // Note: AllowDIVExt must be emitted if and only if the permission to use
200  // hardware divide cannot be conveyed using AllowDIVIfExists or DisallowDIV
201  AllowDIVIfExists = 0, // Allow hardware divide if available in arch, or no
202                        // info exists.
203  DisallowDIV = 1,      // Hardware divide explicitly disallowed.
204  AllowDIVExt = 2,      // Allow hardware divide as optional architecture
205                        // extension above the base arch specified by
206                        // Tag_CPU_arch and Tag_CPU_arch_profile.
207
208  // Tag_Virtualization_use, (=68), uleb128
209  AllowTZ = 1,
210  AllowVirtualization = 2,
211  AllowTZVirtualization = 3
212};
213
214} // namespace ARMBuildAttrs
215} // namespace llvm
216
217#endif // LLVM_SUPPORT_ARM_BUILD_ATTRIBUTES_H
218