mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-03 22:01:56 +00:00
[BPF] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291297 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dae3654635
commit
85430657b9
@ -13,15 +13,13 @@
|
|||||||
|
|
||||||
#include "BPF.h"
|
#include "BPF.h"
|
||||||
#include "BPFInstrInfo.h"
|
#include "BPFInstrInfo.h"
|
||||||
#include "BPFSubtarget.h"
|
|
||||||
#include "BPFTargetMachine.h"
|
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
||||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
|
||||||
#include "llvm/ADT/STLExtras.h"
|
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||||
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
|
#include "llvm/IR/DebugLoc.h"
|
||||||
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#define GET_INSTRINFO_CTOR_DTOR
|
#define GET_INSTRINFO_CTOR_DTOR
|
||||||
#include "BPFGenInstrInfo.inc"
|
#include "BPFGenInstrInfo.inc"
|
||||||
@ -109,11 +107,11 @@ bool BPFInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
|
|||||||
while (std::next(I) != MBB.end())
|
while (std::next(I) != MBB.end())
|
||||||
std::next(I)->eraseFromParent();
|
std::next(I)->eraseFromParent();
|
||||||
Cond.clear();
|
Cond.clear();
|
||||||
FBB = 0;
|
FBB = nullptr;
|
||||||
|
|
||||||
// Delete the J if it's equivalent to a fall-through.
|
// Delete the J if it's equivalent to a fall-through.
|
||||||
if (MBB.isLayoutSuccessor(I->getOperand(0).getMBB())) {
|
if (MBB.isLayoutSuccessor(I->getOperand(0).getMBB())) {
|
||||||
TBB = 0;
|
TBB = nullptr;
|
||||||
I->eraseFromParent();
|
I->eraseFromParent();
|
||||||
I = MBB.end();
|
I = MBB.end();
|
||||||
continue;
|
continue;
|
||||||
|
@ -12,16 +12,15 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "BPF.h"
|
#include "BPF.h"
|
||||||
#include "BPFRegisterInfo.h"
|
|
||||||
#include "BPFSubtarget.h"
|
#include "BPFSubtarget.h"
|
||||||
#include "MCTargetDesc/BPFMCTargetDesc.h"
|
#include "MCTargetDesc/BPFMCTargetDesc.h"
|
||||||
|
#include "llvm/ADT/ArrayRef.h"
|
||||||
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
|
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
|
||||||
#include "llvm/MC/MCFixedLenDisassembler.h"
|
#include "llvm/MC/MCFixedLenDisassembler.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCContext.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -36,14 +35,15 @@ class BPFDisassembler : public MCDisassembler {
|
|||||||
public:
|
public:
|
||||||
BPFDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx)
|
BPFDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx)
|
||||||
: MCDisassembler(STI, Ctx) {}
|
: MCDisassembler(STI, Ctx) {}
|
||||||
virtual ~BPFDisassembler() {}
|
~BPFDisassembler() override = default;
|
||||||
|
|
||||||
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
|
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
|
||||||
ArrayRef<uint8_t> Bytes, uint64_t Address,
|
ArrayRef<uint8_t> Bytes, uint64_t Address,
|
||||||
raw_ostream &VStream,
|
raw_ostream &VStream,
|
||||||
raw_ostream &CStream) const override;
|
raw_ostream &CStream) const override;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
static MCDisassembler *createBPFDisassembler(const Target &T,
|
static MCDisassembler *createBPFDisassembler(const Target &T,
|
||||||
const MCSubtargetInfo &STI,
|
const MCSubtargetInfo &STI,
|
||||||
|
@ -8,28 +8,24 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "MCTargetDesc/BPFMCTargetDesc.h"
|
#include "MCTargetDesc/BPFMCTargetDesc.h"
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/MC/MCAsmBackend.h"
|
#include "llvm/MC/MCAsmBackend.h"
|
||||||
#include "llvm/MC/MCAssembler.h"
|
#include "llvm/MC/MCFixup.h"
|
||||||
#include "llvm/MC/MCDirectives.h"
|
|
||||||
#include "llvm/MC/MCELFObjectWriter.h"
|
|
||||||
#include "llvm/MC/MCFixupKindInfo.h"
|
|
||||||
#include "llvm/MC/MCObjectWriter.h"
|
#include "llvm/MC/MCObjectWriter.h"
|
||||||
#include "llvm/MC/MCSubtargetInfo.h"
|
#include <cassert>
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include <cstdint>
|
||||||
#include "llvm/MC/MCSymbol.h"
|
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
|
||||||
#include "llvm/Support/raw_ostream.h"
|
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class BPFAsmBackend : public MCAsmBackend {
|
class BPFAsmBackend : public MCAsmBackend {
|
||||||
public:
|
public:
|
||||||
bool IsLittleEndian;
|
bool IsLittleEndian;
|
||||||
|
|
||||||
BPFAsmBackend(bool IsLittleEndian)
|
BPFAsmBackend(bool IsLittleEndian)
|
||||||
: MCAsmBackend(), IsLittleEndian(IsLittleEndian) {}
|
: MCAsmBackend(), IsLittleEndian(IsLittleEndian) {}
|
||||||
~BPFAsmBackend() override {}
|
~BPFAsmBackend() override = default;
|
||||||
|
|
||||||
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||||
uint64_t Value, bool IsPCRel) const override;
|
uint64_t Value, bool IsPCRel) const override;
|
||||||
@ -53,6 +49,8 @@ public:
|
|||||||
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
|
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
bool BPFAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
bool BPFAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||||
if ((Count % 8) != 0)
|
if ((Count % 8) != 0)
|
||||||
return false;
|
return false;
|
||||||
@ -66,7 +64,6 @@ bool BPFAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
|||||||
void BPFAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
|
void BPFAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
|
||||||
unsigned DataSize, uint64_t Value,
|
unsigned DataSize, uint64_t Value,
|
||||||
bool IsPCRel) const {
|
bool IsPCRel) const {
|
||||||
|
|
||||||
if (Fixup.getKind() == FK_SecRel_4 || Fixup.getKind() == FK_SecRel_8) {
|
if (Fixup.getKind() == FK_SecRel_4 || Fixup.getKind() == FK_SecRel_8) {
|
||||||
assert(Value == 0);
|
assert(Value == 0);
|
||||||
} else if (Fixup.getKind() == FK_Data_4 || Fixup.getKind() == FK_Data_8) {
|
} else if (Fixup.getKind() == FK_Data_4 || Fixup.getKind() == FK_Data_8) {
|
||||||
@ -92,7 +89,6 @@ void BPFAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
|
|||||||
MCObjectWriter *BPFAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const {
|
MCObjectWriter *BPFAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const {
|
||||||
return createBPFELFObjectWriter(OS, 0, IsLittleEndian);
|
return createBPFELFObjectWriter(OS, 0, IsLittleEndian);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
MCAsmBackend *llvm::createBPFAsmBackend(const Target &T,
|
MCAsmBackend *llvm::createBPFAsmBackend(const Target &T,
|
||||||
const MCRegisterInfo &MRI,
|
const MCRegisterInfo &MRI,
|
||||||
|
@ -10,29 +10,30 @@
|
|||||||
#include "MCTargetDesc/BPFMCTargetDesc.h"
|
#include "MCTargetDesc/BPFMCTargetDesc.h"
|
||||||
#include "llvm/MC/MCELFObjectWriter.h"
|
#include "llvm/MC/MCELFObjectWriter.h"
|
||||||
#include "llvm/MC/MCFixup.h"
|
#include "llvm/MC/MCFixup.h"
|
||||||
|
#include "llvm/Support/ELF.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class BPFELFObjectWriter : public MCELFObjectTargetWriter {
|
class BPFELFObjectWriter : public MCELFObjectTargetWriter {
|
||||||
public:
|
public:
|
||||||
BPFELFObjectWriter(uint8_t OSABI);
|
BPFELFObjectWriter(uint8_t OSABI);
|
||||||
|
~BPFELFObjectWriter() override = default;
|
||||||
~BPFELFObjectWriter() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
|
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
|
||||||
const MCFixup &Fixup, bool IsPCRel) const override;
|
const MCFixup &Fixup, bool IsPCRel) const override;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
BPFELFObjectWriter::BPFELFObjectWriter(uint8_t OSABI)
|
BPFELFObjectWriter::BPFELFObjectWriter(uint8_t OSABI)
|
||||||
: MCELFObjectTargetWriter(/*Is64Bit*/ true, OSABI, ELF::EM_BPF,
|
: MCELFObjectTargetWriter(/*Is64Bit*/ true, OSABI, ELF::EM_BPF,
|
||||||
/*HasRelocationAddend*/ false) {}
|
/*HasRelocationAddend*/ false) {}
|
||||||
|
|
||||||
BPFELFObjectWriter::~BPFELFObjectWriter() {}
|
|
||||||
|
|
||||||
unsigned BPFELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
|
unsigned BPFELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
|
||||||
const MCFixup &Fixup,
|
const MCFixup &Fixup,
|
||||||
bool IsPCRel) const {
|
bool IsPCRel) const {
|
||||||
|
@ -12,24 +12,25 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "MCTargetDesc/BPFMCTargetDesc.h"
|
#include "MCTargetDesc/BPFMCTargetDesc.h"
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/MC/MCCodeEmitter.h"
|
#include "llvm/MC/MCCodeEmitter.h"
|
||||||
#include "llvm/MC/MCFixup.h"
|
#include "llvm/MC/MCFixup.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCInstrInfo.h"
|
#include "llvm/MC/MCInstrInfo.h"
|
||||||
#include "llvm/MC/MCRegisterInfo.h"
|
#include "llvm/MC/MCRegisterInfo.h"
|
||||||
#include "llvm/MC/MCSubtargetInfo.h"
|
#include "llvm/MC/MCSubtargetInfo.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/Support/Endian.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
|
||||||
#include "llvm/Support/EndianStream.h"
|
#include "llvm/Support/EndianStream.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include <cassert>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
#define DEBUG_TYPE "mccodeemitter"
|
#define DEBUG_TYPE "mccodeemitter"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class BPFMCCodeEmitter : public MCCodeEmitter {
|
class BPFMCCodeEmitter : public MCCodeEmitter {
|
||||||
BPFMCCodeEmitter(const BPFMCCodeEmitter &) = delete;
|
|
||||||
void operator=(const BPFMCCodeEmitter &) = delete;
|
|
||||||
const MCInstrInfo &MCII;
|
const MCInstrInfo &MCII;
|
||||||
const MCRegisterInfo &MRI;
|
const MCRegisterInfo &MRI;
|
||||||
bool IsLittleEndian;
|
bool IsLittleEndian;
|
||||||
@ -38,8 +39,9 @@ public:
|
|||||||
BPFMCCodeEmitter(const MCInstrInfo &mcii, const MCRegisterInfo &mri,
|
BPFMCCodeEmitter(const MCInstrInfo &mcii, const MCRegisterInfo &mri,
|
||||||
bool IsLittleEndian)
|
bool IsLittleEndian)
|
||||||
: MCII(mcii), MRI(mri), IsLittleEndian(IsLittleEndian) {}
|
: MCII(mcii), MRI(mri), IsLittleEndian(IsLittleEndian) {}
|
||||||
|
BPFMCCodeEmitter(const BPFMCCodeEmitter &) = delete;
|
||||||
~BPFMCCodeEmitter() {}
|
void operator=(const BPFMCCodeEmitter &) = delete;
|
||||||
|
~BPFMCCodeEmitter() override = default;
|
||||||
|
|
||||||
// getBinaryCodeForInstr - TableGen'erated function for getting the
|
// getBinaryCodeForInstr - TableGen'erated function for getting the
|
||||||
// binary encoding for an instruction.
|
// binary encoding for an instruction.
|
||||||
@ -66,7 +68,8 @@ private:
|
|||||||
void verifyInstructionPredicates(const MCInst &MI,
|
void verifyInstructionPredicates(const MCInst &MI,
|
||||||
uint64_t AvailableFeatures) const;
|
uint64_t AvailableFeatures) const;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
MCCodeEmitter *llvm::createBPFMCCodeEmitter(const MCInstrInfo &MCII,
|
MCCodeEmitter *llvm::createBPFMCCodeEmitter(const MCInstrInfo &MCII,
|
||||||
const MCRegisterInfo &MRI,
|
const MCRegisterInfo &MRI,
|
||||||
|
@ -12,14 +12,13 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "BPF.h"
|
#include "BPF.h"
|
||||||
#include "BPFMCTargetDesc.h"
|
|
||||||
#include "BPFMCAsmInfo.h"
|
|
||||||
#include "InstPrinter/BPFInstPrinter.h"
|
#include "InstPrinter/BPFInstPrinter.h"
|
||||||
|
#include "MCTargetDesc/BPFMCTargetDesc.h"
|
||||||
|
#include "MCTargetDesc/BPFMCAsmInfo.h"
|
||||||
#include "llvm/MC/MCInstrInfo.h"
|
#include "llvm/MC/MCInstrInfo.h"
|
||||||
#include "llvm/MC/MCRegisterInfo.h"
|
#include "llvm/MC/MCRegisterInfo.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
|
||||||
#include "llvm/MC/MCSubtargetInfo.h"
|
#include "llvm/MC/MCSubtargetInfo.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/Host.h"
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
|
|
||||||
#define GET_INSTRINFO_MC_DESC
|
#define GET_INSTRINFO_MC_DESC
|
||||||
@ -64,7 +63,7 @@ static MCInstPrinter *createBPFMCInstPrinter(const Triple &T,
|
|||||||
const MCRegisterInfo &MRI) {
|
const MCRegisterInfo &MRI) {
|
||||||
if (SyntaxVariant == 0)
|
if (SyntaxVariant == 0)
|
||||||
return new BPFInstPrinter(MAI, MII, MRI);
|
return new BPFInstPrinter(MAI, MII, MRI);
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMInitializeBPFTargetMC() {
|
extern "C" void LLVMInitializeBPFTargetMC() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user