llvm.org GIT mirror llvm / d6d6b83
Revert r291903 and r291898. Reason: they break check-lld on the bots. Summary: Revert [ARM] Fix ubig32_t read in ARMAttributeParser Now using support functions to read data instead of trying to perform casts. =========================================================== Revert [ARM] Enable objdump to construct triple for ARM Now that The ARMAttributeParser has been moved into the library, it has been modified so that it can parse the attributes without printing them and stores them in a map. ELFObjectFile now queries the attributes to fill out the architecture details of a provided triple for 'arm' and 'thumb' targets. llvm-objdump uses this new functionality. Subscribers: llvm-commits, samparker, aemerson, mgorny Differential Revision: https://reviews.llvm.org/D28683 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291911 91177308-0d34-0410-b5e6-96231b3b80d8 Ivan Krasin 3 years ago
19 changed file(s) with 56 addition(s) and 681 deletion(s). Raw diff Collapse all Expand all
2525 #include "llvm/Object/Error.h"
2626 #include "llvm/Object/ObjectFile.h"
2727 #include "llvm/Object/SymbolicFile.h"
28 #include "llvm/Support/ARMAttributeParser.h"
2928 #include "llvm/Support/Casting.h"
3029 #include "llvm/Support/ELF.h"
3130 #include "llvm/Support/Endian.h"
7271 static inline bool classof(const Binary *v) { return v->isELF(); }
7372
7473 SubtargetFeatures getFeatures() const override;
75
76 void setARMSubArch(Triple &TheTriple) const override;
7774 };
7875
7976 class ELFSectionRef : public SectionRef {
355352
356353 std::error_code getPlatformFlags(unsigned &Result) const override {
357354 Result = EF.getHeader()->e_flags;
358 return std::error_code();
359 }
360
361 std::error_code getBuildAttributes(ARMAttributeParser &Attributes) const override {
362 auto SectionsOrErr = EF.sections();
363 if (!SectionsOrErr)
364 return errorToErrorCode(SectionsOrErr.takeError());
365
366 for (const Elf_Shdr &Sec : *SectionsOrErr) {
367 if (Sec.sh_type == ELF::SHT_ARM_ATTRIBUTES) {
368 auto ErrorOrContents = EF.getSectionContents(&Sec);
369 if (!ErrorOrContents)
370 return errorToErrorCode(ErrorOrContents.takeError());
371
372 auto Contents = ErrorOrContents.get();
373 if (Contents[0] != ARMBuildAttrs::Format_Version || Contents.size() == 1)
374 return std::error_code();
375
376 Attributes.Parse(Contents, ELFT::TargetEndianness == support::little);
377 break;
378 }
379 }
380355 return std::error_code();
381356 }
382357
2323 #include
2424
2525 namespace llvm {
26 class ARMAttributeParser;
27
2826 namespace object {
2927
3028 class ObjectFile;
266264 virtual StringRef getFileFormatName() const = 0;
267265 virtual /* Triple::ArchType */ unsigned getArch() const = 0;
268266 virtual SubtargetFeatures getFeatures() const = 0;
269 virtual void setARMSubArch(Triple &TheTriple) const { }
270267
271268 /// Returns platform-specific object flags, if any.
272269 virtual std::error_code getPlatformFlags(unsigned &Result) const {
273270 Result = 0;
274271 return object_error::invalid_file_type;
275272 }
276
277 virtual std::error_code
278 getBuildAttributes(ARMAttributeParser &Attributes) const {
279 return std::error_code();
280 }
281273
282274 /// True if this is a relocatable object (.o/.obj).
283275 virtual bool isRelocatableObject() const = 0;
1212 #include "ARMBuildAttributes.h"
1313 #include "ScopedPrinter.h"
1414
15 #include
16
1715 namespace llvm {
1816 class StringRef;
1917
2018 class ARMAttributeParser {
21 ScopedPrinter *SW;
22
23 std::map Attributes;
19 ScopedPrinter &SW;
2420
2521 struct DisplayHandler {
2622 ARMBuildAttrs::AttrType Attribute;
118114 SmallVectorImpl &IndexList);
119115 void ParseSubsection(const uint8_t *Data, uint32_t Length);
120116 public:
121 ARMAttributeParser(ScopedPrinter *SW) : SW(SW) {}
117 ARMAttributeParser(ScopedPrinter &SW) : SW(SW) {}
122118
123 ARMAttributeParser() : SW(nullptr) { }
124
125 void Parse(ArrayRef Section, bool isLittle);
126
127 bool hasAttribute(unsigned Tag) const {
128 return Attributes.count(Tag);
129 }
130
131 unsigned getAttributeValue(unsigned Tag) const {
132 return Attributes.find(Tag)->second;
133 }
119 void Parse(ArrayRef Section);
134120 };
135121
136122 }
175175 WCharWidth2Bytes = 2, // sizeof(wchar_t) == 2
176176 WCharWidth4Bytes = 4, // sizeof(wchar_t) == 4
177177
178 // Tag_ABI_align_needed, (=24), uleb128
179 Align8Byte = 1,
180 Align4Byte = 2,
181 AlignReserved = 3,
182
183 // Tag_ABI_align_needed, (=25), uleb128
184 AlignNotPreserved = 0,
185 AlignPreserve8Byte = 1,
186 AlignPreserveAll = 2,
187
188178 // Tag_ABI_FP_denormal, (=20), uleb128
189179 PositiveZero = 0,
190180 IEEEDenormals = 1,
191181 PreserveFPSign = 2, // sign when flushed-to-zero is preserved
192182
193183 // Tag_ABI_FP_number_model, (=23), uleb128
194 AllowIEEENormal = 1,
195184 AllowRTABI = 2, // numbers, infinities, and one quiet NaN (see [RTABI])
196 AllowIEEE754 = 3, // this code to use all the IEEE 754-defined FP encodings
185 AllowIEE754 = 3, // this code to use all the IEEE 754-defined FP encodings
197186
198187 // Tag_ABI_enum_size, (=26), uleb128
199188 EnumProhibited = 0, // The user prohibited the use of enums when building
218207
219208 // Tag_FP_16bit_format, (=38), uleb128
220209 FP16FormatIEEE = 1,
221 FP16VFP3 = 2,
222210
223211 // Tag_MPextension_use, (=42), uleb128
224212 AllowMP = 1, // Allow use of MP extensions
121121 }
122122 }
123123
124 // FIXME Encode from a tablegen description or target parser.
125 void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const {
126 if (TheTriple.getSubArch() != Triple::NoSubArch)
127 return;
128
129 ARMAttributeParser Attributes;
130 std::error_code EC = getBuildAttributes(Attributes);
131 if (EC)
132 return;
133
134 std::string Triple;
135 // Default to ARM, but use the triple if it's been set.
136 if (TheTriple.getArch() == Triple::thumb ||
137 TheTriple.getArch() == Triple::thumbeb)
138 Triple = "thumb";
139 else
140 Triple = "arm";
141
142 switch(Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch)) {
143 case ARMBuildAttrs::v4:
144 Triple += "v4";
145 break;
146 case ARMBuildAttrs::v4T:
147 Triple += "v4t";
148 break;
149 case ARMBuildAttrs::v5T:
150 Triple += "v5t";
151 break;
152 case ARMBuildAttrs::v5TE:
153 Triple += "v5te";
154 break;
155 case ARMBuildAttrs::v5TEJ:
156 Triple += "v5tej";
157 break;
158 case ARMBuildAttrs::v6:
159 Triple += "v6";
160 break;
161 case ARMBuildAttrs::v6KZ:
162 Triple += "v6kz";
163 break;
164 case ARMBuildAttrs::v6T2:
165 Triple += "v6t2";
166 break;
167 case ARMBuildAttrs::v6K:
168 Triple += "v6k";
169 break;
170 case ARMBuildAttrs::v7:
171 Triple += "v7";
172 break;
173 case ARMBuildAttrs::v6_M:
174 Triple += "v6m";
175 break;
176 case ARMBuildAttrs::v6S_M:
177 Triple += "v6sm";
178 break;
179 case ARMBuildAttrs::v7E_M:
180 Triple += "v7em";
181 break;
182 }
183 if (!isLittleEndian())
184 Triple += "eb";
185
186 TheTriple.setArchName(Triple);
187 }
188
189124 } // end namespace llvm
8888
8989 void ARMAttributeParser::IntegerAttribute(AttrType Tag, const uint8_t *Data,
9090 uint32_t &Offset) {
91
92 uint64_t Value = ParseInteger(Data, Offset);
93 Attributes.insert(std::make_pair(Tag, Value));
94
95 if (SW)
96 SW->printNumber(ARMBuildAttrs::AttrTypeAsString(Tag), Value);
91 SW.printNumber(ARMBuildAttrs::AttrTypeAsString(Tag),
92 ParseInteger(Data, Offset));
9793 }
9894
9995 void ARMAttributeParser::StringAttribute(AttrType Tag, const uint8_t *Data,
10096 uint32_t &Offset) {
10197 StringRef TagName = ARMBuildAttrs::AttrTypeAsString(Tag, /*TagPrefix*/false);
102 StringRef ValueDesc = ParseString(Data, Offset);
103
104 if (SW) {
105 DictScope AS(*SW, "Attribute");
106 SW->printNumber("Tag", Tag);
107 if (!TagName.empty())
108 SW->printString("TagName", TagName);
109 SW->printString("Value", ValueDesc);
110 }
98
99 DictScope AS(SW, "Attribute");
100 SW.printNumber("Tag", Tag);
101 if (!TagName.empty())
102 SW.printString("TagName", TagName);
103 SW.printString("Value", ParseString(Data, Offset));
111104 }
112105
113106 void ARMAttributeParser::PrintAttribute(unsigned Tag, unsigned Value,
114107 StringRef ValueDesc) {
115 Attributes.insert(std::make_pair(Tag, Value));
116
117 if (SW) {
118 StringRef TagName = ARMBuildAttrs::AttrTypeAsString(Tag,
119 /*TagPrefix*/false);
120 DictScope AS(*SW, "Attribute");
121 SW->printNumber("Tag", Tag);
122 SW->printNumber("Value", Value);
123 if (!TagName.empty())
124 SW->printString("TagName", TagName);
125 if (!ValueDesc.empty())
126 SW->printString("Description", ValueDesc);
127 }
108 StringRef TagName = ARMBuildAttrs::AttrTypeAsString(Tag, /*TagPrefix*/false);
109
110 DictScope AS(SW, "Attribute");
111 SW.printNumber("Tag", Tag);
112 SW.printNumber("Value", Value);
113 if (!TagName.empty())
114 SW.printString("TagName", TagName);
115 if (!ValueDesc.empty())
116 SW.printString("Description", ValueDesc);
128117 }
129118
130119 void ARMAttributeParser::CPU_arch(AttrType Tag, const uint8_t *Data,
459448 uint64_t Integer = ParseInteger(Data, Offset);
460449 StringRef String = ParseString(Data, Offset);
461450
462 if (SW) {
463 DictScope AS(*SW, "Attribute");
464 SW->printNumber("Tag", Tag);
465 SW->startLine() << "Value: " << Integer << ", " << String << '\n';
466 SW->printString("TagName", AttrTypeAsString(Tag, /*TagPrefix*/false));
467 switch (Integer) {
468 case 0:
469 SW->printString("Description", StringRef("No Specific Requirements"));
470 break;
471 case 1:
472 SW->printString("Description", StringRef("AEABI Conformant"));
473 break;
474 default:
475 SW->printString("Description", StringRef("AEABI Non-Conformant"));
476 break;
477 }
451 DictScope AS(SW, "Attribute");
452 SW.printNumber("Tag", Tag);
453 SW.startLine() << "Value: " << Integer << ", " << String << '\n';
454 SW.printString("TagName", AttrTypeAsString(Tag, /*TagPrefix*/false));
455 switch (Integer) {
456 case 0:
457 SW.printString("Description", StringRef("No Specific Requirements"));
458 break;
459 case 1:
460 SW.printString("Description", StringRef("AEABI Conformant"));
461 break;
462 default:
463 SW.printString("Description", StringRef("AEABI Non-Conformant"));
464 break;
478465 }
479466 }
480467
616603 void ARMAttributeParser::ParseSubsection(const uint8_t *Data, uint32_t Length) {
617604 uint32_t Offset = sizeof(uint32_t); /* SectionLength */
618605
606 SW.printNumber("SectionLength", Length);
607
619608 const char *VendorName = reinterpret_cast(Data + Offset);
620609 size_t VendorNameLength = std::strlen(VendorName);
610 SW.printString("Vendor", StringRef(VendorName, VendorNameLength));
621611 Offset = Offset + VendorNameLength + 1;
622612
623 if (SW) {
624 SW->printNumber("SectionLength", Length);
625 SW->printString("Vendor", StringRef(VendorName, VendorNameLength));
626 }
627
628 if (StringRef(VendorName, VendorNameLength).lower() != "aeabi") {
613 if (StringRef(VendorName, VendorNameLength).lower() != "aeabi")
629614 return;
630 }
631615
632616 while (Offset < Length) {
633617 /// Tag_File | Tag_Section | Tag_Symbol uleb128:byte-size
634618 uint8_t Tag = Data[Offset];
619 SW.printEnum("Tag", Tag, makeArrayRef(TagNames));
635620 Offset = Offset + sizeof(Tag);
636621
637622 uint32_t Size =
638623 *reinterpret_cast(Data + Offset);
624 SW.printNumber("Size", Size);
639625 Offset = Offset + sizeof(Size);
640
641 if (SW) {
642 SW->printEnum("Tag", Tag, makeArrayRef(TagNames));
643 SW->printNumber("Size", Size);
644 }
645626
646627 if (Size > Length) {
647628 errs() << "subsection length greater than section length\n";
669650 return;
670651 }
671652
672 if (SW) {
673 DictScope ASS(*SW, ScopeName);
674 if (!Indicies.empty())
675 SW->printList(IndexName, Indicies);
676 }
653 DictScope ASS(SW, ScopeName);
654
655 if (!Indicies.empty())
656 SW.printList(IndexName, Indicies);
677657
678658 ParseAttributeList(Data, Offset, Length);
679659 }
680660 }
681661
682 void ARMAttributeParser::Parse(ArrayRef Section, bool isLittle) {
662 void ARMAttributeParser::Parse(ArrayRef Section) {
683663 size_t Offset = 1;
684664 unsigned SectionNumber = 0;
685665
686666 while (Offset < Section.size()) {
687667 uint32_t SectionLength =
688 isLittle ? support::endian::read32le(Section.data() + Offset)
689 : support::endian::read32be(Section.data() + Offset);
690
691 if (SW) {
692 SW->startLine() << "Section " << ++SectionNumber << " {\n";
693 SW->indent();
694 }
668 *reinterpret_cast(Section.data() + Offset);
669
670 SW.startLine() << "Section " << ++SectionNumber << " {\n";
671 SW.indent();
695672
696673 ParseSubsection(Section.data() + Offset, SectionLength);
697674 Offset = Offset + SectionLength;
698675
699 if (SW) {
700 SW->unindent();
701 SW->startLine() << "}\n";
702 }
676 SW.unindent();
677 SW.startLine() << "}\n";
703678 }
704679 }
705680 }
840840 ARMBuildAttrs::Allowed);
841841 else
842842 ATS.emitAttribute(ARMBuildAttrs::ABI_FP_number_model,
843 ARMBuildAttrs::AllowIEEE754);
843 ARMBuildAttrs::AllowIEE754);
844844
845845 if (STI.allowsUnalignedMem())
846846 ATS.emitAttribute(ARMBuildAttrs::CPU_unaligned_access,
+0
-10
test/tools/llvm-objdump/ARM/v5t-subarch.s less more
None @ RUN: llvm-mc < %s -triple armv5t-elf -filetype=obj | llvm-objdump -triple=arm -d - | FileCheck %s
1
2 .arch armv5t
3
4 clz:
5 clz r0, r1
6
7 @ CHECK-LABEL: clz
8 @ CHECK: 11 0f 6f e1
9
+0
-10
test/tools/llvm-objdump/ARM/v5te-subarch.s less more
None @ RUN: llvm-mc < %s -triple armv5te-elf -filetype=obj | llvm-objdump -triple=arm -d - | FileCheck %s
1
2 .arch armv5te
3
4 strd:
5 strd r0, r1, [r2, +r3]
6
7 @ CHECK-LABEL strd
8 @ CHECK: f3 00 82 e1 strd r0, r1, [r2, r3]
9
+0
-7
test/tools/llvm-objdump/ARM/v5tej-subarch.s less more
None @ RUN: llvm-mc < %s -triple armv5tej-elf -filetype=obj | llvm-objdump -triple=arm -d - | FileCheck %s
1
2 bxj:
3 bxj r0
4
5 @ CHECK-LABEL: bxj
6 @ CHECK: 20 ff 2f e1 bxj r0
+0
-9
test/tools/llvm-objdump/ARM/v6-subarch.s less more
None @ RUN: llvm-mc < %s -triple armv6-elf -filetype=obj | llvm-objdump -triple=arm -d - | FileCheck %s
1
2 .arch armv6
3
4 umaal:
5 umaal r0, r1, r2, r3
6
7 @ CHECK-LABEL:umaal
8 @ CHECK: 92 03 41 e0 umaal r0, r1, r2, r3
+0
-9
test/tools/llvm-objdump/ARM/v6k-subarch.s less more
None @ RUN: llvm-mc < %s -triple armv6k-elf -filetype=obj | llvm-objdump -triple=arm -d - | FileCheck %s
1
2 .arch armv6k
3
4 clrex:
5 clrex
6
7 @ CHECK-LABEL: clrex
8 @ CHECK: 1f f0 7f f5 clrex
+0
-9
test/tools/llvm-objdump/ARM/v6m-subarch.s less more
None @ RUN: llvm-mc < %s -triple armv6m-elf -filetype=obj | llvm-objdump -triple=thumb -d - | FileCheck %s
1
2 .arch armv6m
3
4 dmb:
5 dmb
6
7 @ CHECK-LABEL: dmb
8 @ CHECK: bf f3 5f 8f dmb sy
+0
-10
test/tools/llvm-objdump/ARM/v6t2-subarch.s less more
None @ RUN: llvm-mc < %s -triple armv6t2-elf -filetype=obj | llvm-objdump -triple=thumb -d - | FileCheck %s
1
2 .arch armv6t2
3
4 .thumb
5 umaalt2:
6 umaal r0, r1, r2, r3
7
8 @ CHECK-LABEL: umaalt2
9 @ CHECK: e2 fb 63 01 umaal r0, r1, r2, r3
+0
-10
test/tools/llvm-objdump/ARM/v7m-subarch.s less more
None @ RUN: llvm-mc < %s -triple armv7m-elf -filetype=obj | llvm-objdump -triple=thumb -d - | FileCheck %s
1
2 .arch armv7m
3
4 umlal:
5 umlal r0, r1, r2, r3
6
7 @ CHECK-LABEL: umlal
8 @ CHECK: e2 fb 03 01 umlal r0, r1, r2, r3
9
356356 llvm::Triple TheTriple("unknown-unknown-unknown");
357357 if (TripleName.empty()) {
358358 if (Obj) {
359 auto Arch = Obj->getArch();
360 TheTriple.setArch(Triple::ArchType(Arch));
361
362 // For ARM targets, try to use the build attributes to build determine
363 // the build target. Target features are also added, but later during
364 // disassembly.
365 if (Arch == Triple::arm || Arch == Triple::armeb) {
366 Obj->setARMSubArch(TheTriple);
367 }
368
359 TheTriple.setArch(Triple::ArchType(Obj->getArch()));
369360 // TheTriple defaults to ELF, and COFF doesn't have an environment:
370361 // the best we can do here is indicate that it is mach-o.
371362 if (Obj->isMachO())
377368 TheTriple.setTriple("thumbv7-windows");
378369 }
379370 }
380 } else {
371 } else
381372 TheTriple.setTriple(Triple::normalize(TripleName));
382 // Use the triple, but also try to combine with ARM build attributes.
383 if (Obj) {
384 auto Arch = Obj->getArch();
385 if (Arch == Triple::arm || Arch == Triple::armeb) {
386 Obj->setARMSubArch(TheTriple);
387 }
388 }
389 }
390373
391374 // Get the target specific parser.
392375 std::string Error;
18911891 if (Contents.size() == 1)
18921892 continue;
18931893
1894 ARMAttributeParser(&W).Parse(Contents, true);
1894 ARMAttributeParser(W).Parse(Contents);
18951895 }
18961896 }
18971897 }
+0
-384
unittests/Support/ARMAttributeParser.cpp less more
None #include "llvm/Support/ARMBuildAttributes.h"
1 #include "llvm/Support/ARMAttributeParser.h"
2 #include "llvm/Support/LEB128.h"
3 #include "gtest/gtest.h"
4 #include
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 Bytes((uint8_t*)OS.str().c_str(), OS.str().size());
34
35 ARMAttributeParser Parser;
36 Parser.Parse(Bytes, true);
37
38 return (Parser.hasAttribute(ExpectedTag) &&
39 Parser.getAttributeValue(ExpectedTag) == ExpectedValue);
40 }
41
42 bool testTagString(unsigned Tag, const char *name) {
43 return ARMBuildAttrs::AttrTypeAsString(Tag).str() == name;
44 }
45
46 TEST(CPUArchBuildAttr, testBuildAttr) {
47 EXPECT_TRUE(testTagString(6, "Tag_CPU_arch"));
48
49 EXPECT_TRUE(testBuildAttr(6, 0, ARMBuildAttrs::CPU_arch,
50 ARMBuildAttrs::Pre_v4));
51 EXPECT_TRUE(testBuildAttr(6, 1, ARMBuildAttrs::CPU_arch,
52 ARMBuildAttrs::v4));
53 EXPECT_TRUE(testBuildAttr(6, 2, ARMBuildAttrs::CPU_arch,
54 ARMBuildAttrs::v4T));
55 EXPECT_TRUE(testBuildAttr(6, 3, ARMBuildAttrs::CPU_arch,
56 ARMBuildAttrs::v5T));
57 EXPECT_TRUE(testBuildAttr(6, 4, ARMBuildAttrs::CPU_arch,
58 ARMBuildAttrs::v5TE));
59 EXPECT_TRUE(testBuildAttr(6, 5, ARMBuildAttrs::CPU_arch,
60 ARMBuildAttrs::v5TEJ));
61 EXPECT_TRUE(testBuildAttr(6, 6, ARMBuildAttrs::CPU_arch,
62 ARMBuildAttrs::v6));
63 EXPECT_TRUE(testBuildAttr(6, 7, ARMBuildAttrs::CPU_arch,
64 ARMBuildAttrs::v6KZ));
65 EXPECT_TRUE(testBuildAttr(6, 8, ARMBuildAttrs::CPU_arch,
66 ARMBuildAttrs::v6T2));
67 EXPECT_TRUE(testBuildAttr(6, 9, ARMBuildAttrs::CPU_arch,
68 ARMBuildAttrs::v6K));
69 EXPECT_TRUE(testBuildAttr(6, 10, ARMBuildAttrs::CPU_arch,
70 ARMBuildAttrs::v7));
71 EXPECT_TRUE(testBuildAttr(6, 11, ARMBuildAttrs::CPU_arch,
72 ARMBuildAttrs::v6_M));
73 EXPECT_TRUE(testBuildAttr(6, 12, ARMBuildAttrs::CPU_arch,
74 ARMBuildAttrs::v6S_M));
75 EXPECT_TRUE(testBuildAttr(6, 13, ARMBuildAttrs::CPU_arch,
76 ARMBuildAttrs::v7E_M));
77 }
78
79 TEST(CPUArchProfileBuildAttr, testBuildAttr) {
80 EXPECT_TRUE(testTagString(7, "Tag_CPU_arch_profile"));
81 EXPECT_TRUE(testBuildAttr(7, 'A', ARMBuildAttrs::CPU_arch_profile,
82 ARMBuildAttrs::ApplicationProfile));
83 EXPECT_TRUE(testBuildAttr(7, 'R', ARMBuildAttrs::CPU_arch_profile,
84 ARMBuildAttrs::RealTimeProfile));
85 EXPECT_TRUE(testBuildAttr(7, 'M', ARMBuildAttrs::CPU_arch_profile,
86 ARMBuildAttrs::MicroControllerProfile));
87 EXPECT_TRUE(testBuildAttr(7, 'S', ARMBuildAttrs::CPU_arch_profile,
88 ARMBuildAttrs::SystemProfile));
89 }
90
91 TEST(ARMISABuildAttr, testBuildAttr) {
92 EXPECT_TRUE(testTagString(8, "Tag_ARM_ISA_use"));
93 EXPECT_TRUE(testBuildAttr(8, 0, ARMBuildAttrs::ARM_ISA_use,
94 ARMBuildAttrs::Not_Allowed));
95 EXPECT_TRUE(testBuildAttr(8, 1, ARMBuildAttrs::ARM_ISA_use,
96 ARMBuildAttrs::Allowed));
97 }
98
99 TEST(ThumbISABuildAttr, testBuildAttr) {
100 EXPECT_TRUE(testTagString(9, "Tag_THUMB_ISA_use"));
101 EXPECT_TRUE(testBuildAttr(9, 0, ARMBuildAttrs::THUMB_ISA_use,
102 ARMBuildAttrs::Not_Allowed));
103 EXPECT_TRUE(testBuildAttr(9, 1, ARMBuildAttrs::THUMB_ISA_use,
104 ARMBuildAttrs::Allowed));
105 }
106
107 TEST(FPArchBuildAttr, testBuildAttr) {
108 EXPECT_TRUE(testTagString(10, "Tag_FP_arch"));
109 EXPECT_TRUE(testBuildAttr(10, 0, ARMBuildAttrs::FP_arch,
110 ARMBuildAttrs::Not_Allowed));
111 EXPECT_TRUE(testBuildAttr(10, 1, ARMBuildAttrs::FP_arch,
112 ARMBuildAttrs::Allowed));
113 EXPECT_TRUE(testBuildAttr(10, 2, ARMBuildAttrs::FP_arch,
114 ARMBuildAttrs::AllowFPv2));
115 EXPECT_TRUE(testBuildAttr(10, 3, ARMBuildAttrs::FP_arch,
116 ARMBuildAttrs::AllowFPv3A));
117 EXPECT_TRUE(testBuildAttr(10, 4, ARMBuildAttrs::FP_arch,
118 ARMBuildAttrs::AllowFPv3B));
119 EXPECT_TRUE(testBuildAttr(10, 5, ARMBuildAttrs::FP_arch,
120 ARMBuildAttrs::AllowFPv4A));
121 EXPECT_TRUE(testBuildAttr(10, 6, ARMBuildAttrs::FP_arch,
122 ARMBuildAttrs::AllowFPv4B));
123 EXPECT_TRUE(testBuildAttr(10, 7, ARMBuildAttrs::FP_arch,
124 ARMBuildAttrs::AllowFPARMv8A));
125 EXPECT_TRUE(testBuildAttr(10, 8, ARMBuildAttrs::FP_arch,
126 ARMBuildAttrs::AllowFPARMv8B));
127 }
128
129 TEST(WMMXBuildAttr, testBuildAttr) {
130 EXPECT_TRUE(testTagString(11, "Tag_WMMX_arch"));
131 EXPECT_TRUE(testBuildAttr(11, 0, ARMBuildAttrs::WMMX_arch,
132 ARMBuildAttrs::Not_Allowed));
133 EXPECT_TRUE(testBuildAttr(11, 1, ARMBuildAttrs::WMMX_arch,
134 ARMBuildAttrs::AllowWMMXv1));
135 EXPECT_TRUE(testBuildAttr(11, 2, ARMBuildAttrs::WMMX_arch,
136 ARMBuildAttrs::AllowWMMXv2));
137 }
138
139 TEST(SIMDBuildAttr, testBuildAttr) {
140 EXPECT_TRUE(testTagString(12, "Tag_Advanced_SIMD_arch"));
141 EXPECT_TRUE(testBuildAttr(12, 0, ARMBuildAttrs::Advanced_SIMD_arch,
142 ARMBuildAttrs::Not_Allowed));
143 EXPECT_TRUE(testBuildAttr(12, 1, ARMBuildAttrs::Advanced_SIMD_arch,
144 ARMBuildAttrs::AllowNeon));
145 EXPECT_TRUE(testBuildAttr(12, 2, ARMBuildAttrs::Advanced_SIMD_arch,
146 ARMBuildAttrs::AllowNeon2));
147 EXPECT_TRUE(testBuildAttr(12, 3, ARMBuildAttrs::Advanced_SIMD_arch,
148 ARMBuildAttrs::AllowNeonARMv8));
149 EXPECT_TRUE(testBuildAttr(12, 4, ARMBuildAttrs::Advanced_SIMD_arch,
150 ARMBuildAttrs::AllowNeonARMv8_1a));
151 }
152
153 TEST(FPHPBuildAttr, testBuildAttr) {
154 EXPECT_TRUE(testTagString(36, "Tag_FP_HP_extension"));
155 EXPECT_TRUE(testBuildAttr(36, 0, ARMBuildAttrs::FP_HP_extension,
156 ARMBuildAttrs::Not_Allowed));
157 EXPECT_TRUE(testBuildAttr(36, 1, ARMBuildAttrs::FP_HP_extension,
158 ARMBuildAttrs::AllowHPFP));
159 }
160
161 TEST(CPUAlignBuildAttr, testBuildAttr) {
162 EXPECT_TRUE(testTagString(34, "Tag_CPU_unaligned_access"));
163 EXPECT_TRUE(testBuildAttr(34, 0, ARMBuildAttrs::CPU_unaligned_access,
164 ARMBuildAttrs::Not_Allowed));
165 EXPECT_TRUE(testBuildAttr(34, 1, ARMBuildAttrs::CPU_unaligned_access,
166 ARMBuildAttrs::Allowed));
167 }
168
169 TEST(T2EEBuildAttr, testBuildAttr) {
170 EXPECT_TRUE(testTagString(66, "Tag_T2EE_use"));
171 EXPECT_TRUE(testBuildAttr(66, 0, ARMBuildAttrs::T2EE_use,
172 ARMBuildAttrs::Not_Allowed));
173 EXPECT_TRUE(testBuildAttr(66, 1, ARMBuildAttrs::T2EE_use,
174 ARMBuildAttrs::Allowed));
175 }
176
177 TEST(VirtualizationBuildAttr, testBuildAttr) {
178 EXPECT_TRUE(testTagString(68, "Tag_Virtualization_use"));
179 EXPECT_TRUE(testBuildAttr(68, 0, ARMBuildAttrs::Virtualization_use,
180 ARMBuildAttrs::Not_Allowed));
181 EXPECT_TRUE(testBuildAttr(68, 1, ARMBuildAttrs::Virtualization_use,
182 ARMBuildAttrs::AllowTZ));
183 EXPECT_TRUE(testBuildAttr(68, 2, ARMBuildAttrs::Virtualization_use,
184 ARMBuildAttrs::AllowVirtualization));
185 EXPECT_TRUE(testBuildAttr(68, 3, ARMBuildAttrs::Virtualization_use,
186 ARMBuildAttrs::AllowTZVirtualization));
187 }
188
189 TEST(MPBuildAttr, testBuildAttr) {
190 EXPECT_TRUE(testTagString(42, "Tag_MPextension_use"));
191 EXPECT_TRUE(testBuildAttr(42, 0, ARMBuildAttrs::MPextension_use,
192 ARMBuildAttrs::Not_Allowed));
193 EXPECT_TRUE(testBuildAttr(42, 1, ARMBuildAttrs::MPextension_use,
194 ARMBuildAttrs::AllowMP));
195 }
196
197 TEST(DivBuildAttr, testBuildAttr) {
198 EXPECT_TRUE(testTagString(44, "Tag_DIV_use"));
199 EXPECT_TRUE(testBuildAttr(44, 0, ARMBuildAttrs::DIV_use,
200 ARMBuildAttrs::AllowDIVIfExists));
201 EXPECT_TRUE(testBuildAttr(44, 1, ARMBuildAttrs::DIV_use,
202 ARMBuildAttrs::DisallowDIV));
203 EXPECT_TRUE(testBuildAttr(44, 2, ARMBuildAttrs::DIV_use,
204 ARMBuildAttrs::AllowDIVExt));
205 }
206
207 TEST(PCS_ConfigBuildAttr, testBuildAttr) {
208 EXPECT_TRUE(testTagString(13, "Tag_PCS_config"));
209 EXPECT_TRUE(testBuildAttr(13, 0, ARMBuildAttrs::PCS_config, 0));
210 EXPECT_TRUE(testBuildAttr(13, 1, ARMBuildAttrs::PCS_config, 1));
211 EXPECT_TRUE(testBuildAttr(13, 2, ARMBuildAttrs::PCS_config, 2));
212 EXPECT_TRUE(testBuildAttr(13, 3, ARMBuildAttrs::PCS_config, 3));
213 EXPECT_TRUE(testBuildAttr(13, 4, ARMBuildAttrs::PCS_config, 4));
214 EXPECT_TRUE(testBuildAttr(13, 5, ARMBuildAttrs::PCS_config, 5));
215 EXPECT_TRUE(testBuildAttr(13, 6, ARMBuildAttrs::PCS_config, 6));
216 EXPECT_TRUE(testBuildAttr(13, 7, ARMBuildAttrs::PCS_config, 7));
217 }
218
219 TEST(PCS_R9BuildAttr, testBuildAttr) {
220 EXPECT_TRUE(testTagString(14, "Tag_ABI_PCS_R9_use"));
221 EXPECT_TRUE(testBuildAttr(14, 0, ARMBuildAttrs::ABI_PCS_R9_use,
222 ARMBuildAttrs::R9IsGPR));
223 EXPECT_TRUE(testBuildAttr(14, 1, ARMBuildAttrs::ABI_PCS_R9_use,
224 ARMBuildAttrs::R9IsSB));
225 EXPECT_TRUE(testBuildAttr(14, 2, ARMBuildAttrs::ABI_PCS_R9_use,
226 ARMBuildAttrs::R9IsTLSPointer));
227 EXPECT_TRUE(testBuildAttr(14, 3, ARMBuildAttrs::ABI_PCS_R9_use,
228 ARMBuildAttrs::R9Reserved));
229 }
230
231 TEST(PCS_RWBuildAttr, testBuildAttr) {
232 EXPECT_TRUE(testTagString(15, "Tag_ABI_PCS_RW_data"));
233 EXPECT_TRUE(testBuildAttr(15, 0, ARMBuildAttrs::ABI_PCS_RW_data,
234 ARMBuildAttrs::Not_Allowed));
235 EXPECT_TRUE(testBuildAttr(15, 1, ARMBuildAttrs::ABI_PCS_RW_data,
236 ARMBuildAttrs::AddressRWPCRel));
237 EXPECT_TRUE(testBuildAttr(15, 2, ARMBuildAttrs::ABI_PCS_RW_data,
238 ARMBuildAttrs::AddressRWSBRel));
239 EXPECT_TRUE(testBuildAttr(15, 3, ARMBuildAttrs::ABI_PCS_RW_data,
240 ARMBuildAttrs::AddressRWNone));
241 }
242
243 TEST(PCS_ROBuildAttr, testBuildAttr) {
244 EXPECT_TRUE(testTagString(16, "Tag_ABI_PCS_RO_data"));
245 EXPECT_TRUE(testBuildAttr(16, 0, ARMBuildAttrs::ABI_PCS_RO_data,
246 ARMBuildAttrs::Not_Allowed));
247 EXPECT_TRUE(testBuildAttr(16, 1, ARMBuildAttrs::ABI_PCS_RO_data,
248 ARMBuildAttrs::AddressROPCRel));
249 EXPECT_TRUE(testBuildAttr(16, 2, ARMBuildAttrs::ABI_PCS_RO_data,
250 ARMBuildAttrs::AddressRONone));
251 }
252
253 TEST(PCS_GOTBuildAttr, testBuildAttr) {
254 EXPECT_TRUE(testTagString(17, "Tag_ABI_PCS_GOT_use"));
255 EXPECT_TRUE(testBuildAttr(17, 0, ARMBuildAttrs::ABI_PCS_GOT_use,
256 ARMBuildAttrs::Not_Allowed));
257 EXPECT_TRUE(testBuildAttr(17, 1, ARMBuildAttrs::ABI_PCS_GOT_use,
258 ARMBuildAttrs::AddressDirect));
259 EXPECT_TRUE(testBuildAttr(17, 2, ARMBuildAttrs::ABI_PCS_GOT_use,
260 ARMBuildAttrs::AddressGOT));
261 }
262
263 TEST(PCS_WCharBuildAttr, testBuildAttr) {
264 EXPECT_TRUE(testTagString(18, "Tag_ABI_PCS_wchar_t"));
265 EXPECT_TRUE(testBuildAttr(18, 0, ARMBuildAttrs::ABI_PCS_wchar_t,
266 ARMBuildAttrs::WCharProhibited));
267 EXPECT_TRUE(testBuildAttr(18, 2, ARMBuildAttrs::ABI_PCS_wchar_t,
268 ARMBuildAttrs::WCharWidth2Bytes));
269 EXPECT_TRUE(testBuildAttr(18, 4, ARMBuildAttrs::ABI_PCS_wchar_t,
270 ARMBuildAttrs::WCharWidth4Bytes));
271 }
272
273 TEST(EnumSizeBuildAttr, testBuildAttr) {
274 EXPECT_TRUE(testTagString(26, "Tag_ABI_enum_size"));
275 EXPECT_TRUE(testBuildAttr(26, 0, ARMBuildAttrs::ABI_enum_size,
276 ARMBuildAttrs::EnumProhibited));
277 EXPECT_TRUE(testBuildAttr(26, 1, ARMBuildAttrs::ABI_enum_size,
278 ARMBuildAttrs::EnumSmallest));
279 EXPECT_TRUE(testBuildAttr(26, 2, ARMBuildAttrs::ABI_enum_size,
280 ARMBuildAttrs::Enum32Bit));
281 EXPECT_TRUE(testBuildAttr(26, 3, ARMBuildAttrs::ABI_enum_size,
282 ARMBuildAttrs::Enum32BitABI));
283 }
284
285 TEST(AlignNeededBuildAttr, testBuildAttr) {
286 EXPECT_TRUE(testTagString(24, "Tag_ABI_align_needed"));
287 EXPECT_TRUE(testBuildAttr(24, 0, ARMBuildAttrs::ABI_align_needed,
288 ARMBuildAttrs::Not_Allowed));
289 EXPECT_TRUE(testBuildAttr(24, 1, ARMBuildAttrs::ABI_align_needed,
290 ARMBuildAttrs::Align8Byte));
291 EXPECT_TRUE(testBuildAttr(24, 2, ARMBuildAttrs::ABI_align_needed,
292 ARMBuildAttrs::Align4Byte));
293 EXPECT_TRUE(testBuildAttr(24, 3, ARMBuildAttrs::ABI_align_needed,
294 ARMBuildAttrs::AlignReserved));
295 }
296
297 TEST(AlignPreservedBuildAttr, testBuildAttr) {
298 EXPECT_TRUE(testTagString(25, "Tag_ABI_align_preserved"));
299 EXPECT_TRUE(testBuildAttr(25, 0, ARMBuildAttrs::ABI_align_preserved,
300 ARMBuildAttrs::AlignNotPreserved));
301 EXPECT_TRUE(testBuildAttr(25, 1, ARMBuildAttrs::ABI_align_preserved,
302 ARMBuildAttrs::AlignPreserve8Byte));
303 EXPECT_TRUE(testBuildAttr(25, 2, ARMBuildAttrs::ABI_align_preserved,
304 ARMBuildAttrs::AlignPreserveAll));
305 EXPECT_TRUE(testBuildAttr(25, 3, ARMBuildAttrs::ABI_align_preserved,
306 ARMBuildAttrs::AlignReserved));
307 }
308
309 TEST(FPRoundingBuildAttr, testBuildAttr) {
310 EXPECT_TRUE(testTagString(19, "Tag_ABI_FP_rounding"));
311 EXPECT_TRUE(testBuildAttr(19, 0, ARMBuildAttrs::ABI_FP_rounding, 0));
312 EXPECT_TRUE(testBuildAttr(19, 1, ARMBuildAttrs::ABI_FP_rounding, 1));
313 }
314
315 TEST(FPDenormalBuildAttr, testBuildAttr) {
316 EXPECT_TRUE(testTagString(20, "Tag_ABI_FP_denormal"));
317 EXPECT_TRUE(testBuildAttr(20, 0, ARMBuildAttrs::ABI_FP_denormal,
318 ARMBuildAttrs::PositiveZero));
319 EXPECT_TRUE(testBuildAttr(20, 1, ARMBuildAttrs::ABI_FP_denormal,
320 ARMBuildAttrs::IEEEDenormals));
321 EXPECT_TRUE(testBuildAttr(20, 2, ARMBuildAttrs::ABI_FP_denormal,
322 ARMBuildAttrs::PreserveFPSign));
323 }
324
325 TEST(FPExceptionsBuildAttr, testBuildAttr) {
326 EXPECT_TRUE(testTagString(21, "Tag_ABI_FP_exceptions"));
327 EXPECT_TRUE(testBuildAttr(21, 0, ARMBuildAttrs::ABI_FP_exceptions, 0));
328 EXPECT_TRUE(testBuildAttr(21, 1, ARMBuildAttrs::ABI_FP_exceptions, 1));
329 }
330
331 TEST(FPUserExceptionsBuildAttr, testBuildAttr) {
332 EXPECT_TRUE(testTagString(22, "Tag_ABI_FP_user_exceptions"));
333 EXPECT_TRUE(testBuildAttr(22, 0, ARMBuildAttrs::ABI_FP_user_exceptions, 0));
334 EXPECT_TRUE(testBuildAttr(22, 1, ARMBuildAttrs::ABI_FP_user_exceptions, 1));
335 }
336
337 TEST(FPNumberModelBuildAttr, testBuildAttr) {
338 EXPECT_TRUE(testTagString(23, "Tag_ABI_FP_number_model"));
339 EXPECT_TRUE(testBuildAttr(23, 0, ARMBuildAttrs::ABI_FP_number_model,
340 ARMBuildAttrs::Not_Allowed));
341 EXPECT_TRUE(testBuildAttr(23, 1, ARMBuildAttrs::ABI_FP_number_model,
342 ARMBuildAttrs::AllowIEEENormal));
343 EXPECT_TRUE(testBuildAttr(23, 2, ARMBuildAttrs::ABI_FP_number_model,
344 ARMBuildAttrs::AllowRTABI));
345 EXPECT_TRUE(testBuildAttr(23, 3, ARMBuildAttrs::ABI_FP_number_model,
346 ARMBuildAttrs::AllowIEEE754));
347 }
348
349 TEST(FP16BuildAttr, testBuildAttr) {
350 EXPECT_TRUE(testTagString(38, "Tag_ABI_FP_16bit_format"));
351 EXPECT_TRUE(testBuildAttr(38, 0, ARMBuildAttrs::ABI_FP_16bit_format,
352 ARMBuildAttrs::Not_Allowed));
353 EXPECT_TRUE(testBuildAttr(38, 1, ARMBuildAttrs::ABI_FP_16bit_format,
354 ARMBuildAttrs::FP16FormatIEEE));
355 EXPECT_TRUE(testBuildAttr(38, 2, ARMBuildAttrs::ABI_FP_16bit_format,
356 ARMBuildAttrs::FP16VFP3));
357 }
358
359 TEST(HardFPBuildAttr, testBuildAttr) {
360 EXPECT_TRUE(testTagString(27, "Tag_ABI_HardFP_use"));
361 EXPECT_TRUE(testBuildAttr(27, 0, ARMBuildAttrs::ABI_HardFP_use,
362 ARMBuildAttrs::HardFPImplied));
363 EXPECT_TRUE(testBuildAttr(27, 1, ARMBuildAttrs::ABI_HardFP_use,
364 ARMBuildAttrs::HardFPSinglePrecision));
365 EXPECT_TRUE(testBuildAttr(27, 2, ARMBuildAttrs::ABI_HardFP_use, 2));
366 }
367
368 TEST(VFPArgsBuildAttr, testBuildAttr) {
369 EXPECT_TRUE(testTagString(28, "Tag_ABI_VFP_args"));
370 EXPECT_TRUE(testBuildAttr(28, 0, ARMBuildAttrs::ABI_VFP_args,
371 ARMBuildAttrs::BaseAAPCS));
372 EXPECT_TRUE(testBuildAttr(28, 1, ARMBuildAttrs::ABI_VFP_args,
373 ARMBuildAttrs::HardFPAAPCS));
374 EXPECT_TRUE(testBuildAttr(28, 2, ARMBuildAttrs::ABI_VFP_args, 2));
375 EXPECT_TRUE(testBuildAttr(28, 3, ARMBuildAttrs::ABI_VFP_args, 3));
376 }
377
378 TEST(WMMXArgsBuildAttr, testBuildAttr) {
379 EXPECT_TRUE(testTagString(29, "Tag_ABI_WMMX_args"));
380 EXPECT_TRUE(testBuildAttr(29, 0, ARMBuildAttrs::ABI_WMMX_args, 0));
381 EXPECT_TRUE(testBuildAttr(29, 1, ARMBuildAttrs::ABI_WMMX_args, 1));
382 EXPECT_TRUE(testBuildAttr(29, 2, ARMBuildAttrs::ABI_WMMX_args, 2));
383 }
44 add_llvm_unittest(SupportTests
55 AlignOfTest.cpp
66 AllocatorTest.cpp
7 ARMAttributeParser.cpp
87 ArrayRecyclerTest.cpp
98 BlockFrequencyTest.cpp
109 BranchProbabilityTest.cpp