mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-25 17:20:48 +00:00
Simplify now that we always use an alignment of 2 for ELF files.
This saves 123144 bytes out of llvm-nm on powerpc64le. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238824 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -27,51 +27,27 @@ ObjectFile::createELFObjectFile(MemoryBufferRef Obj) {
|
||||
std::size_t MaxAlignment =
|
||||
1ULL << countTrailingZeros(uintptr_t(Obj.getBufferStart()));
|
||||
|
||||
if (MaxAlignment < 2)
|
||||
return object_error::parse_failed;
|
||||
|
||||
std::error_code EC;
|
||||
std::unique_ptr<ObjectFile> R;
|
||||
if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2LSB)
|
||||
#if !LLVM_IS_UNALIGNED_ACCESS_FAST
|
||||
if (MaxAlignment >= 4)
|
||||
R.reset(new ELFObjectFile<ELFType<support::little, 4, false>>(Obj, EC));
|
||||
if (Ident.first == ELF::ELFCLASS32) {
|
||||
if (Ident.second == ELF::ELFDATA2LSB)
|
||||
R.reset(new ELFObjectFile<ELFType<support::little, false>>(Obj, EC));
|
||||
else if (Ident.second == ELF::ELFDATA2MSB)
|
||||
R.reset(new ELFObjectFile<ELFType<support::big, false>>(Obj, EC));
|
||||
else
|
||||
#endif
|
||||
if (MaxAlignment >= 2)
|
||||
R.reset(new ELFObjectFile<ELFType<support::little, 2, false>>(Obj, EC));
|
||||
llvm_unreachable("Buffer is not an ELF object file!");
|
||||
} else {
|
||||
assert(Ident.first == ELF::ELFCLASS64);
|
||||
if (Ident.second == ELF::ELFDATA2LSB)
|
||||
R.reset(new ELFObjectFile<ELFType<support::little, true>>(Obj, EC));
|
||||
else if (Ident.second == ELF::ELFDATA2MSB)
|
||||
R.reset(new ELFObjectFile<ELFType<support::big, true>>(Obj, EC));
|
||||
else
|
||||
return object_error::parse_failed;
|
||||
else if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2MSB)
|
||||
#if !LLVM_IS_UNALIGNED_ACCESS_FAST
|
||||
if (MaxAlignment >= 4)
|
||||
R.reset(new ELFObjectFile<ELFType<support::big, 4, false>>(Obj, EC));
|
||||
else
|
||||
#endif
|
||||
if (MaxAlignment >= 2)
|
||||
R.reset(new ELFObjectFile<ELFType<support::big, 2, false>>(Obj, EC));
|
||||
else
|
||||
return object_error::parse_failed;
|
||||
else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2MSB)
|
||||
#if !LLVM_IS_UNALIGNED_ACCESS_FAST
|
||||
if (MaxAlignment >= 8)
|
||||
R.reset(new ELFObjectFile<ELFType<support::big, 8, true>>(Obj, EC));
|
||||
else
|
||||
#endif
|
||||
if (MaxAlignment >= 2)
|
||||
R.reset(new ELFObjectFile<ELFType<support::big, 2, true>>(Obj, EC));
|
||||
else
|
||||
return object_error::parse_failed;
|
||||
else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2LSB) {
|
||||
#if !LLVM_IS_UNALIGNED_ACCESS_FAST
|
||||
if (MaxAlignment >= 8)
|
||||
R.reset(new ELFObjectFile<ELFType<support::little, 8, true>>(Obj, EC));
|
||||
else
|
||||
#endif
|
||||
if (MaxAlignment >= 2)
|
||||
R.reset(new ELFObjectFile<ELFType<support::little, 2, true>>(Obj, EC));
|
||||
else
|
||||
return object_error::parse_failed;
|
||||
llvm_unreachable("Buffer is not an ELF object file!");
|
||||
}
|
||||
else
|
||||
llvm_unreachable("Buffer is not an ELF object file!");
|
||||
|
||||
if (EC)
|
||||
return EC;
|
||||
|
Reference in New Issue
Block a user