aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/MCDisassembler
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:12 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:12 +0000
commite6d1592492a3a379186bfb02bd0f4eda0669c0d5 (patch)
tree599ab169a01f1c86eda9adc774edaedde2f2db5b /lib/MC/MCDisassembler
parent1a56a5ead7a2e84bee8240f5f6b033b5f1707154 (diff)
Diffstat (limited to 'lib/MC/MCDisassembler')
-rw-r--r--lib/MC/MCDisassembler/Disassembler.cpp35
-rw-r--r--lib/MC/MCDisassembler/Disassembler.h41
-rw-r--r--lib/MC/MCDisassembler/MCDisassembler.cpp16
-rw-r--r--lib/MC/MCDisassembler/MCExternalSymbolizer.cpp7
-rw-r--r--lib/MC/MCDisassembler/MCRelocationInfo.cpp7
-rw-r--r--lib/MC/MCDisassembler/MCSymbolizer.cpp7
6 files changed, 58 insertions, 55 deletions
diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp
index ad0a39991c53..21bdc2eaea3e 100644
--- a/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/lib/MC/MCDisassembler/Disassembler.cpp
@@ -1,9 +1,8 @@
//===-- lib/MC/Disassembler.cpp - Disassembler Public C Interface ---------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
@@ -53,31 +52,32 @@ LLVMCreateDisasmCPUFeatures(const char *TT, const char *CPU,
if (!TheTarget)
return nullptr;
- const MCRegisterInfo *MRI = TheTarget->createMCRegInfo(TT);
+ std::unique_ptr<const MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TT));
if (!MRI)
return nullptr;
// Get the assembler info needed to setup the MCContext.
- const MCAsmInfo *MAI = TheTarget->createMCAsmInfo(*MRI, TT);
+ std::unique_ptr<const MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, TT));
if (!MAI)
return nullptr;
- const MCInstrInfo *MII = TheTarget->createMCInstrInfo();
+ std::unique_ptr<const MCInstrInfo> MII(TheTarget->createMCInstrInfo());
if (!MII)
return nullptr;
- const MCSubtargetInfo *STI =
- TheTarget->createMCSubtargetInfo(TT, CPU, Features);
+ std::unique_ptr<const MCSubtargetInfo> STI(
+ TheTarget->createMCSubtargetInfo(TT, CPU, Features));
if (!STI)
return nullptr;
// Set up the MCContext for creating symbols and MCExpr's.
- MCContext *Ctx = new MCContext(MAI, MRI, nullptr);
+ std::unique_ptr<MCContext> Ctx(new MCContext(MAI.get(), MRI.get(), nullptr));
if (!Ctx)
return nullptr;
// Set up disassembler.
- MCDisassembler *DisAsm = TheTarget->createMCDisassembler(*STI, *Ctx);
+ std::unique_ptr<MCDisassembler> DisAsm(
+ TheTarget->createMCDisassembler(*STI, *Ctx));
if (!DisAsm)
return nullptr;
@@ -87,19 +87,20 @@ LLVMCreateDisasmCPUFeatures(const char *TT, const char *CPU,
return nullptr;
std::unique_ptr<MCSymbolizer> Symbolizer(TheTarget->createMCSymbolizer(
- TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx, std::move(RelInfo)));
+ TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx.get(), std::move(RelInfo)));
DisAsm->setSymbolizer(std::move(Symbolizer));
// Set up the instruction printer.
int AsmPrinterVariant = MAI->getAssemblerDialect();
- MCInstPrinter *IP = TheTarget->createMCInstPrinter(
- Triple(TT), AsmPrinterVariant, *MAI, *MII, *MRI);
+ std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
+ Triple(TT), AsmPrinterVariant, *MAI, *MII, *MRI));
if (!IP)
return nullptr;
- LLVMDisasmContext *DC =
- new LLVMDisasmContext(TT, DisInfo, TagType, GetOpInfo, SymbolLookUp,
- TheTarget, MAI, MRI, STI, MII, Ctx, DisAsm, IP);
+ LLVMDisasmContext *DC = new LLVMDisasmContext(
+ TT, DisInfo, TagType, GetOpInfo, SymbolLookUp, TheTarget, std::move(MAI),
+ std::move(MRI), std::move(STI), std::move(MII), std::move(Ctx),
+ std::move(DisAsm), std::move(IP));
if (!DC)
return nullptr;
diff --git a/lib/MC/MCDisassembler/Disassembler.h b/lib/MC/MCDisassembler/Disassembler.h
index f638fdc781d7..e5aab53a7613 100644
--- a/lib/MC/MCDisassembler/Disassembler.h
+++ b/lib/MC/MCDisassembler/Disassembler.h
@@ -1,9 +1,8 @@
//===------------- Disassembler.h - LLVM Disassembler -----------*- 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
//
//===----------------------------------------------------------------------===//
//
@@ -83,24 +82,22 @@ public:
SmallString<128> CommentsToEmit;
raw_svector_ostream CommentStream;
- LLVMDisasmContext(std::string tripleName, void *disInfo, int tagType,
- LLVMOpInfoCallback getOpInfo,
- LLVMSymbolLookupCallback symbolLookUp,
- const Target *theTarget, const MCAsmInfo *mAI,
- const MCRegisterInfo *mRI, const MCSubtargetInfo *mSI,
- const MCInstrInfo *mII, llvm::MCContext *ctx,
- const MCDisassembler *disAsm, MCInstPrinter *iP)
- : TripleName(std::move(tripleName)), DisInfo(disInfo), TagType(tagType),
- GetOpInfo(getOpInfo), SymbolLookUp(symbolLookUp), TheTarget(theTarget),
- Options(0), CommentStream(CommentsToEmit) {
- MAI.reset(mAI);
- MRI.reset(mRI);
- MSI.reset(mSI);
- MII.reset(mII);
- Ctx.reset(ctx);
- DisAsm.reset(disAsm);
- IP.reset(iP);
- }
+ LLVMDisasmContext(std::string TripleName, void *DisInfo, int TagType,
+ LLVMOpInfoCallback GetOpInfo,
+ LLVMSymbolLookupCallback SymbolLookUp,
+ const Target *TheTarget,
+ std::unique_ptr<const MCAsmInfo> &&MAI,
+ std::unique_ptr<const MCRegisterInfo> &&MRI,
+ std::unique_ptr<const MCSubtargetInfo> &&MSI,
+ std::unique_ptr<const MCInstrInfo> &&MII,
+ std::unique_ptr<const llvm::MCContext> &&Ctx,
+ std::unique_ptr<const MCDisassembler> &&DisAsm,
+ std::unique_ptr<MCInstPrinter> &&IP)
+ : TripleName(std::move(TripleName)), DisInfo(DisInfo), TagType(TagType),
+ GetOpInfo(GetOpInfo), SymbolLookUp(SymbolLookUp), TheTarget(TheTarget),
+ MAI(std::move(MAI)), MRI(std::move(MRI)), MSI(std::move(MSI)),
+ MII(std::move(MII)), Ctx(std::move(Ctx)), DisAsm(std::move(DisAsm)),
+ IP(std::move(IP)), Options(0), CommentStream(CommentsToEmit) {}
const std::string &getTripleName() const { return TripleName; }
void *getDisInfo() const { return DisInfo; }
int getTagType() const { return TagType; }
diff --git a/lib/MC/MCDisassembler/MCDisassembler.cpp b/lib/MC/MCDisassembler/MCDisassembler.cpp
index 2f1275d00b86..063f7e706024 100644
--- a/lib/MC/MCDisassembler/MCDisassembler.cpp
+++ b/lib/MC/MCDisassembler/MCDisassembler.cpp
@@ -1,13 +1,14 @@
//===- MCDisassembler.cpp - Disassembler interface ------------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -15,6 +16,13 @@ using namespace llvm;
MCDisassembler::~MCDisassembler() = default;
+MCDisassembler::DecodeStatus MCDisassembler::onSymbolStart(
+ StringRef Name, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address,
+ raw_ostream &VStream, raw_ostream &CStream) const {
+ Size = 0;
+ return MCDisassembler::Success;
+}
+
bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
uint64_t Address, bool IsBranch,
uint64_t Offset,
diff --git a/lib/MC/MCDisassembler/MCExternalSymbolizer.cpp b/lib/MC/MCDisassembler/MCExternalSymbolizer.cpp
index 1969c5dc66ab..7befef86303c 100644
--- a/lib/MC/MCDisassembler/MCExternalSymbolizer.cpp
+++ b/lib/MC/MCDisassembler/MCExternalSymbolizer.cpp
@@ -1,9 +1,8 @@
//===-- MCExternalSymbolizer.cpp - External symbolizer --------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
diff --git a/lib/MC/MCDisassembler/MCRelocationInfo.cpp b/lib/MC/MCDisassembler/MCRelocationInfo.cpp
index 8f932a3f0d48..64e216e0051d 100644
--- a/lib/MC/MCDisassembler/MCRelocationInfo.cpp
+++ b/lib/MC/MCDisassembler/MCRelocationInfo.cpp
@@ -1,9 +1,8 @@
//===-- MCRelocationInfo.cpp ----------------------------------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//
diff --git a/lib/MC/MCDisassembler/MCSymbolizer.cpp b/lib/MC/MCDisassembler/MCSymbolizer.cpp
index 78e611e3ddda..8214a196afb1 100644
--- a/lib/MC/MCDisassembler/MCSymbolizer.cpp
+++ b/lib/MC/MCDisassembler/MCSymbolizer.cpp
@@ -1,9 +1,8 @@
//===-- llvm/MC/MCSymbolizer.cpp - MCSymbolizer class ---------------------===//
//
-// 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
//
//===----------------------------------------------------------------------===//