[llvm-exegesis] [NFC] Fixing typo.
[llvm-complete.git] / lib / Support / ARMBuildAttrs.cpp
blobf5fb64bb7ba6926555d45902a06c56fef053514f
1 //===-- ARMBuildAttrs.cpp - ARM Build Attributes --------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ADT/StringRef.h"
10 #include "llvm/Support/ARMBuildAttributes.h"
12 using namespace llvm;
14 namespace {
15 const struct {
16 ARMBuildAttrs::AttrType Attr;
17 StringRef TagName;
18 } ARMAttributeTags[] = {
19 { ARMBuildAttrs::File, "Tag_File" },
20 { ARMBuildAttrs::Section, "Tag_Section" },
21 { ARMBuildAttrs::Symbol, "Tag_Symbol" },
22 { ARMBuildAttrs::CPU_raw_name, "Tag_CPU_raw_name" },
23 { ARMBuildAttrs::CPU_name, "Tag_CPU_name" },
24 { ARMBuildAttrs::CPU_arch, "Tag_CPU_arch" },
25 { ARMBuildAttrs::CPU_arch_profile, "Tag_CPU_arch_profile" },
26 { ARMBuildAttrs::ARM_ISA_use, "Tag_ARM_ISA_use" },
27 { ARMBuildAttrs::THUMB_ISA_use, "Tag_THUMB_ISA_use" },
28 { ARMBuildAttrs::FP_arch, "Tag_FP_arch" },
29 { ARMBuildAttrs::WMMX_arch, "Tag_WMMX_arch" },
30 { ARMBuildAttrs::Advanced_SIMD_arch, "Tag_Advanced_SIMD_arch" },
31 { ARMBuildAttrs::PCS_config, "Tag_PCS_config" },
32 { ARMBuildAttrs::ABI_PCS_R9_use, "Tag_ABI_PCS_R9_use" },
33 { ARMBuildAttrs::ABI_PCS_RW_data, "Tag_ABI_PCS_RW_data" },
34 { ARMBuildAttrs::ABI_PCS_RO_data, "Tag_ABI_PCS_RO_data" },
35 { ARMBuildAttrs::ABI_PCS_GOT_use, "Tag_ABI_PCS_GOT_use" },
36 { ARMBuildAttrs::ABI_PCS_wchar_t, "Tag_ABI_PCS_wchar_t" },
37 { ARMBuildAttrs::ABI_FP_rounding, "Tag_ABI_FP_rounding" },
38 { ARMBuildAttrs::ABI_FP_denormal, "Tag_ABI_FP_denormal" },
39 { ARMBuildAttrs::ABI_FP_exceptions, "Tag_ABI_FP_exceptions" },
40 { ARMBuildAttrs::ABI_FP_user_exceptions, "Tag_ABI_FP_user_exceptions" },
41 { ARMBuildAttrs::ABI_FP_number_model, "Tag_ABI_FP_number_model" },
42 { ARMBuildAttrs::ABI_align_needed, "Tag_ABI_align_needed" },
43 { ARMBuildAttrs::ABI_align_preserved, "Tag_ABI_align_preserved" },
44 { ARMBuildAttrs::ABI_enum_size, "Tag_ABI_enum_size" },
45 { ARMBuildAttrs::ABI_HardFP_use, "Tag_ABI_HardFP_use" },
46 { ARMBuildAttrs::ABI_VFP_args, "Tag_ABI_VFP_args" },
47 { ARMBuildAttrs::ABI_WMMX_args, "Tag_ABI_WMMX_args" },
48 { ARMBuildAttrs::ABI_optimization_goals, "Tag_ABI_optimization_goals" },
49 { ARMBuildAttrs::ABI_FP_optimization_goals, "Tag_ABI_FP_optimization_goals" },
50 { ARMBuildAttrs::compatibility, "Tag_compatibility" },
51 { ARMBuildAttrs::CPU_unaligned_access, "Tag_CPU_unaligned_access" },
52 { ARMBuildAttrs::FP_HP_extension, "Tag_FP_HP_extension" },
53 { ARMBuildAttrs::ABI_FP_16bit_format, "Tag_ABI_FP_16bit_format" },
54 { ARMBuildAttrs::MPextension_use, "Tag_MPextension_use" },
55 { ARMBuildAttrs::DIV_use, "Tag_DIV_use" },
56 { ARMBuildAttrs::DSP_extension, "Tag_DSP_extension" },
57 { ARMBuildAttrs::nodefaults, "Tag_nodefaults" },
58 { ARMBuildAttrs::also_compatible_with, "Tag_also_compatible_with" },
59 { ARMBuildAttrs::T2EE_use, "Tag_T2EE_use" },
60 { ARMBuildAttrs::conformance, "Tag_conformance" },
61 { ARMBuildAttrs::Virtualization_use, "Tag_Virtualization_use" },
63 // Legacy Names
64 { ARMBuildAttrs::FP_arch, "Tag_VFP_arch" },
65 { ARMBuildAttrs::FP_HP_extension, "Tag_VFP_HP_extension" },
66 { ARMBuildAttrs::ABI_align_needed, "Tag_ABI_align8_needed" },
67 { ARMBuildAttrs::ABI_align_preserved, "Tag_ABI_align8_preserved" },
71 namespace llvm {
72 namespace ARMBuildAttrs {
73 StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix) {
74 return AttrTypeAsString(static_cast<AttrType>(Attr), HasTagPrefix);
77 StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix) {
78 for (unsigned TI = 0, TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags);
79 TI != TE; ++TI)
80 if (ARMAttributeTags[TI].Attr == Attr) {
81 auto TagName = ARMAttributeTags[TI].TagName;
82 return HasTagPrefix ? TagName : TagName.drop_front(4);
84 return "";
87 int AttrTypeFromString(StringRef Tag) {
88 bool HasTagPrefix = Tag.startswith("Tag_");
89 for (unsigned TI = 0,
90 TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags);
91 TI != TE; ++TI) {
92 auto TagName = ARMAttributeTags[TI].TagName;
93 if (TagName.drop_front(HasTagPrefix ? 0 : 4) == Tag) {
94 return ARMAttributeTags[TI].Attr;
97 return -1;