1 //===--- ARMAttributeParser.h - ARM Attribute Information Printer ---------===// 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 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_SUPPORT_ARMATTRIBUTEPARSER_H 10 #define LLVM_SUPPORT_ARMATTRIBUTEPARSER_H 11 12 #include "ARMBuildAttributes.h" 13 #include "ScopedPrinter.h" 14 15 #include <map> 16 17 namespace llvm { 18 class StringRef; 19 20 class ARMAttributeParser { 21 ScopedPrinter *SW; 22 23 std::map<unsigned, unsigned> Attributes; 24 25 struct DisplayHandler { 26 ARMBuildAttrs::AttrType Attribute; 27 void (ARMAttributeParser::*Routine)(ARMBuildAttrs::AttrType, 28 const uint8_t *, uint32_t &); 29 }; 30 static const DisplayHandler DisplayRoutines[]; 31 32 uint64_t ParseInteger(const uint8_t *Data, uint32_t &Offset); 33 StringRef ParseString(const uint8_t *Data, uint32_t &Offset); 34 35 void IntegerAttribute(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 36 uint32_t &Offset); 37 void StringAttribute(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 38 uint32_t &Offset); 39 40 void PrintAttribute(unsigned Tag, unsigned Value, StringRef ValueDesc); 41 42 void CPU_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 43 uint32_t &Offset); 44 void CPU_arch_profile(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 45 uint32_t &Offset); 46 void ARM_ISA_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 47 uint32_t &Offset); 48 void THUMB_ISA_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 49 uint32_t &Offset); 50 void FP_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 51 uint32_t &Offset); 52 void WMMX_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 53 uint32_t &Offset); 54 void Advanced_SIMD_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 55 uint32_t &Offset); 56 void MVE_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 57 uint32_t &Offset); 58 void PCS_config(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 59 uint32_t &Offset); 60 void ABI_PCS_R9_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 61 uint32_t &Offset); 62 void ABI_PCS_RW_data(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 63 uint32_t &Offset); 64 void ABI_PCS_RO_data(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 65 uint32_t &Offset); 66 void ABI_PCS_GOT_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 67 uint32_t &Offset); 68 void ABI_PCS_wchar_t(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 69 uint32_t &Offset); 70 void ABI_FP_rounding(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 71 uint32_t &Offset); 72 void ABI_FP_denormal(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 73 uint32_t &Offset); 74 void ABI_FP_exceptions(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 75 uint32_t &Offset); 76 void ABI_FP_user_exceptions(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 77 uint32_t &Offset); 78 void ABI_FP_number_model(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 79 uint32_t &Offset); 80 void ABI_align_needed(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 81 uint32_t &Offset); 82 void ABI_align_preserved(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 83 uint32_t &Offset); 84 void ABI_enum_size(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 85 uint32_t &Offset); 86 void ABI_HardFP_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 87 uint32_t &Offset); 88 void ABI_VFP_args(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 89 uint32_t &Offset); 90 void ABI_WMMX_args(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 91 uint32_t &Offset); 92 void ABI_optimization_goals(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 93 uint32_t &Offset); 94 void ABI_FP_optimization_goals(ARMBuildAttrs::AttrType Tag, 95 const uint8_t *Data, uint32_t &Offset); 96 void compatibility(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 97 uint32_t &Offset); 98 void CPU_unaligned_access(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 99 uint32_t &Offset); 100 void FP_HP_extension(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 101 uint32_t &Offset); 102 void ABI_FP_16bit_format(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 103 uint32_t &Offset); 104 void MPextension_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 105 uint32_t &Offset); 106 void DIV_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 107 uint32_t &Offset); 108 void DSP_extension(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 109 uint32_t &Offset); 110 void T2EE_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 111 uint32_t &Offset); 112 void Virtualization_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 113 uint32_t &Offset); 114 void nodefaults(ARMBuildAttrs::AttrType Tag, const uint8_t *Data, 115 uint32_t &Offset); 116 117 void ParseAttributeList(const uint8_t *Data, uint32_t &Offset, 118 uint32_t Length); 119 void ParseIndexList(const uint8_t *Data, uint32_t &Offset, 120 SmallVectorImpl<uint8_t> &IndexList); 121 void ParseSubsection(const uint8_t *Data, uint32_t Length); 122 public: ARMAttributeParser(ScopedPrinter * SW)123 ARMAttributeParser(ScopedPrinter *SW) : SW(SW) {} 124 ARMAttributeParser()125 ARMAttributeParser() : SW(nullptr) { } 126 127 void Parse(ArrayRef<uint8_t> Section, bool isLittle); 128 hasAttribute(unsigned Tag)129 bool hasAttribute(unsigned Tag) const { 130 return Attributes.count(Tag); 131 } 132 getAttributeValue(unsigned Tag)133 unsigned getAttributeValue(unsigned Tag) const { 134 return Attributes.find(Tag)->second; 135 } 136 }; 137 138 } 139 140 #endif 141 142