Remove some uneeded pseudos in the presence of the naked function attribute.
[oota-llvm.git] / include / llvm / Object / ELF_ARM.h
1 //===-- ELF_ARM.h - ARM ELF ABI ---------------------------------*- 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 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_OBJECT_ELF_ARM_H
16 #define LLVM_OBJECT_ELF_ARM_H
17
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/Support/Endian.h"
20
21 namespace llvm {
22
23 namespace ARMBuildAttrs {
24 enum SpecialAttr {
25   // This is for the .cpu asm attr. It translates into one or more
26   // AttrType (below) entries in the .ARM.attributes section in the ELF.
27   SEL_CPU
28 };
29
30 enum AttrType {
31   // Rest correspond to ELF/.ARM.attributes
32   File                      = 1,
33   Section                   = 2,
34   Symbol                    = 3,
35   CPU_raw_name              = 4,
36   CPU_name                  = 5,
37   CPU_arch                  = 6,
38   CPU_arch_profile          = 7,
39   ARM_ISA_use               = 8,
40   THUMB_ISA_use             = 9,
41   FP_arch                   = 10,
42   WMMX_arch                 = 11,
43   Advanced_SIMD_arch        = 12,
44   PCS_config                = 13,
45   ABI_PCS_R9_use            = 14,
46   ABI_PCS_RW_data           = 15,
47   ABI_PCS_RO_data           = 16,
48   ABI_PCS_GOT_use           = 17,
49   ABI_PCS_wchar_t           = 18,
50   ABI_FP_rounding           = 19,
51   ABI_FP_denormal           = 20,
52   ABI_FP_exceptions         = 21,
53   ABI_FP_user_exceptions    = 22,
54   ABI_FP_number_model       = 23,
55   ABI_align8_needed         = 24,
56   ABI_align8_preserved      = 25,
57   ABI_enum_size             = 26,
58   ABI_HardFP_use            = 27,
59   ABI_VFP_args              = 28,
60   ABI_WMMX_args             = 29,
61   ABI_optimization_goals    = 30,
62   ABI_FP_optimization_goals = 31,
63   compatibility             = 32,
64   CPU_unaligned_access      = 34,
65   FP_HP_extension           = 36,
66   ABI_FP_16bit_format       = 38,
67   MPextension_use           = 42, // was 70, 2.08 ABI
68   DIV_use                   = 44,
69   nodefaults                = 64,
70   also_compatible_with      = 65,
71   T2EE_use                  = 66,
72   conformance               = 67,
73   Virtualization_use        = 68,
74   MPextension_use_old       = 70
75 };
76
77 // Magic numbers for .ARM.attributes
78 enum AttrMagic {
79   Format_Version  = 0x41
80 };
81
82 // Legal Values for CPU_arch, (=6), uleb128
83 enum CPUArch {
84   Pre_v4       = 0,
85   v4       = 1,   // e.g. SA110
86   v4T      = 2,   // e.g. ARM7TDMI
87   v5T      = 3,   // e.g. ARM9TDMI
88   v5TE     = 4,   // e.g. ARM946E_S
89   v5TEJ    = 5,   // e.g. ARM926EJ_S
90   v6       = 6,   // e.g. ARM1136J_S
91   v6KZ     = 7,   // e.g. ARM1176JZ_S
92   v6T2     = 8,   // e.g. ARM1156T2F_S
93   v6K      = 9,   // e.g. ARM1136J_S
94   v7       = 10,  // e.g. Cortex A8, Cortex M3
95   v6_M     = 11,  // e.g. Cortex M1
96   v6S_M    = 12,  // v6_M with the System extensions
97   v7E_M    = 13,  // v7_M with DSP extensions
98   v8
99 };
100
101 enum CPUArchProfile { // (=7), uleb128
102   Not_Applicable = 0, // pre v7, or cross-profile code
103   ApplicationProfile = (0x41), // 'A' (e.g. for Cortex A8)
104   RealTimeProfile = (0x52), // 'R' (e.g. for Cortex R4)
105   MicroControllerProfile = (0x4D), // 'M' (e.g. for Cortex M3)
106   SystemProfile = (0x53) // 'S' Application or real-time profile
107 };
108
109 // The following have a lot of common use cases
110 enum {
111   //ARMISAUse (=8), uleb128  and THUMBISAUse (=9), uleb128
112   Not_Allowed = 0,
113   Allowed = 1
114 };
115
116 enum {
117   // FP_arch (=10), uleb128 (formerly Tag_VFP_arch = 10)
118   AllowFPv2  = 2, // v2 FP ISA permitted (implies use of the v1 FP ISA)
119   AllowFPv3A = 3, // v3 FP ISA permitted (implies use of the v2 FP ISA)
120   AllowFPv3B = 4, // v3 FP ISA permitted, but only D0-D15, S0-S31
121   AllowFPv4A = 5, // v4 FP ISA permitted (implies use of v3 FP ISA)
122   AllowFPv4B = 6, // v4 FP ISA was permitted, but only D0-D15, S0-S31
123   AllowV8FP  = 7, // ARMv8-A FP ISA permitted
124   AllowV8FPB = 8  // ARMv8-A FP ISA permitted, but only D0-D15, S0-D31
125 };
126
127 enum {
128   // Tag_THUMB_ISA_use, (=9), uleb128
129   AllowThumb32 = 2 // 32-bit Thumb (implies 16-bit instructions)
130 };
131
132 enum {
133   // Tag_WMMX_arch, (=11), uleb128
134   AllowWMMXv1 = 1,  // The user permitted this entity to use WMMX v1
135   AllowWMMXv2 = 2   // The user permitted this entity to use WMMX v2
136 };
137
138 enum {
139   // Tag_ABI_FP_denormal, (=20), uleb128
140   MightFlushToZero = 0, // Denormal numbers might be flushed to (+) zero
141   IEEE754Denormal = 1 , // Depends on IEEE 754 denormal numbers
142   PreserveFPSign = 2    // Sign when flushed-to-zero is preserved
143 };
144
145 enum {
146   // Tag_ABI_FP_number_model, (=23), uleb128
147   AllowNormal = 1, // Use IEEE 754 format normal numbers only
148   AllowRTABI = 2,  // numbers, infinities, and one quiet NaN (see [RTABI])
149   AllowIEE754 = 3  // this code to use all the IEEE 754-defined FP encodings
150 };
151
152 enum {
153   // Tag_ABI_FP_rounding, (=19), uleb128
154   FPRoundingNearest = 0,  // Use the IEEE 754 round to nearest rounding mode
155   FPRoundingRuntime = 1   // Choose the IEEE 754 rounding mode at run time
156 };
157
158 enum {
159   // Tag_DIV_use, (=44), uleb128
160   AllowDIVThumb = 0,  // Allow SDIV, UDIV on Thumb ISA, e.g. Cortex R4 or M3
161   NotAllowedDIV = 1,  // Disallow SDIV and UDIV
162   AllowDIVv7a   = 2   // Allow SDIV, UDIV on v7-a with integer div extension
163 };
164
165 enum {
166   // Tag_Virtualization_use, (=42), uleb128
167   TrustZone = 1,  // Use of the TrustZone extension was permitted
168   VirtExts  = 2,  // Use of virtualization extensions (HVC, ERET) permitted
169   TrustZoneVirtExts = 3  // TrustZone and virtualization extensions permitted
170 };
171
172 enum {
173   // Tag_PCS_config, (=13), uleb128
174   PCS_none = 0,  // No standard configuration used, or no information recorded
175   PCS_bare = 1,        // Bare platform configuration
176   PCS_linux = 2,       // Linux application configuration
177   PCS_linux_dso = 3,   // Linux DSO configuration
178   PCS_palm_2004 = 4,   // Palm OS 2004 configuration
179   PCS_palm_future = 5, // Reserved to future Palm OS configuration
180   PCS_symbian_2004 = 6,   // Symbian OS 2004 configuration
181   PCS_symbian_future = 7  // Reserved to future Symbian OS configuration
182 };
183
184 enum {
185   // Tag_ABI_PCS_R9_use, (=14), uleb128
186   PCS_R9_normal = 0, // R9 used as V6 (just another callee-saved register,
187                      // implied by omitting the tag)
188   PCS_R9_SB = 1,     // R9 used as SB, a global Static Base register
189   PCS_R9_TLS = 2,    // R9 used as a Thread Local Storage (TLS) pointer
190   PCS_R9_none = 3    // R9 not used at all by code associated with
191                      // the attributed entity.
192 };
193
194 enum {
195   // Tag_ABI_PCS_RW_data, (=15), uleb128
196   PCS_RW_data_abs = 0, // RW static data permitted to be addressed absolutely
197   PCS_RW_data_pcrel = 1, // RW static data was only permitted to be
198                          // addressed PC-relative.
199   PCS_RW_data_sbrel = 2, // RW static data was only permitted to be addressed
200                          // SB-relative.
201   PCS_RW_data_none = 3   // No permission to use RW static data
202 };
203
204 enum {
205   // Tag_ABI_PCS_RO_data, (=16), uleb128
206   PCS_RO_data_abs = 0,  // RO static data permitted to be addressed absolutely
207   PCS_RO_data_pcrel = 1, // RO static data was only permitted to be
208                          // addressed PC-relative.
209   PCS_RO_data_none = 2   // No permission to use RO static data
210 };
211
212 enum {
213   // Tag_ABI_PCS_GOT_use, (=17), uleb128
214   PCS_GOT_none = 0,   // No permission to import static data
215   PCS_GOT_direct = 1, // Permission to address imported data directly
216   PCS_GOT_indirect = 2  // The user permitted this entity to address imported
217                         // data indirectly (e.g. via a GOT)
218 };
219
220 enum {
221   // Tag_ABI_PCS_wchar_t, (=18), uleb128
222   PCS_wchar_t_disallowed = 0, // The user prohibited the use of wchar_t
223   PCS_wchar_t_2 = 2,          // The user intended the size of wchar_t to be 2
224   PCS_wchar_t_4 = 4           // The user intended the size of wchar_t to be 4
225 };
226
227 enum {
228   // Tag_ABI_enum_size, (=26), uleb128
229   PCS_enum_size = 1,  // Enum values occupy the smallest container big enough
230                       // to hold all their values.
231   PCS_enum_size_32 = 2, // The user intended Enum containers to be 32-bit
232   PCS_enum_size_abi32 = 3  // The user intended that every enumeration visible
233     // across an ABI-complying interface contains a value needing 32 bits to
234     // encode it; other enums can be containerized.
235 };
236
237 enum {
238   // Tag_ABI_align_needed, (=24), uleb128
239   PCS_Align_needed_disallowed = 0, //  The user did not permit code to depend
240     // the alignment of 8-byte data or data with extended (>8-byte) alignment.
241   PCS_Align_needed_8 = 1, // Code was permitted to depend on the 8-byte
242                           // alignment of 8-byte data items.
243   PCS_Align_needed_4 = 2, // Code was permitted to depend on the 4-byte
244                           // alignment of 8-byte data items.
245   PCS_Align_needed_res = 3  // Reserved
246   // OR: n (in 4..12) Code was permitted to depend on the 8-byte alignment of
247   // 8-byte data items and the alignment of data items having up to 2^n byte
248   // extended alignment.
249 };
250
251 enum {
252   // Tag_ABI_align_preserved, (=25), uleb128
253   PCS_Align_preserved_none = 0, // The user did not require code to preserve
254                                 // 8-byte alignment of 8-byte data objects.
255   PCS_Align_preserved_8 = 1, // Code was required to preserve 8-byte alignment
256                              // of 8-byte data objects.
257   PCS_Align_preserved_8sp = 2, // Code was required to preserve 8-byte
258     // alignment of 8-byte data objects and to ensure (SP MOD 8) = 0 at all
259     // instruction boundaries (not just at function calls).
260   PCS_Align_preserved_res = 3  // Reserved
261   // OR: n (in 4..12) Code was required to preserve the alignments of case 2
262   // and the alignment of data items having up to 2^n byte extended alignment
263 };
264
265 enum {
266   // Tag_ABI_HardFP_use, (=27), uleb128
267   HardFPImplied = 0,   // FP use should be implied by Tag_FP_arch
268   HardFP_SP_VFP = 1,   // Use only SP FP instructions
269   HardFP_Reserved = 2,      // Reserved
270   HardFP_ImpliedDup = 3  // Deprecated duplicate of the default HardFPImplied
271 };
272
273 enum {
274   // Tag_ABI_VFP_args, (=28), uleb128
275   VFPArgs_base = 0,  // FP parameter/result passing using AAPCS, base variant
276   VFPArgs_VFP = 1,   // FP parameter/result passing using AAPCS, VFP variant
277   VFPArgs_toolchain = 2, // FP parameter/result passing to conform to tool
278     // chain-specific conventions
279   VFPArgs_baseVFP = 3 // FP parameter/result passing using both base and VFP
280     //variants. Did not permit non-variadic functions to pass FP params/results.
281 };
282
283 /// Contains build ARM aeabi attribute values.
284 class ARMGenericBuildAttrInfo {
285 public:
286   ARMGenericBuildAttrInfo()
287     : Valid(false) {}
288
289   CPUArch Tag_CPU_arch;
290   CPUArchProfile Tag_CPU_arch_profile;
291   std::string Tag_CPU_raw_name;
292   std::string Tag_CPU_name;
293   unsigned Tag_ARM_ISA_use;
294   unsigned Tag_THUMB_ISA_use;
295   unsigned Tag_FP_arch;
296   unsigned Tag_WMMX_arch;
297   unsigned Tag_Advanced_SIMD_arch;
298   unsigned Tag_FP_HP_extension;
299   unsigned Tag_CPU_unaligned_access;
300   unsigned Tag_MPextension_use;
301   unsigned Tag_DIV_use;
302   unsigned Tag_T2EE_use;
303   unsigned Tag_Virtualization_use;
304   unsigned Tag_ABI_optimization_goals;
305   unsigned Tag_ABI_FP_optimization_goals;
306
307   //PCS/ABI attributes
308   unsigned Tag_PCS_config;
309   unsigned Tag_ABI_PCS_R9_use;
310   unsigned Tag_ABI_PCS_RW_data;
311   unsigned Tag_ABI_PCS_RO_data;
312   unsigned Tag_ABI_PCS_GOT_use;
313   unsigned Tag_ABI_PCS_wchar_t;
314   unsigned Tag_ABI_enum_size;
315   unsigned Tag_ABI_align8_needed;
316   unsigned Tag_ABI_align8_preserved;
317
318   //FP
319   unsigned Tag_ABI_FP_rounding;
320   unsigned Tag_ABI_FP_denormal;
321   unsigned Tag_ABI_FP_number_model;
322   unsigned Tag_ABI_FP_exceptions;
323   unsigned Tag_ABI_FP_user_exceptions;
324   unsigned Tag_ABI_HardFP_use;
325   unsigned Tag_ABI_VFP_args;
326
327 private:
328   bool Valid;
329
330 public:
331   /// Indicates whether this instance contains valid or default values.
332   bool isValid() { return Valid; }
333   void setValid(bool v) { Valid = v; }
334 };
335
336 }
337 } // llvm
338
339 #endif // LLVM_OBJECT_ELF_ARM_H