diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Utility/ArchSpec.cpp | |
parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) |
Notes
Diffstat (limited to 'source/Utility/ArchSpec.cpp')
-rw-r--r-- | source/Utility/ArchSpec.cpp | 79 |
1 files changed, 19 insertions, 60 deletions
diff --git a/source/Utility/ArchSpec.cpp b/source/Utility/ArchSpec.cpp index 752fb182d79a..81b87fff88d4 100644 --- a/source/Utility/ArchSpec.cpp +++ b/source/Utility/ArchSpec.cpp @@ -1,9 +1,8 @@ //===-- ArchSpec.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -215,13 +214,7 @@ static const CoreDefinition g_core_definitions[] = { ArchSpec::eCore_uknownMach32, "unknown-mach-32"}, {eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch, ArchSpec::eCore_uknownMach64, "unknown-mach-64"}, - - {eByteOrderBig, 4, 1, 1, llvm::Triple::kalimba, ArchSpec::eCore_kalimba3, - "kalimba3"}, - {eByteOrderLittle, 4, 1, 1, llvm::Triple::kalimba, ArchSpec::eCore_kalimba4, - "kalimba4"}, - {eByteOrderLittle, 4, 1, 1, llvm::Triple::kalimba, ArchSpec::eCore_kalimba5, - "kalimba5"}}; +}; // Ensure that we have an entry in the g_core_definitions for each core. If you // comment out an entry above, you will need to comment out the corresponding @@ -453,12 +446,6 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = { ArchSpec::eMIPSSubType_mips64r6el, 0xFFFFFFFFu, 0xFFFFFFFFu}, // mips64r6el {ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}, // HEXAGON - {ArchSpec::eCore_kalimba3, llvm::ELF::EM_CSR_KALIMBA, - llvm::Triple::KalimbaSubArch_v3, 0xFFFFFFFFu, 0xFFFFFFFFu}, // KALIMBA - {ArchSpec::eCore_kalimba4, llvm::ELF::EM_CSR_KALIMBA, - llvm::Triple::KalimbaSubArch_v4, 0xFFFFFFFFu, 0xFFFFFFFFu}, // KALIMBA - {ArchSpec::eCore_kalimba5, llvm::ELF::EM_CSR_KALIMBA, - llvm::Triple::KalimbaSubArch_v5, 0xFFFFFFFFu, 0xFFFFFFFFu} // KALIMBA }; static const ArchDefinition g_elf_arch_def = { @@ -608,11 +595,7 @@ const char *ArchSpec::GetArchitectureName() const { return "unknown"; } -bool ArchSpec::IsMIPS() const { - const llvm::Triple::ArchType machine = GetMachine(); - return machine == llvm::Triple::mips || machine == llvm::Triple::mipsel || - machine == llvm::Triple::mips64 || machine == llvm::Triple::mips64el; -} +bool ArchSpec::IsMIPS() const { return GetTriple().isMIPS(); } std::string ArchSpec::GetTargetABI() const { @@ -652,10 +635,8 @@ void ArchSpec::SetFlags(std::string elf_abi) { std::string ArchSpec::GetClangTargetCPU() const { std::string cpu; - const llvm::Triple::ArchType machine = GetMachine(); - if (machine == llvm::Triple::mips || machine == llvm::Triple::mipsel || - machine == llvm::Triple::mips64 || machine == llvm::Triple::mips64el) { + if (IsMIPS()) { switch (m_core) { case ArchSpec::eCore_mips32: case ArchSpec::eCore_mips32el: @@ -729,30 +710,10 @@ uint32_t ArchSpec::GetMachOCPUSubType() const { } uint32_t ArchSpec::GetDataByteSize() const { - switch (m_core) { - case eCore_kalimba3: - return 4; - case eCore_kalimba4: - return 1; - case eCore_kalimba5: - return 4; - default: - return 1; - } return 1; } uint32_t ArchSpec::GetCodeByteSize() const { - switch (m_core) { - case eCore_kalimba3: - return 4; - case eCore_kalimba4: - return 1; - case eCore_kalimba5: - return 1; - default: - return 1; - } return 1; } @@ -764,7 +725,7 @@ llvm::Triple::ArchType ArchSpec::GetMachine() const { return llvm::Triple::UnknownArch; } -const ConstString &ArchSpec::GetDistributionId() const { +ConstString ArchSpec::GetDistributionId() const { return m_distribution_id; } @@ -890,10 +851,9 @@ bool ArchSpec::ContainsOnlyArch(const llvm::Triple &normalized_triple) { } void ArchSpec::MergeFrom(const ArchSpec &other) { - if (TripleVendorIsUnspecifiedUnknown() && - !other.TripleVendorIsUnspecifiedUnknown()) + if (!TripleVendorWasSpecified() && other.TripleVendorWasSpecified()) GetTriple().setVendor(other.GetTriple().getVendor()); - if (TripleOSIsUnspecifiedUnknown() && !other.TripleOSIsUnspecifiedUnknown()) + if (!TripleOSWasSpecified() && other.TripleOSWasSpecified()) GetTriple().setOS(other.GetTriple().getOS()); if (GetTriple().getArch() == llvm::Triple::UnknownArch) { GetTriple().setArch(other.GetTriple().getArch()); @@ -904,10 +864,9 @@ void ArchSpec::MergeFrom(const ArchSpec &other) { if (other.GetCore() != eCore_uknownMach64) UpdateCore(); } - if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment && - !TripleVendorWasSpecified()) { - if (other.TripleVendorWasSpecified()) - GetTriple().setEnvironment(other.GetTriple().getEnvironment()); + if (!TripleEnvironmentWasSpecified() && + other.TripleEnvironmentWasSpecified()) { + GetTriple().setEnvironment(other.GetTriple().getEnvironment()); } // If this and other are both arm ArchSpecs and this ArchSpec is a generic // "some kind of arm" spec but the other ArchSpec is a specific arm core, @@ -945,13 +904,13 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu, m_triple.setVendor(llvm::Triple::Apple); // Don't set the OS. It could be simulator, macosx, ios, watchos, - // tvos, bridgeos. We could get close with the cpu type - but we - // can't get it right all of the time. Better to leave this unset - // so other sections of code will set it when they have more - // information. NB: don't call m_triple.setOS (llvm::Triple::UnknownOS). - // That sets the OSName to "unknown" and the - // ArchSpec::TripleVendorWasSpecified() method says that any OSName - // setting means it was specified. + // tvos, bridgeos. We could get close with the cpu type - but we + // can't get it right all of the time. Better to leave this unset + // so other sections of code will set it when they have more + // information. NB: don't call m_triple.setOS + // (llvm::Triple::UnknownOS). That sets the OSName to "unknown" and + // the ArchSpec::TripleVendorWasSpecified() method says that any + // OSName setting means it was specified. } else if (arch_type == eArchTypeELF) { switch (os) { case llvm::ELF::ELFOSABI_AIX: |