diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Object/ELFObjectFile.cpp | 65 | ||||
-rw-r--r-- | llvm/lib/Support/ARMAttributeParser.cpp | 119 | ||||
-rw-r--r-- | llvm/lib/Target/ARM/ARMAsmPrinter.cpp | 2 |
3 files changed, 48 insertions, 138 deletions
diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index d33da47d6cb..4bd69e34e3c 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -122,69 +122,4 @@ SubtargetFeatures ELFObjectFileBase::getFeatures() const { } } -// FIXME Encode from a tablegen description or target parser. -void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const { - if (TheTriple.getSubArch() != Triple::NoSubArch) - return; - - ARMAttributeParser Attributes; - std::error_code EC = getBuildAttributes(Attributes); - if (EC) - return; - - std::string Triple; - // Default to ARM, but use the triple if it's been set. - if (TheTriple.getArch() == Triple::thumb || - TheTriple.getArch() == Triple::thumbeb) - Triple = "thumb"; - else - Triple = "arm"; - - switch(Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch)) { - case ARMBuildAttrs::v4: - Triple += "v4"; - break; - case ARMBuildAttrs::v4T: - Triple += "v4t"; - break; - case ARMBuildAttrs::v5T: - Triple += "v5t"; - break; - case ARMBuildAttrs::v5TE: - Triple += "v5te"; - break; - case ARMBuildAttrs::v5TEJ: - Triple += "v5tej"; - break; - case ARMBuildAttrs::v6: - Triple += "v6"; - break; - case ARMBuildAttrs::v6KZ: - Triple += "v6kz"; - break; - case ARMBuildAttrs::v6T2: - Triple += "v6t2"; - break; - case ARMBuildAttrs::v6K: - Triple += "v6k"; - break; - case ARMBuildAttrs::v7: - Triple += "v7"; - break; - case ARMBuildAttrs::v6_M: - Triple += "v6m"; - break; - case ARMBuildAttrs::v6S_M: - Triple += "v6sm"; - break; - case ARMBuildAttrs::v7E_M: - Triple += "v7em"; - break; - } - if (!isLittleEndian()) - Triple += "eb"; - - TheTriple.setArchName(Triple); -} - } // end namespace llvm diff --git a/llvm/lib/Support/ARMAttributeParser.cpp b/llvm/lib/Support/ARMAttributeParser.cpp index 6ab072d683d..792510e6b84 100644 --- a/llvm/lib/Support/ARMAttributeParser.cpp +++ b/llvm/lib/Support/ARMAttributeParser.cpp @@ -89,43 +89,32 @@ StringRef ARMAttributeParser::ParseString(const uint8_t *Data, void ARMAttributeParser::IntegerAttribute(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { - - uint64_t Value = ParseInteger(Data, Offset); - Attributes.insert(std::make_pair(Tag, Value)); - - if (SW) - SW->printNumber(ARMBuildAttrs::AttrTypeAsString(Tag), Value); + SW.printNumber(ARMBuildAttrs::AttrTypeAsString(Tag), + ParseInteger(Data, Offset)); } void ARMAttributeParser::StringAttribute(AttrType Tag, const uint8_t *Data, uint32_t &Offset) { StringRef TagName = ARMBuildAttrs::AttrTypeAsString(Tag, /*TagPrefix*/false); - StringRef ValueDesc = ParseString(Data, Offset); - - if (SW) { - DictScope AS(*SW, "Attribute"); - SW->printNumber("Tag", Tag); - if (!TagName.empty()) - SW->printString("TagName", TagName); - SW->printString("Value", ValueDesc); - } + + DictScope AS(SW, "Attribute"); + SW.printNumber("Tag", Tag); + if (!TagName.empty()) + SW.printString("TagName", TagName); + SW.printString("Value", ParseString(Data, Offset)); } void ARMAttributeParser::PrintAttribute(unsigned Tag, unsigned Value, StringRef ValueDesc) { - Attributes.insert(std::make_pair(Tag, Value)); - - if (SW) { - StringRef TagName = ARMBuildAttrs::AttrTypeAsString(Tag, - /*TagPrefix*/false); - DictScope AS(*SW, "Attribute"); - SW->printNumber("Tag", Tag); - SW->printNumber("Value", Value); - if (!TagName.empty()) - SW->printString("TagName", TagName); - if (!ValueDesc.empty()) - SW->printString("Description", ValueDesc); - } + StringRef TagName = ARMBuildAttrs::AttrTypeAsString(Tag, /*TagPrefix*/false); + + DictScope AS(SW, "Attribute"); + SW.printNumber("Tag", Tag); + SW.printNumber("Value", Value); + if (!TagName.empty()) + SW.printString("TagName", TagName); + if (!ValueDesc.empty()) + SW.printString("Description", ValueDesc); } void ARMAttributeParser::CPU_arch(AttrType Tag, const uint8_t *Data, @@ -460,22 +449,20 @@ void ARMAttributeParser::compatibility(AttrType Tag, const uint8_t *Data, uint64_t Integer = ParseInteger(Data, Offset); StringRef String = ParseString(Data, Offset); - if (SW) { - DictScope AS(*SW, "Attribute"); - SW->printNumber("Tag", Tag); - SW->startLine() << "Value: " << Integer << ", " << String << '\n'; - SW->printString("TagName", AttrTypeAsString(Tag, /*TagPrefix*/false)); - switch (Integer) { - case 0: - SW->printString("Description", StringRef("No Specific Requirements")); - break; - case 1: - SW->printString("Description", StringRef("AEABI Conformant")); - break; - default: - SW->printString("Description", StringRef("AEABI Non-Conformant")); - break; - } + DictScope AS(SW, "Attribute"); + SW.printNumber("Tag", Tag); + SW.startLine() << "Value: " << Integer << ", " << String << '\n'; + SW.printString("TagName", AttrTypeAsString(Tag, /*TagPrefix*/false)); + switch (Integer) { + case 0: + SW.printString("Description", StringRef("No Specific Requirements")); + break; + case 1: + SW.printString("Description", StringRef("AEABI Conformant")); + break; + default: + SW.printString("Description", StringRef("AEABI Non-Conformant")); + break; } } @@ -617,33 +604,27 @@ void ARMAttributeParser::ParseAttributeList(const uint8_t *Data, void ARMAttributeParser::ParseSubsection(const uint8_t *Data, uint32_t Length) { uint32_t Offset = sizeof(uint32_t); /* SectionLength */ + SW.printNumber("SectionLength", Length); + const char *VendorName = reinterpret_cast<const char*>(Data + Offset); size_t VendorNameLength = std::strlen(VendorName); + SW.printString("Vendor", StringRef(VendorName, VendorNameLength)); Offset = Offset + VendorNameLength + 1; - if (SW) { - SW->printNumber("SectionLength", Length); - SW->printString("Vendor", StringRef(VendorName, VendorNameLength)); - } - - if (StringRef(VendorName, VendorNameLength).lower() != "aeabi") { + if (StringRef(VendorName, VendorNameLength).lower() != "aeabi") return; - } while (Offset < Length) { /// Tag_File | Tag_Section | Tag_Symbol uleb128:byte-size uint8_t Tag = Data[Offset]; + SW.printEnum("Tag", Tag, makeArrayRef(TagNames)); Offset = Offset + sizeof(Tag); uint32_t Size = *reinterpret_cast<const support::ulittle32_t*>(Data + Offset); + SW.printNumber("Size", Size); Offset = Offset + sizeof(Size); - if (SW) { - SW->printEnum("Tag", Tag, makeArrayRef(TagNames)); - SW->printNumber("Size", Size); - } - if (Size > Length) { errs() << "subsection length greater than section length\n"; return; @@ -670,37 +651,31 @@ void ARMAttributeParser::ParseSubsection(const uint8_t *Data, uint32_t Length) { return; } - if (SW) { - DictScope ASS(*SW, ScopeName); - if (!Indicies.empty()) - SW->printList(IndexName, Indicies); - } + DictScope ASS(SW, ScopeName); + + if (!Indicies.empty()) + SW.printList(IndexName, Indicies); ParseAttributeList(Data, Offset, Length); } } -void ARMAttributeParser::Parse(ArrayRef<uint8_t> Section, bool isLittle) { +void ARMAttributeParser::Parse(ArrayRef<uint8_t> Section) { size_t Offset = 1; unsigned SectionNumber = 0; while (Offset < Section.size()) { uint32_t SectionLength = - isLittle ? support::endian::read32le(Section.data() + Offset) - : support::endian::read32be(Section.data() + Offset); + *reinterpret_cast<const support::ulittle32_t*>(Section.data() + Offset); - if (SW) { - SW->startLine() << "Section " << ++SectionNumber << " {\n"; - SW->indent(); - } + SW.startLine() << "Section " << ++SectionNumber << " {\n"; + SW.indent(); ParseSubsection(Section.data() + Offset, SectionLength); Offset = Offset + SectionLength; - if (SW) { - SW->unindent(); - SW->startLine() << "}\n"; - } + SW.unindent(); + SW.startLine() << "}\n"; } } } diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index f852805408c..8ec9cb02813 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -841,7 +841,7 @@ void ARMAsmPrinter::emitAttributes() { ARMBuildAttrs::Allowed); else ATS.emitAttribute(ARMBuildAttrs::ABI_FP_number_model, - ARMBuildAttrs::AllowIEEE754); + ARMBuildAttrs::AllowIEE754); if (STI.allowsUnalignedMem()) ATS.emitAttribute(ARMBuildAttrs::CPU_unaligned_access, |