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