LLVM API Documentation
00001 //===-- ARMBuildAttrs.cpp - ARM Build Attributes --------------------------===// 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 #include "llvm/Support/ARMBuildAttributes.h" 00011 #include "llvm/ADT/StringRef.h" 00012 00013 using namespace llvm; 00014 00015 namespace { 00016 const struct { 00017 ARMBuildAttrs::AttrType Attr; 00018 const char *TagName; 00019 } ARMAttributeTags[] = { 00020 { ARMBuildAttrs::File, "Tag_File" }, 00021 { ARMBuildAttrs::Section, "Tag_Section" }, 00022 { ARMBuildAttrs::Symbol, "Tag_Symbol" }, 00023 { ARMBuildAttrs::CPU_raw_name, "Tag_CPU_raw_name" }, 00024 { ARMBuildAttrs::CPU_name, "Tag_CPU_name" }, 00025 { ARMBuildAttrs::CPU_arch, "Tag_CPU_arch" }, 00026 { ARMBuildAttrs::CPU_arch_profile, "Tag_CPU_arch_profile" }, 00027 { ARMBuildAttrs::ARM_ISA_use, "Tag_ARM_ISA_use" }, 00028 { ARMBuildAttrs::THUMB_ISA_use, "Tag_THUMB_ISA_use" }, 00029 { ARMBuildAttrs::FP_arch, "Tag_FP_arch" }, 00030 { ARMBuildAttrs::WMMX_arch, "Tag_WMMX_arch" }, 00031 { ARMBuildAttrs::Advanced_SIMD_arch, "Tag_Advanced_SIMD_arch" }, 00032 { ARMBuildAttrs::PCS_config, "Tag_PCS_config" }, 00033 { ARMBuildAttrs::ABI_PCS_R9_use, "Tag_ABI_PCS_R9_use" }, 00034 { ARMBuildAttrs::ABI_PCS_RW_data, "Tag_ABI_PCS_RW_data" }, 00035 { ARMBuildAttrs::ABI_PCS_RO_data, "Tag_ABI_PCS_RO_data" }, 00036 { ARMBuildAttrs::ABI_PCS_GOT_use, "Tag_ABI_PCS_GOT_use" }, 00037 { ARMBuildAttrs::ABI_PCS_wchar_t, "Tag_ABI_PCS_wchar_t" }, 00038 { ARMBuildAttrs::ABI_FP_rounding, "Tag_ABI_FP_rounding" }, 00039 { ARMBuildAttrs::ABI_FP_denormal, "Tag_ABI_FP_denormal" }, 00040 { ARMBuildAttrs::ABI_FP_exceptions, "Tag_ABI_FP_exceptions" }, 00041 { ARMBuildAttrs::ABI_FP_user_exceptions, "Tag_ABI_FP_user_exceptions" }, 00042 { ARMBuildAttrs::ABI_FP_number_model, "Tag_ABI_FP_number_model" }, 00043 { ARMBuildAttrs::ABI_align_needed, "Tag_ABI_align_needed" }, 00044 { ARMBuildAttrs::ABI_align_preserved, "Tag_ABI_align_preserved" }, 00045 { ARMBuildAttrs::ABI_enum_size, "Tag_ABI_enum_size" }, 00046 { ARMBuildAttrs::ABI_HardFP_use, "Tag_ABI_HardFP_use" }, 00047 { ARMBuildAttrs::ABI_VFP_args, "Tag_ABI_VFP_args" }, 00048 { ARMBuildAttrs::ABI_WMMX_args, "Tag_ABI_WMMX_args" }, 00049 { ARMBuildAttrs::ABI_optimization_goals, "Tag_ABI_optimization_goals" }, 00050 { ARMBuildAttrs::ABI_FP_optimization_goals, "Tag_ABI_FP_optimization_goals" }, 00051 { ARMBuildAttrs::compatibility, "Tag_compatibility" }, 00052 { ARMBuildAttrs::CPU_unaligned_access, "Tag_CPU_unaligned_access" }, 00053 { ARMBuildAttrs::FP_HP_extension, "Tag_FP_HP_extension" }, 00054 { ARMBuildAttrs::ABI_FP_16bit_format, "Tag_ABI_FP_16bit_format" }, 00055 { ARMBuildAttrs::MPextension_use, "Tag_MPextension_use" }, 00056 { ARMBuildAttrs::DIV_use, "Tag_DIV_use" }, 00057 { ARMBuildAttrs::nodefaults, "Tag_nodefaults" }, 00058 { ARMBuildAttrs::also_compatible_with, "Tag_also_compatible_with" }, 00059 { ARMBuildAttrs::T2EE_use, "Tag_T2EE_use" }, 00060 { ARMBuildAttrs::conformance, "Tag_conformance" }, 00061 { ARMBuildAttrs::Virtualization_use, "Tag_Virtualization_use" }, 00062 00063 // Legacy Names 00064 { ARMBuildAttrs::FP_arch, "Tag_VFP_arch" }, 00065 { ARMBuildAttrs::FP_HP_extension, "Tag_VFP_HP_extension" }, 00066 { ARMBuildAttrs::ABI_align_needed, "Tag_ABI_align8_needed" }, 00067 { ARMBuildAttrs::ABI_align_preserved, "Tag_ABI_align8_preserved" }, 00068 }; 00069 } 00070 00071 namespace llvm { 00072 namespace ARMBuildAttrs { 00073 StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix) { 00074 return AttrTypeAsString(static_cast<AttrType>(Attr), HasTagPrefix); 00075 } 00076 00077 StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix) { 00078 for (unsigned TI = 0, TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags); 00079 TI != TE; ++TI) 00080 if (ARMAttributeTags[TI].Attr == Attr) 00081 return ARMAttributeTags[TI].TagName + (HasTagPrefix ? 0 : 4); 00082 return ""; 00083 } 00084 00085 int AttrTypeFromString(StringRef Tag) { 00086 bool HasTagPrefix = Tag.startswith("Tag_"); 00087 for (unsigned TI = 0, TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags); 00088 TI != TE; ++TI) 00089 if (StringRef(ARMAttributeTags[TI].TagName + (HasTagPrefix ? 0 : 4)) == Tag) 00090 return ARMAttributeTags[TI].Attr; 00091 return -1; 00092 } 00093 } 00094 } 00095