LLVM API Documentation

ARMBuildAttributes.h
Go to the documentation of this file.
00001 //===-- ARMBuildAttributes.h - ARM Build Attributes -------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains enumerations and support routines for ARM build attributes
00011 // as defined in ARM ABI addenda document (ABI release 2.08).
00012 //
00013 // ELF for the ARM Architecture r2.09 - November 30, 2012
00014 //
00015 // http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf
00016 //
00017 //===----------------------------------------------------------------------===//
00018 
00019 #ifndef LLVM_SUPPORT_ARMBUILDATTRIBUTES_H
00020 #define LLVM_SUPPORT_ARMBUILDATTRIBUTES_H
00021 
00022 namespace llvm {
00023 class StringRef;
00024 
00025 namespace ARMBuildAttrs {
00026 
00027 enum SpecialAttr {
00028   // This is for the .cpu asm attr. It translates into one or more
00029   // AttrType (below) entries in the .ARM.attributes section in the ELF.
00030   SEL_CPU
00031 };
00032 
00033 enum AttrType {
00034   // Rest correspond to ELF/.ARM.attributes
00035   File                      = 1,
00036   CPU_raw_name              = 4,
00037   CPU_name                  = 5,
00038   CPU_arch                  = 6,
00039   CPU_arch_profile          = 7,
00040   ARM_ISA_use               = 8,
00041   THUMB_ISA_use             = 9,
00042   FP_arch                   = 10,
00043   WMMX_arch                 = 11,
00044   Advanced_SIMD_arch        = 12,
00045   PCS_config                = 13,
00046   ABI_PCS_R9_use            = 14,
00047   ABI_PCS_RW_data           = 15,
00048   ABI_PCS_RO_data           = 16,
00049   ABI_PCS_GOT_use           = 17,
00050   ABI_PCS_wchar_t           = 18,
00051   ABI_FP_rounding           = 19,
00052   ABI_FP_denormal           = 20,
00053   ABI_FP_exceptions         = 21,
00054   ABI_FP_user_exceptions    = 22,
00055   ABI_FP_number_model       = 23,
00056   ABI_align_needed          = 24,
00057   ABI_align_preserved       = 25,
00058   ABI_enum_size             = 26,
00059   ABI_HardFP_use            = 27,
00060   ABI_VFP_args              = 28,
00061   ABI_WMMX_args             = 29,
00062   ABI_optimization_goals    = 30,
00063   ABI_FP_optimization_goals = 31,
00064   compatibility             = 32,
00065   CPU_unaligned_access      = 34,
00066   FP_HP_extension           = 36,
00067   ABI_FP_16bit_format       = 38,
00068   MPextension_use           = 42, // recoded from 70 (ABI r2.08)
00069   DIV_use                   = 44,
00070   also_compatible_with      = 65,
00071   conformance               = 67,
00072   Virtualization_use        = 68,
00073 
00074   /// Legacy Tags
00075   Section                   = 2,  // deprecated (ABI r2.09)
00076   Symbol                    = 3,  // deprecated (ABI r2.09)
00077   ABI_align8_needed         = 24, // renamed to ABI_align_needed (ABI r2.09)
00078   ABI_align8_preserved      = 25, // renamed to ABI_align_preserved (ABI r2.09)
00079   nodefaults                = 64, // deprecated (ABI r2.09)
00080   T2EE_use                  = 66, // deprecated (ABI r2.09)
00081   MPextension_use_old       = 70  // recoded to MPextension_use (ABI r2.08)
00082 };
00083 
00084 StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix = true);
00085 StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix = true);
00086 int AttrTypeFromString(StringRef Tag);
00087 
00088 // Magic numbers for .ARM.attributes
00089 enum AttrMagic {
00090   Format_Version  = 0x41
00091 };
00092 
00093 // Legal Values for CPU_arch, (=6), uleb128
00094 enum CPUArch {
00095   Pre_v4   = 0,
00096   v4       = 1,   // e.g. SA110
00097   v4T      = 2,   // e.g. ARM7TDMI
00098   v5T      = 3,   // e.g. ARM9TDMI
00099   v5TE     = 4,   // e.g. ARM946E_S
00100   v5TEJ    = 5,   // e.g. ARM926EJ_S
00101   v6       = 6,   // e.g. ARM1136J_S
00102   v6KZ     = 7,   // e.g. ARM1176JZ_S
00103   v6T2     = 8,   // e.g. ARM1156T2F_S
00104   v6K      = 9,   // e.g. ARM1136J_S
00105   v7       = 10,  // e.g. Cortex A8, Cortex M3
00106   v6_M     = 11,  // e.g. Cortex M1
00107   v6S_M    = 12,  // v6_M with the System extensions
00108   v7E_M    = 13,  // v7_M with DSP extensions
00109   v8       = 14   // v8, AArch32
00110 };
00111 
00112 enum CPUArchProfile {               // (=7), uleb128
00113   Not_Applicable          = 0,      // pre v7, or cross-profile code
00114   ApplicationProfile      = (0x41), // 'A' (e.g. for Cortex A8)
00115   RealTimeProfile         = (0x52), // 'R' (e.g. for Cortex R4)
00116   MicroControllerProfile  = (0x4D), // 'M' (e.g. for Cortex M3)
00117   SystemProfile           = (0x53)  // 'S' Application or real-time profile
00118 };
00119 
00120 // The following have a lot of common use cases
00121 enum {
00122   Not_Allowed = 0,
00123   Allowed = 1,
00124 
00125   // Tag_ARM_ISA_use (=8), uleb128
00126 
00127   // Tag_THUMB_ISA_use, (=9), uleb128
00128   AllowThumb32 = 2, // 32-bit Thumb (implies 16-bit instructions)
00129 
00130   // Tag_FP_arch (=10), uleb128 (formerly Tag_VFP_arch = 10)
00131   AllowFPv2  = 2,     // v2 FP ISA permitted (implies use of the v1 FP ISA)
00132   AllowFPv3A = 3,     // v3 FP ISA permitted (implies use of the v2 FP ISA)
00133   AllowFPv3B = 4,     // v3 FP ISA permitted, but only D0-D15, S0-S31
00134   AllowFPv4A = 5,     // v4 FP ISA permitted (implies use of v3 FP ISA)
00135   AllowFPv4B = 6,     // v4 FP ISA was permitted, but only D0-D15, S0-S31
00136   AllowFPARMv8A = 7,  // Use of the ARM v8-A FP ISA was permitted
00137   AllowFPARMv8B = 8,  // Use of the ARM v8-A FP ISA was permitted, but only
00138                       // D0-D15, S0-S31
00139 
00140   // Tag_WMMX_arch, (=11), uleb128
00141   AllowWMMXv1 = 1,  // The user permitted this entity to use WMMX v1
00142   AllowWMMXv2 = 2,  // The user permitted this entity to use WMMX v2
00143 
00144   // Tag_Advanced_SIMD_arch, (=12), uleb128
00145   AllowNeon = 1,      // SIMDv1 was permitted
00146   AllowNeon2 = 2,     // SIMDv2 was permitted (Half-precision FP, MAC operations)
00147   AllowNeonARMv8 = 3, // ARM v8-A SIMD was permitted
00148 
00149   // Tag_ABI_PCS_R9_use, (=14), uleb128
00150   R9IsGPR = 0,        // R9 used as v6 (just another callee-saved register)
00151   R9IsSB = 1,         // R9 used as a global static base rgister
00152   R9IsTLSPointer = 2, // R9 used as a thread local storage pointer
00153   R9Reserved = 3,     // R9 not used by code associated with attributed entity
00154 
00155   // Tag_ABI_PCS_RW_data, (=15), uleb128
00156   AddressRWPCRel = 1, // Address RW static data PC-relative
00157   AddressRWSBRel = 2, // Address RW static data SB-relative
00158   AddressRWNone = 3, // No RW static data permitted
00159 
00160   // Tag_ABI_PCS_RO_data, (=14), uleb128
00161   AddressROPCRel = 1, // Address RO static data PC-relative
00162   AddressRONone = 2, // No RO static data permitted
00163 
00164   // Tag_ABI_PCS_GOT_use, (=17), uleb128
00165   AddressDirect = 1, // Address imported data directly
00166   AddressGOT = 2, // Address imported data indirectly (via GOT)
00167 
00168   // Tag_ABI_PCS_wchar_t, (=18), uleb128
00169   WCharProhibited = 0,  // wchar_t is not used
00170   WCharWidth2Bytes = 2, // sizeof(wchar_t) == 2
00171   WCharWidth4Bytes = 4, // sizeof(wchar_t) == 4
00172 
00173   // Tag_ABI_FP_denormal, (=20), uleb128
00174   PreserveFPSign = 2, // sign when flushed-to-zero is preserved
00175 
00176   // Tag_ABI_FP_number_model, (=23), uleb128
00177   AllowRTABI = 2,  // numbers, infinities, and one quiet NaN (see [RTABI])
00178   AllowIEE754 = 3, // this code to use all the IEEE 754-defined FP encodings
00179 
00180   // Tag_ABI_enum_size, (=26), uleb128
00181   EnumProhibited = 0, // The user prohibited the use of enums when building
00182                       // this entity.
00183   EnumSmallest = 1,   // Enum is smallest container big enough to hold all
00184                       // values.
00185   Enum32Bit = 2,      // Enum is at least 32 bits.
00186   Enum32BitABI = 3,   // Every enumeration visible across an ABI-complying
00187                       // interface contains a value needing 32 bits to encode
00188                       // it; other enums can be containerized.
00189 
00190   // Tag_ABI_HardFP_use, (=27), uleb128
00191   HardFPImplied = 0,          // FP use should be implied by Tag_FP_arch
00192   HardFPSinglePrecision = 1,  // Single-precision only
00193 
00194   // Tag_ABI_VFP_args, (=28), uleb128
00195   BaseAAPCS = 0,
00196   HardFPAAPCS = 1,
00197 
00198   // Tag_FP_HP_extension, (=36), uleb128
00199   AllowHPFP = 1, // Allow use of Half Precision FP
00200 
00201   // Tag_MPextension_use, (=42), uleb128
00202   AllowMP = 1, // Allow use of MP extensions
00203 
00204   // Tag_DIV_use, (=44), uleb128
00205   // Note: AllowDIVExt must be emitted if and only if the permission to use
00206   // hardware divide cannot be conveyed using AllowDIVIfExists or DisallowDIV
00207   AllowDIVIfExists = 0, // Allow hardware divide if available in arch, or no
00208                         // info exists.
00209   DisallowDIV = 1,      // Hardware divide explicitly disallowed.
00210   AllowDIVExt = 2,      // Allow hardware divide as optional architecture
00211                         // extension above the base arch specified by
00212                         // Tag_CPU_arch and Tag_CPU_arch_profile.
00213 
00214   // Tag_Virtualization_use, (=68), uleb128
00215   AllowTZ = 1,
00216   AllowVirtualization = 2,
00217   AllowTZVirtualization = 3
00218 };
00219 
00220 } // namespace ARMBuildAttrs
00221 } // namespace llvm
00222 
00223 #endif