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