• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- ARMBuildAttrs.cpp - ARM Build Attributes --------------------------===//
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 #include "llvm/ADT/StringRef.h"
11 #include "llvm/Support/ARMBuildAttributes.h"
12 
13 using namespace llvm;
14 
15 namespace {
16 const struct {
17   ARMBuildAttrs::AttrType Attr;
18   StringRef TagName;
19 } ARMAttributeTags[] = {
20   { ARMBuildAttrs::File, "Tag_File" },
21   { ARMBuildAttrs::Section, "Tag_Section" },
22   { ARMBuildAttrs::Symbol, "Tag_Symbol" },
23   { ARMBuildAttrs::CPU_raw_name, "Tag_CPU_raw_name" },
24   { ARMBuildAttrs::CPU_name, "Tag_CPU_name" },
25   { ARMBuildAttrs::CPU_arch, "Tag_CPU_arch" },
26   { ARMBuildAttrs::CPU_arch_profile, "Tag_CPU_arch_profile" },
27   { ARMBuildAttrs::ARM_ISA_use, "Tag_ARM_ISA_use" },
28   { ARMBuildAttrs::THUMB_ISA_use, "Tag_THUMB_ISA_use" },
29   { ARMBuildAttrs::FP_arch, "Tag_FP_arch" },
30   { ARMBuildAttrs::WMMX_arch, "Tag_WMMX_arch" },
31   { ARMBuildAttrs::Advanced_SIMD_arch, "Tag_Advanced_SIMD_arch" },
32   { ARMBuildAttrs::PCS_config, "Tag_PCS_config" },
33   { ARMBuildAttrs::ABI_PCS_R9_use, "Tag_ABI_PCS_R9_use" },
34   { ARMBuildAttrs::ABI_PCS_RW_data, "Tag_ABI_PCS_RW_data" },
35   { ARMBuildAttrs::ABI_PCS_RO_data, "Tag_ABI_PCS_RO_data" },
36   { ARMBuildAttrs::ABI_PCS_GOT_use, "Tag_ABI_PCS_GOT_use" },
37   { ARMBuildAttrs::ABI_PCS_wchar_t, "Tag_ABI_PCS_wchar_t" },
38   { ARMBuildAttrs::ABI_FP_rounding, "Tag_ABI_FP_rounding" },
39   { ARMBuildAttrs::ABI_FP_denormal, "Tag_ABI_FP_denormal" },
40   { ARMBuildAttrs::ABI_FP_exceptions, "Tag_ABI_FP_exceptions" },
41   { ARMBuildAttrs::ABI_FP_user_exceptions, "Tag_ABI_FP_user_exceptions" },
42   { ARMBuildAttrs::ABI_FP_number_model, "Tag_ABI_FP_number_model" },
43   { ARMBuildAttrs::ABI_align_needed, "Tag_ABI_align_needed" },
44   { ARMBuildAttrs::ABI_align_preserved, "Tag_ABI_align_preserved" },
45   { ARMBuildAttrs::ABI_enum_size, "Tag_ABI_enum_size" },
46   { ARMBuildAttrs::ABI_HardFP_use, "Tag_ABI_HardFP_use" },
47   { ARMBuildAttrs::ABI_VFP_args, "Tag_ABI_VFP_args" },
48   { ARMBuildAttrs::ABI_WMMX_args, "Tag_ABI_WMMX_args" },
49   { ARMBuildAttrs::ABI_optimization_goals, "Tag_ABI_optimization_goals" },
50   { ARMBuildAttrs::ABI_FP_optimization_goals, "Tag_ABI_FP_optimization_goals" },
51   { ARMBuildAttrs::compatibility, "Tag_compatibility" },
52   { ARMBuildAttrs::CPU_unaligned_access, "Tag_CPU_unaligned_access" },
53   { ARMBuildAttrs::FP_HP_extension, "Tag_FP_HP_extension" },
54   { ARMBuildAttrs::ABI_FP_16bit_format, "Tag_ABI_FP_16bit_format" },
55   { ARMBuildAttrs::MPextension_use, "Tag_MPextension_use" },
56   { ARMBuildAttrs::DIV_use, "Tag_DIV_use" },
57   { ARMBuildAttrs::DSP_extension, "Tag_DSP_extension" },
58   { ARMBuildAttrs::nodefaults, "Tag_nodefaults" },
59   { ARMBuildAttrs::also_compatible_with, "Tag_also_compatible_with" },
60   { ARMBuildAttrs::T2EE_use, "Tag_T2EE_use" },
61   { ARMBuildAttrs::conformance, "Tag_conformance" },
62   { ARMBuildAttrs::Virtualization_use, "Tag_Virtualization_use" },
63 
64   // Legacy Names
65   { ARMBuildAttrs::FP_arch, "Tag_VFP_arch" },
66   { ARMBuildAttrs::FP_HP_extension, "Tag_VFP_HP_extension" },
67   { ARMBuildAttrs::ABI_align_needed, "Tag_ABI_align8_needed" },
68   { ARMBuildAttrs::ABI_align_preserved, "Tag_ABI_align8_preserved" },
69 };
70 }
71 
72 namespace llvm {
73 namespace ARMBuildAttrs {
AttrTypeAsString(unsigned Attr,bool HasTagPrefix)74 StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix) {
75   return AttrTypeAsString(static_cast<AttrType>(Attr), HasTagPrefix);
76 }
77 
AttrTypeAsString(AttrType Attr,bool HasTagPrefix)78 StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix) {
79   for (unsigned TI = 0, TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags);
80        TI != TE; ++TI)
81     if (ARMAttributeTags[TI].Attr == Attr) {
82       auto TagName = ARMAttributeTags[TI].TagName;
83       return HasTagPrefix ? TagName : TagName.drop_front(4);
84     }
85   return "";
86 }
87 
AttrTypeFromString(StringRef Tag)88 int AttrTypeFromString(StringRef Tag) {
89   bool HasTagPrefix = Tag.startswith("Tag_");
90   for (unsigned TI = 0,
91                 TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags);
92        TI != TE; ++TI) {
93     auto TagName = ARMAttributeTags[TI].TagName;
94     if (TagName.drop_front(HasTagPrefix ? 0 : 4) == Tag) {
95       return ARMAttributeTags[TI].Attr;
96     }
97   }
98   return -1;
99 }
100 }
101 }
102 
103