diff options
Diffstat (limited to 'source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp')
-rw-r--r-- | source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp index 5df8422505915..44c75fc953c82 100644 --- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp +++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp @@ -1,9 +1,8 @@ //===-- DisassemblerLLVMC.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 // //===----------------------------------------------------------------------===// @@ -357,7 +356,7 @@ public: return; else { const uint8_t *bytes = data.PeekData(offset, inst_size); - if (bytes == NULL) + if (bytes == nullptr) return; m_opcode_name.assign(".byte"); m_opcode.SetOpcodeBytes(bytes, inst_size); @@ -957,7 +956,7 @@ DisassemblerLLVMC::MCDisasmInstance::Create(const char *triple, const char *cpu, return Instance(); std::unique_ptr<llvm::MCContext> context_up( - new llvm::MCContext(asm_info_up.get(), reg_info_up.get(), 0)); + new llvm::MCContext(asm_info_up.get(), reg_info_up.get(), nullptr)); if (!context_up) return Instance(); @@ -1080,7 +1079,7 @@ bool DisassemblerLLVMC::MCDisasmInstance::IsCall(llvm::MCInst &mc_inst) const { DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch, const char *flavor_string) - : Disassembler(arch, flavor_string), m_exe_ctx(NULL), m_inst(NULL), + : Disassembler(arch, flavor_string), m_exe_ctx(nullptr), m_inst(nullptr), m_data_from_file(false) { if (!FlavorValidForArchSpec(arch, m_flavor.c_str())) { m_flavor.assign("default"); @@ -1179,10 +1178,7 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch, break; } - if (triple.getArch() == llvm::Triple::mips || - triple.getArch() == llvm::Triple::mipsel || - triple.getArch() == llvm::Triple::mips64 || - triple.getArch() == llvm::Triple::mips64el) { + if (arch.IsMIPS()) { uint32_t arch_flags = arch.GetFlags(); if (arch_flags & ArchSpec::eMIPSAse_msa) features_str += "+msa,"; @@ -1192,12 +1188,17 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch, features_str += "+dspr2,"; } - // If any AArch64 variant, enable the ARMv8.2 ISA extensions so we can - // disassemble newer instructions. + // If any AArch64 variant, enable the ARMv8.5 ISA with SVE extensions so we + // can disassemble newer instructions. if (triple.getArch() == llvm::Triple::aarch64) - features_str += "+v8.2a"; + features_str += "+v8.5a,+sve2"; + + if (triple.getArch() == llvm::Triple::aarch64 + && triple.getVendor() == llvm::Triple::Apple) { + cpu = "apple-latest"; + } - // We use m_disasm_ap.get() to tell whether we are valid or not, so if this + // We use m_disasm_up.get() to tell whether we are valid or not, so if this // isn't good for some reason, we won't be valid and FindPlugin will fail and // we won't get used. m_disasm_up = MCDisasmInstance::Create(triple_str, cpu, features_str.c_str(), @@ -1215,10 +1216,7 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch, if (!m_alternate_disasm_up) m_disasm_up.reset(); - } else if (llvm_arch == llvm::Triple::mips || - llvm_arch == llvm::Triple::mipsel || - llvm_arch == llvm::Triple::mips64 || - llvm_arch == llvm::Triple::mips64el) { + } else if (arch.IsMIPS()) { /* Create alternate disassembler for MIPS16 and microMIPS */ uint32_t arch_flags = arch.GetFlags(); if (arch_flags & ArchSpec::eMIPSAse_mips16) @@ -1238,13 +1236,13 @@ DisassemblerLLVMC::~DisassemblerLLVMC() = default; Disassembler *DisassemblerLLVMC::CreateInstance(const ArchSpec &arch, const char *flavor) { if (arch.GetTriple().getArch() != llvm::Triple::UnknownArch) { - std::unique_ptr<DisassemblerLLVMC> disasm_ap( + std::unique_ptr<DisassemblerLLVMC> disasm_up( new DisassemblerLLVMC(arch, flavor)); - if (disasm_ap.get() && disasm_ap->IsValid()) - return disasm_ap.release(); + if (disasm_up.get() && disasm_up->IsValid()) + return disasm_up.release(); } - return NULL; + return nullptr; } size_t DisassemblerLLVMC::DecodeInstructions(const Address &base_addr, @@ -1331,7 +1329,7 @@ const char *DisassemblerLLVMC::SymbolLookupCallback(void *disassembler, bool DisassemblerLLVMC::FlavorValidForArchSpec( const lldb_private::ArchSpec &arch, const char *flavor) { llvm::Triple triple = arch.GetTriple(); - if (flavor == NULL || strcmp(flavor, "default") == 0) + if (flavor == nullptr || strcmp(flavor, "default") == 0) return true; if (triple.getArch() == llvm::Triple::x86 || @@ -1360,7 +1358,7 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr, if (*type_ptr) { if (m_exe_ctx && m_inst) { // std::string remove_this_prior_to_checkin; - Target *target = m_exe_ctx ? m_exe_ctx->GetTargetPtr() : NULL; + Target *target = m_exe_ctx ? m_exe_ctx->GetTargetPtr() : nullptr; Address value_so_addr; Address pc_so_addr; if (m_inst->UsingFileAddress()) { @@ -1425,13 +1423,11 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr, } *type_ptr = LLVMDisassembler_ReferenceType_InOut_None; - *name = NULL; - return NULL; + *name = nullptr; + return nullptr; } -//------------------------------------------------------------------ // PluginInterface protocol -//------------------------------------------------------------------ ConstString DisassemblerLLVMC::GetPluginName() { return GetPluginNameStatic(); } uint32_t DisassemblerLLVMC::GetPluginVersion() { return 1; } |