6781acc59a72b6e5f06088ce31544a754d6a31f5
[lldb.git] / llvm / unittests / Support / ARMAttributeParser.cpp
1 #include "llvm/Support/ARMAttributeParser.h"
2 #include "llvm/Support/ARMBuildAttributes.h"
3 #include "gtest/gtest.h"
4 #include <string>
5
6 using namespace llvm;
7
8 struct AttributeSection {
9   unsigned Tag;
10   unsigned Value;
11
12   AttributeSection(unsigned tag, unsigned value) : Tag(tag), Value(value) { }
13
14   void write(raw_ostream &OS) {
15     OS.flush();
16     // length = length + "aeabi\0" + TagFile + ByteSize + Tag + Value;
17     // length = 17 bytes
18
19     OS << 'A' << (uint8_t)17 << (uint8_t)0 << (uint8_t)0 << (uint8_t)0;
20     OS << "aeabi" << '\0';
21     OS << (uint8_t)1 << (uint8_t)7 << (uint8_t)0 << (uint8_t)0 << (uint8_t)0;
22     OS << (uint8_t)Tag << (uint8_t)Value;
23
24   }
25 };
26
27 bool testBuildAttr(unsigned Tag, unsigned Value,
28                    unsigned ExpectedTag, unsigned ExpectedValue) {
29   std::string buffer;
30   raw_string_ostream OS(buffer);
31   AttributeSection Section(Tag, Value);
32   Section.write(OS);
33   ArrayRef<uint8_t> Bytes(
34     reinterpret_cast<const uint8_t*>(OS.str().c_str()), OS.str().size());
35
36   ARMAttributeParser Parser;
37   Parser.Parse(Bytes, true);
38
39   return (Parser.hasAttribute(ExpectedTag) &&
40     Parser.getAttributeValue(ExpectedTag) == ExpectedValue);
41 }
42
43 bool testTagString(unsigned Tag, const char *name) {
44   return ARMBuildAttrs::AttrTypeAsString(Tag).str() == name;
45 }
46
47 TEST(CPUArchBuildAttr, testBuildAttr) {
48   EXPECT_TRUE(testTagString(6, "Tag_CPU_arch"));
49
50   EXPECT_TRUE(testBuildAttr(6, 0, ARMBuildAttrs::CPU_arch,
51                             ARMBuildAttrs::Pre_v4));
52   EXPECT_TRUE(testBuildAttr(6, 1, ARMBuildAttrs::CPU_arch,
53                             ARMBuildAttrs::v4));
54   EXPECT_TRUE(testBuildAttr(6, 2, ARMBuildAttrs::CPU_arch,
55                                ARMBuildAttrs::v4T));
56   EXPECT_TRUE(testBuildAttr(6, 3, ARMBuildAttrs::CPU_arch,
57                                ARMBuildAttrs::v5T));
58   EXPECT_TRUE(testBuildAttr(6, 4, ARMBuildAttrs::CPU_arch,
59                                ARMBuildAttrs::v5TE));
60   EXPECT_TRUE(testBuildAttr(6, 5, ARMBuildAttrs::CPU_arch,
61                                ARMBuildAttrs::v5TEJ));
62   EXPECT_TRUE(testBuildAttr(6, 6, ARMBuildAttrs::CPU_arch,
63                                ARMBuildAttrs::v6));
64   EXPECT_TRUE(testBuildAttr(6, 7, ARMBuildAttrs::CPU_arch,
65                                ARMBuildAttrs::v6KZ));
66   EXPECT_TRUE(testBuildAttr(6, 8, ARMBuildAttrs::CPU_arch,
67                                ARMBuildAttrs::v6T2));
68   EXPECT_TRUE(testBuildAttr(6, 9, ARMBuildAttrs::CPU_arch,
69                                ARMBuildAttrs::v6K));
70   EXPECT_TRUE(testBuildAttr(6, 10, ARMBuildAttrs::CPU_arch,
71                                ARMBuildAttrs::v7));
72   EXPECT_TRUE(testBuildAttr(6, 11, ARMBuildAttrs::CPU_arch,
73                                ARMBuildAttrs::v6_M));
74   EXPECT_TRUE(testBuildAttr(6, 12, ARMBuildAttrs::CPU_arch,
75                                ARMBuildAttrs::v6S_M));
76   EXPECT_TRUE(testBuildAttr(6, 13, ARMBuildAttrs::CPU_arch,
77                                ARMBuildAttrs::v7E_M));
78   EXPECT_TRUE(testBuildAttr(6, 14, ARMBuildAttrs::CPU_arch,
79                                ARMBuildAttrs::v8_A));
80   EXPECT_TRUE(testBuildAttr(6, 15, ARMBuildAttrs::CPU_arch,
81                                ARMBuildAttrs::v8_R));
82   EXPECT_TRUE(testBuildAttr(6, 16, ARMBuildAttrs::CPU_arch,
83                                ARMBuildAttrs::v8_M_Base));
84   EXPECT_TRUE(testBuildAttr(6, 17, ARMBuildAttrs::CPU_arch,
85                                ARMBuildAttrs::v8_M_Main));
86   EXPECT_TRUE(testBuildAttr(6, 21, ARMBuildAttrs::CPU_arch,
87                                ARMBuildAttrs::v8_1_M_Main));
88 }
89
90 TEST(CPUArchProfileBuildAttr, testBuildAttr) {
91   EXPECT_TRUE(testTagString(7, "Tag_CPU_arch_profile"));
92   EXPECT_TRUE(testBuildAttr(7, 'A', ARMBuildAttrs::CPU_arch_profile,
93                                ARMBuildAttrs::ApplicationProfile));
94   EXPECT_TRUE(testBuildAttr(7, 'R', ARMBuildAttrs::CPU_arch_profile,
95                                ARMBuildAttrs::RealTimeProfile));
96   EXPECT_TRUE(testBuildAttr(7, 'M', ARMBuildAttrs::CPU_arch_profile,
97                                ARMBuildAttrs::MicroControllerProfile));
98   EXPECT_TRUE(testBuildAttr(7, 'S', ARMBuildAttrs::CPU_arch_profile,
99                                ARMBuildAttrs::SystemProfile));
100 }
101
102 TEST(ARMISABuildAttr, testBuildAttr) {
103   EXPECT_TRUE(testTagString(8, "Tag_ARM_ISA_use"));
104   EXPECT_TRUE(testBuildAttr(8, 0, ARMBuildAttrs::ARM_ISA_use,
105                                ARMBuildAttrs::Not_Allowed));
106   EXPECT_TRUE(testBuildAttr(8, 1, ARMBuildAttrs::ARM_ISA_use,
107                                ARMBuildAttrs::Allowed));
108 }
109
110 TEST(ThumbISABuildAttr, testBuildAttr) {
111   EXPECT_TRUE(testTagString(9, "Tag_THUMB_ISA_use"));
112   EXPECT_TRUE(testBuildAttr(9, 0, ARMBuildAttrs::THUMB_ISA_use,
113                                ARMBuildAttrs::Not_Allowed));
114   EXPECT_TRUE(testBuildAttr(9, 1, ARMBuildAttrs::THUMB_ISA_use,
115                                ARMBuildAttrs::Allowed));
116 }
117
118 TEST(FPArchBuildAttr, testBuildAttr) {
119   EXPECT_TRUE(testTagString(10, "Tag_FP_arch"));
120   EXPECT_TRUE(testBuildAttr(10, 0, ARMBuildAttrs::FP_arch,
121                                ARMBuildAttrs::Not_Allowed));
122   EXPECT_TRUE(testBuildAttr(10, 1, ARMBuildAttrs::FP_arch,
123                                ARMBuildAttrs::Allowed));
124   EXPECT_TRUE(testBuildAttr(10, 2, ARMBuildAttrs::FP_arch,
125                                ARMBuildAttrs::AllowFPv2));
126   EXPECT_TRUE(testBuildAttr(10, 3, ARMBuildAttrs::FP_arch,
127                                ARMBuildAttrs::AllowFPv3A));
128   EXPECT_TRUE(testBuildAttr(10, 4, ARMBuildAttrs::FP_arch,
129                                ARMBuildAttrs::AllowFPv3B));
130   EXPECT_TRUE(testBuildAttr(10, 5, ARMBuildAttrs::FP_arch,
131                                ARMBuildAttrs::AllowFPv4A));
132   EXPECT_TRUE(testBuildAttr(10, 6, ARMBuildAttrs::FP_arch,
133                                ARMBuildAttrs::AllowFPv4B));
134   EXPECT_TRUE(testBuildAttr(10, 7, ARMBuildAttrs::FP_arch,
135                                ARMBuildAttrs::AllowFPARMv8A));
136   EXPECT_TRUE(testBuildAttr(10, 8, ARMBuildAttrs::FP_arch,
137                                ARMBuildAttrs::AllowFPARMv8B));
138 }
139
140 TEST(WMMXBuildAttr, testBuildAttr) {
141   EXPECT_TRUE(testTagString(11, "Tag_WMMX_arch"));
142   EXPECT_TRUE(testBuildAttr(11, 0, ARMBuildAttrs::WMMX_arch,
143                             ARMBuildAttrs::Not_Allowed));
144   EXPECT_TRUE(testBuildAttr(11, 1, ARMBuildAttrs::WMMX_arch,
145                             ARMBuildAttrs::AllowWMMXv1));
146   EXPECT_TRUE(testBuildAttr(11, 2, ARMBuildAttrs::WMMX_arch,
147                             ARMBuildAttrs::AllowWMMXv2));
148 }
149
150 TEST(SIMDBuildAttr, testBuildAttr) {
151   EXPECT_TRUE(testTagString(12, "Tag_Advanced_SIMD_arch"));
152   EXPECT_TRUE(testBuildAttr(12, 0, ARMBuildAttrs::Advanced_SIMD_arch,
153                             ARMBuildAttrs::Not_Allowed));
154   EXPECT_TRUE(testBuildAttr(12, 1, ARMBuildAttrs::Advanced_SIMD_arch,
155                             ARMBuildAttrs::AllowNeon));
156   EXPECT_TRUE(testBuildAttr(12, 2, ARMBuildAttrs::Advanced_SIMD_arch,
157                             ARMBuildAttrs::AllowNeon2));
158   EXPECT_TRUE(testBuildAttr(12, 3, ARMBuildAttrs::Advanced_SIMD_arch,
159                             ARMBuildAttrs::AllowNeonARMv8));
160   EXPECT_TRUE(testBuildAttr(12, 4, ARMBuildAttrs::Advanced_SIMD_arch,
161                             ARMBuildAttrs::AllowNeonARMv8_1a));
162 }
163
164 TEST(FPHPBuildAttr, testBuildAttr) {
165   EXPECT_TRUE(testTagString(36, "Tag_FP_HP_extension"));
166   EXPECT_TRUE(testBuildAttr(36, 0, ARMBuildAttrs::FP_HP_extension,
167                             ARMBuildAttrs::Not_Allowed));
168   EXPECT_TRUE(testBuildAttr(36, 1, ARMBuildAttrs::FP_HP_extension,
169                             ARMBuildAttrs::AllowHPFP));
170 }
171
172 TEST(MVEBuildAttr, testBuildAttr) {
173   EXPECT_TRUE(testTagString(48, "Tag_MVE_arch"));
174   EXPECT_TRUE(testBuildAttr(48, 0, ARMBuildAttrs::MVE_arch,
175                             ARMBuildAttrs::Not_Allowed));
176   EXPECT_TRUE(testBuildAttr(48, 1, ARMBuildAttrs::MVE_arch,
177                             ARMBuildAttrs::AllowMVEInteger));
178   EXPECT_TRUE(testBuildAttr(48, 2, ARMBuildAttrs::MVE_arch,
179                             ARMBuildAttrs::AllowMVEIntegerAndFloat));
180 }
181
182 TEST(CPUAlignBuildAttr, testBuildAttr) {
183   EXPECT_TRUE(testTagString(34, "Tag_CPU_unaligned_access"));
184   EXPECT_TRUE(testBuildAttr(34, 0, ARMBuildAttrs::CPU_unaligned_access,
185                             ARMBuildAttrs::Not_Allowed));
186   EXPECT_TRUE(testBuildAttr(34, 1, ARMBuildAttrs::CPU_unaligned_access,
187                             ARMBuildAttrs::Allowed));
188 }
189
190 TEST(T2EEBuildAttr, testBuildAttr) {
191   EXPECT_TRUE(testTagString(66, "Tag_T2EE_use"));
192   EXPECT_TRUE(testBuildAttr(66, 0, ARMBuildAttrs::T2EE_use,
193                             ARMBuildAttrs::Not_Allowed));
194   EXPECT_TRUE(testBuildAttr(66, 1, ARMBuildAttrs::T2EE_use,
195                             ARMBuildAttrs::Allowed));
196 }
197
198 TEST(VirtualizationBuildAttr, testBuildAttr) {
199   EXPECT_TRUE(testTagString(68, "Tag_Virtualization_use"));
200   EXPECT_TRUE(testBuildAttr(68, 0, ARMBuildAttrs::Virtualization_use,
201                             ARMBuildAttrs::Not_Allowed));
202   EXPECT_TRUE(testBuildAttr(68, 1, ARMBuildAttrs::Virtualization_use,
203                             ARMBuildAttrs::AllowTZ));
204   EXPECT_TRUE(testBuildAttr(68, 2, ARMBuildAttrs::Virtualization_use,
205                             ARMBuildAttrs::AllowVirtualization));
206   EXPECT_TRUE(testBuildAttr(68, 3, ARMBuildAttrs::Virtualization_use,
207                             ARMBuildAttrs::AllowTZVirtualization));
208 }
209
210 TEST(MPBuildAttr, testBuildAttr) {
211   EXPECT_TRUE(testTagString(42, "Tag_MPextension_use"));
212   EXPECT_TRUE(testBuildAttr(42, 0, ARMBuildAttrs::MPextension_use,
213                             ARMBuildAttrs::Not_Allowed));
214   EXPECT_TRUE(testBuildAttr(42, 1, ARMBuildAttrs::MPextension_use,
215                             ARMBuildAttrs::AllowMP));
216 }
217
218 TEST(DivBuildAttr, testBuildAttr) {
219   EXPECT_TRUE(testTagString(44, "Tag_DIV_use"));
220   EXPECT_TRUE(testBuildAttr(44, 0, ARMBuildAttrs::DIV_use,
221                             ARMBuildAttrs::AllowDIVIfExists));
222   EXPECT_TRUE(testBuildAttr(44, 1, ARMBuildAttrs::DIV_use,
223                             ARMBuildAttrs::DisallowDIV));
224   EXPECT_TRUE(testBuildAttr(44, 2, ARMBuildAttrs::DIV_use,
225                             ARMBuildAttrs::AllowDIVExt));
226 }
227
228 TEST(PCS_ConfigBuildAttr, testBuildAttr) {
229   EXPECT_TRUE(testTagString(13, "Tag_PCS_config"));
230   EXPECT_TRUE(testBuildAttr(13, 0, ARMBuildAttrs::PCS_config, 0));
231   EXPECT_TRUE(testBuildAttr(13, 1, ARMBuildAttrs::PCS_config, 1));
232   EXPECT_TRUE(testBuildAttr(13, 2, ARMBuildAttrs::PCS_config, 2));
233   EXPECT_TRUE(testBuildAttr(13, 3, ARMBuildAttrs::PCS_config, 3));
234   EXPECT_TRUE(testBuildAttr(13, 4, ARMBuildAttrs::PCS_config, 4));
235   EXPECT_TRUE(testBuildAttr(13, 5, ARMBuildAttrs::PCS_config, 5));
236   EXPECT_TRUE(testBuildAttr(13, 6, ARMBuildAttrs::PCS_config, 6));
237   EXPECT_TRUE(testBuildAttr(13, 7, ARMBuildAttrs::PCS_config, 7));
238 }
239
240 TEST(PCS_R9BuildAttr, testBuildAttr) {
241   EXPECT_TRUE(testTagString(14, "Tag_ABI_PCS_R9_use"));
242   EXPECT_TRUE(testBuildAttr(14, 0, ARMBuildAttrs::ABI_PCS_R9_use,
243                             ARMBuildAttrs::R9IsGPR));
244   EXPECT_TRUE(testBuildAttr(14, 1, ARMBuildAttrs::ABI_PCS_R9_use,
245                             ARMBuildAttrs::R9IsSB));
246   EXPECT_TRUE(testBuildAttr(14, 2, ARMBuildAttrs::ABI_PCS_R9_use,
247                             ARMBuildAttrs::R9IsTLSPointer));
248   EXPECT_TRUE(testBuildAttr(14, 3, ARMBuildAttrs::ABI_PCS_R9_use,
249                             ARMBuildAttrs::R9Reserved));
250 }
251
252 TEST(PCS_RWBuildAttr, testBuildAttr) {
253   EXPECT_TRUE(testTagString(15, "Tag_ABI_PCS_RW_data"));
254   EXPECT_TRUE(testBuildAttr(15, 0, ARMBuildAttrs::ABI_PCS_RW_data,
255                             ARMBuildAttrs::Not_Allowed));
256   EXPECT_TRUE(testBuildAttr(15, 1, ARMBuildAttrs::ABI_PCS_RW_data,
257                             ARMBuildAttrs::AddressRWPCRel));
258   EXPECT_TRUE(testBuildAttr(15, 2, ARMBuildAttrs::ABI_PCS_RW_data,
259                             ARMBuildAttrs::AddressRWSBRel));
260   EXPECT_TRUE(testBuildAttr(15, 3, ARMBuildAttrs::ABI_PCS_RW_data,
261                             ARMBuildAttrs::AddressRWNone));
262 }
263
264 TEST(PCS_ROBuildAttr, testBuildAttr) {
265   EXPECT_TRUE(testTagString(16, "Tag_ABI_PCS_RO_data"));
266   EXPECT_TRUE(testBuildAttr(16, 0, ARMBuildAttrs::ABI_PCS_RO_data,
267                             ARMBuildAttrs::Not_Allowed));
268   EXPECT_TRUE(testBuildAttr(16, 1, ARMBuildAttrs::ABI_PCS_RO_data,
269                             ARMBuildAttrs::AddressROPCRel));
270   EXPECT_TRUE(testBuildAttr(16, 2, ARMBuildAttrs::ABI_PCS_RO_data,
271                             ARMBuildAttrs::AddressRONone));
272 }
273
274 TEST(PCS_GOTBuildAttr, testBuildAttr) {
275   EXPECT_TRUE(testTagString(17, "Tag_ABI_PCS_GOT_use"));
276   EXPECT_TRUE(testBuildAttr(17, 0, ARMBuildAttrs::ABI_PCS_GOT_use,
277                             ARMBuildAttrs::Not_Allowed));
278   EXPECT_TRUE(testBuildAttr(17, 1, ARMBuildAttrs::ABI_PCS_GOT_use,
279                             ARMBuildAttrs::AddressDirect));
280   EXPECT_TRUE(testBuildAttr(17, 2, ARMBuildAttrs::ABI_PCS_GOT_use,
281                             ARMBuildAttrs::AddressGOT));
282 }
283
284 TEST(PCS_WCharBuildAttr, testBuildAttr) {
285   EXPECT_TRUE(testTagString(18, "Tag_ABI_PCS_wchar_t"));
286   EXPECT_TRUE(testBuildAttr(18, 0, ARMBuildAttrs::ABI_PCS_wchar_t,
287                             ARMBuildAttrs::WCharProhibited));
288   EXPECT_TRUE(testBuildAttr(18, 2, ARMBuildAttrs::ABI_PCS_wchar_t,
289                             ARMBuildAttrs::WCharWidth2Bytes));
290   EXPECT_TRUE(testBuildAttr(18, 4, ARMBuildAttrs::ABI_PCS_wchar_t,
291                             ARMBuildAttrs::WCharWidth4Bytes));
292 }
293
294 TEST(EnumSizeBuildAttr, testBuildAttr) {
295   EXPECT_TRUE(testTagString(26, "Tag_ABI_enum_size"));
296   EXPECT_TRUE(testBuildAttr(26, 0, ARMBuildAttrs::ABI_enum_size,
297                             ARMBuildAttrs::EnumProhibited));
298   EXPECT_TRUE(testBuildAttr(26, 1, ARMBuildAttrs::ABI_enum_size,
299                             ARMBuildAttrs::EnumSmallest));
300   EXPECT_TRUE(testBuildAttr(26, 2, ARMBuildAttrs::ABI_enum_size,
301                             ARMBuildAttrs::Enum32Bit));
302   EXPECT_TRUE(testBuildAttr(26, 3, ARMBuildAttrs::ABI_enum_size,
303                             ARMBuildAttrs::Enum32BitABI));
304 }
305
306 TEST(AlignNeededBuildAttr, testBuildAttr) {
307   EXPECT_TRUE(testTagString(24, "Tag_ABI_align_needed"));
308   EXPECT_TRUE(testBuildAttr(24, 0, ARMBuildAttrs::ABI_align_needed,
309                             ARMBuildAttrs::Not_Allowed));
310   EXPECT_TRUE(testBuildAttr(24, 1, ARMBuildAttrs::ABI_align_needed,
311                             ARMBuildAttrs::Align8Byte));
312   EXPECT_TRUE(testBuildAttr(24, 2, ARMBuildAttrs::ABI_align_needed,
313                             ARMBuildAttrs::Align4Byte));
314   EXPECT_TRUE(testBuildAttr(24, 3, ARMBuildAttrs::ABI_align_needed,
315                             ARMBuildAttrs::AlignReserved));
316 }
317
318 TEST(AlignPreservedBuildAttr, testBuildAttr) {
319   EXPECT_TRUE(testTagString(25, "Tag_ABI_align_preserved"));
320   EXPECT_TRUE(testBuildAttr(25, 0, ARMBuildAttrs::ABI_align_preserved,
321                             ARMBuildAttrs::AlignNotPreserved));
322   EXPECT_TRUE(testBuildAttr(25, 1, ARMBuildAttrs::ABI_align_preserved,
323                             ARMBuildAttrs::AlignPreserve8Byte));
324   EXPECT_TRUE(testBuildAttr(25, 2, ARMBuildAttrs::ABI_align_preserved,
325                             ARMBuildAttrs::AlignPreserveAll));
326   EXPECT_TRUE(testBuildAttr(25, 3, ARMBuildAttrs::ABI_align_preserved,
327                             ARMBuildAttrs::AlignReserved));
328 }
329
330 TEST(FPRoundingBuildAttr, testBuildAttr) {
331   EXPECT_TRUE(testTagString(19, "Tag_ABI_FP_rounding"));
332   EXPECT_TRUE(testBuildAttr(19, 0, ARMBuildAttrs::ABI_FP_rounding, 0));
333   EXPECT_TRUE(testBuildAttr(19, 1, ARMBuildAttrs::ABI_FP_rounding, 1));
334 }
335
336 TEST(FPDenormalBuildAttr, testBuildAttr) {
337   EXPECT_TRUE(testTagString(20, "Tag_ABI_FP_denormal"));
338   EXPECT_TRUE(testBuildAttr(20, 0, ARMBuildAttrs::ABI_FP_denormal,
339                             ARMBuildAttrs::PositiveZero));
340   EXPECT_TRUE(testBuildAttr(20, 1, ARMBuildAttrs::ABI_FP_denormal,
341                             ARMBuildAttrs::IEEEDenormals));
342   EXPECT_TRUE(testBuildAttr(20, 2, ARMBuildAttrs::ABI_FP_denormal,
343                             ARMBuildAttrs::PreserveFPSign));
344 }
345
346 TEST(FPExceptionsBuildAttr, testBuildAttr) {
347   EXPECT_TRUE(testTagString(21, "Tag_ABI_FP_exceptions"));
348   EXPECT_TRUE(testBuildAttr(21, 0, ARMBuildAttrs::ABI_FP_exceptions, 0));
349   EXPECT_TRUE(testBuildAttr(21, 1, ARMBuildAttrs::ABI_FP_exceptions, 1));
350 }
351
352 TEST(FPUserExceptionsBuildAttr, testBuildAttr) {
353   EXPECT_TRUE(testTagString(22, "Tag_ABI_FP_user_exceptions"));
354   EXPECT_TRUE(testBuildAttr(22, 0, ARMBuildAttrs::ABI_FP_user_exceptions, 0));
355   EXPECT_TRUE(testBuildAttr(22, 1, ARMBuildAttrs::ABI_FP_user_exceptions, 1));
356 }
357
358 TEST(FPNumberModelBuildAttr, testBuildAttr) {
359   EXPECT_TRUE(testTagString(23, "Tag_ABI_FP_number_model"));
360   EXPECT_TRUE(testBuildAttr(23, 0, ARMBuildAttrs::ABI_FP_number_model,
361                             ARMBuildAttrs::Not_Allowed));
362   EXPECT_TRUE(testBuildAttr(23, 1, ARMBuildAttrs::ABI_FP_number_model,
363                             ARMBuildAttrs::AllowIEEENormal));
364   EXPECT_TRUE(testBuildAttr(23, 2, ARMBuildAttrs::ABI_FP_number_model,
365                             ARMBuildAttrs::AllowRTABI));
366   EXPECT_TRUE(testBuildAttr(23, 3, ARMBuildAttrs::ABI_FP_number_model,
367                             ARMBuildAttrs::AllowIEEE754));
368 }
369
370 TEST(FP16BuildAttr, testBuildAttr) {
371   EXPECT_TRUE(testTagString(38, "Tag_ABI_FP_16bit_format"));
372   EXPECT_TRUE(testBuildAttr(38, 0, ARMBuildAttrs::ABI_FP_16bit_format,
373                             ARMBuildAttrs::Not_Allowed));
374   EXPECT_TRUE(testBuildAttr(38, 1, ARMBuildAttrs::ABI_FP_16bit_format,
375                             ARMBuildAttrs::FP16FormatIEEE));
376   EXPECT_TRUE(testBuildAttr(38, 2, ARMBuildAttrs::ABI_FP_16bit_format,
377                             ARMBuildAttrs::FP16VFP3));
378 }
379
380 TEST(HardFPBuildAttr, testBuildAttr) {
381   EXPECT_TRUE(testTagString(27, "Tag_ABI_HardFP_use"));
382   EXPECT_TRUE(testBuildAttr(27, 0, ARMBuildAttrs::ABI_HardFP_use,
383                             ARMBuildAttrs::HardFPImplied));
384   EXPECT_TRUE(testBuildAttr(27, 1, ARMBuildAttrs::ABI_HardFP_use,
385                             ARMBuildAttrs::HardFPSinglePrecision));
386   EXPECT_TRUE(testBuildAttr(27, 2, ARMBuildAttrs::ABI_HardFP_use, 2));
387 }
388
389 TEST(VFPArgsBuildAttr, testBuildAttr) {
390   EXPECT_TRUE(testTagString(28, "Tag_ABI_VFP_args"));
391   EXPECT_TRUE(testBuildAttr(28, 0, ARMBuildAttrs::ABI_VFP_args,
392                             ARMBuildAttrs::BaseAAPCS));
393   EXPECT_TRUE(testBuildAttr(28, 1, ARMBuildAttrs::ABI_VFP_args,
394                             ARMBuildAttrs::HardFPAAPCS));
395   EXPECT_TRUE(testBuildAttr(28, 2, ARMBuildAttrs::ABI_VFP_args, 2));
396   EXPECT_TRUE(testBuildAttr(28, 3, ARMBuildAttrs::ABI_VFP_args, 3));
397 }
398
399 TEST(WMMXArgsBuildAttr, testBuildAttr) {
400   EXPECT_TRUE(testTagString(29, "Tag_ABI_WMMX_args"));
401   EXPECT_TRUE(testBuildAttr(29, 0, ARMBuildAttrs::ABI_WMMX_args, 0));
402   EXPECT_TRUE(testBuildAttr(29, 1, ARMBuildAttrs::ABI_WMMX_args, 1));
403   EXPECT_TRUE(testBuildAttr(29, 2, ARMBuildAttrs::ABI_WMMX_args, 2));
404 }