summaryrefslogtreecommitdiff
path: root/lib/Object/ELFObjectFile.cpp
diff options
context:
space:
mode:
authorSam Parker <sam.parker@arm.com>2017-01-18 13:52:12 +0000
committerSam Parker <sam.parker@arm.com>2017-01-18 13:52:12 +0000
commitaa9676306392bfec05a0c43a9d77349c8ab4c003 (patch)
tree13935e5230f75ddfd902bc59489b92b9f7c899f9 /lib/Object/ELFObjectFile.cpp
parentcaaf153fef329fc386a21fbb6e3c973794523640 (diff)
downloadllvm-aa9676306392bfec05a0c43a9d77349c8ab4c003.tar.gz
[ARM] Create objdump subtarget from build attrs
Enable an ELFObjectFile to read the its arm build attributes to produce a target triple with a specific ARM architecture. llvm-objdump now uses this functionality to automatically produce a more accurate target. Differential Revision: https://reviews.llvm.org/D28769 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292366 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object/ELFObjectFile.cpp')
-rw-r--r--lib/Object/ELFObjectFile.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/Object/ELFObjectFile.cpp b/lib/Object/ELFObjectFile.cpp
index 4bd69e34e3c3..fb133c254d00 100644
--- a/lib/Object/ELFObjectFile.cpp
+++ b/lib/Object/ELFObjectFile.cpp
@@ -122,4 +122,71 @@ 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";
+
+ if (Attributes.hasAttribute(ARMBuildAttrs::CPU_arch)) {
+ 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