mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-28 20:41:07 +00:00
[X86] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 293949
This commit is contained in:
parent
0972183581
commit
fbd13c5c12
@ -1,4 +1,4 @@
|
||||
//===-- X86AsmInstrumentation.cpp - Instrument X86 inline assembly C++ -*-===//
|
||||
//===-- X86AsmInstrumentation.cpp - Instrument X86 inline assembly --------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,24 +7,31 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "MCTargetDesc/X86MCTargetDesc.h"
|
||||
#include "X86AsmInstrumentation.h"
|
||||
#include "MCTargetDesc/X86BaseInfo.h"
|
||||
#include "X86Operand.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCDwarf.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCInstBuilder.h"
|
||||
#include "llvm/MC/MCInstrInfo.h"
|
||||
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
|
||||
#include "llvm/MC/MCParser/MCTargetAsmParser.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/MC/MCTargetOptions.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/SMLoc.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
// Following comment describes how assembly instrumentation works.
|
||||
@ -91,30 +98,35 @@
|
||||
// register as a frame register and temprorary override current CFA
|
||||
// register.
|
||||
|
||||
namespace llvm {
|
||||
namespace {
|
||||
using namespace llvm;
|
||||
|
||||
static cl::opt<bool> ClAsanInstrumentAssembly(
|
||||
"asan-instrument-assembly",
|
||||
cl::desc("instrument assembly with AddressSanitizer checks"), cl::Hidden,
|
||||
cl::init(false));
|
||||
|
||||
const int64_t MinAllowedDisplacement = std::numeric_limits<int32_t>::min();
|
||||
const int64_t MaxAllowedDisplacement = std::numeric_limits<int32_t>::max();
|
||||
static const int64_t MinAllowedDisplacement =
|
||||
std::numeric_limits<int32_t>::min();
|
||||
static const int64_t MaxAllowedDisplacement =
|
||||
std::numeric_limits<int32_t>::max();
|
||||
|
||||
int64_t ApplyDisplacementBounds(int64_t Displacement) {
|
||||
static int64_t ApplyDisplacementBounds(int64_t Displacement) {
|
||||
return std::max(std::min(MaxAllowedDisplacement, Displacement),
|
||||
MinAllowedDisplacement);
|
||||
}
|
||||
|
||||
void CheckDisplacementBounds(int64_t Displacement) {
|
||||
static void CheckDisplacementBounds(int64_t Displacement) {
|
||||
assert(Displacement >= MinAllowedDisplacement &&
|
||||
Displacement <= MaxAllowedDisplacement);
|
||||
}
|
||||
|
||||
bool IsStackReg(unsigned Reg) { return Reg == X86::RSP || Reg == X86::ESP; }
|
||||
static bool IsStackReg(unsigned Reg) {
|
||||
return Reg == X86::RSP || Reg == X86::ESP;
|
||||
}
|
||||
|
||||
bool IsSmallMemAccess(unsigned AccessSize) { return AccessSize < 8; }
|
||||
static bool IsSmallMemAccess(unsigned AccessSize) { return AccessSize < 8; }
|
||||
|
||||
namespace {
|
||||
|
||||
class X86AddressSanitizer : public X86AsmInstrumentation {
|
||||
public:
|
||||
@ -178,7 +190,7 @@ public:
|
||||
X86AddressSanitizer(const MCSubtargetInfo *&STI)
|
||||
: X86AsmInstrumentation(STI), RepPrefix(false), OrigSPOffset(0) {}
|
||||
|
||||
~X86AddressSanitizer() override {}
|
||||
~X86AddressSanitizer() override = default;
|
||||
|
||||
// X86AsmInstrumentation implementation:
|
||||
void InstrumentAndEmitInstruction(const MCInst &Inst,
|
||||
@ -255,9 +267,11 @@ protected:
|
||||
bool is64BitMode() const {
|
||||
return STI->getFeatureBits()[X86::Mode64Bit];
|
||||
}
|
||||
|
||||
bool is32BitMode() const {
|
||||
return STI->getFeatureBits()[X86::Mode32Bit];
|
||||
}
|
||||
|
||||
bool is16BitMode() const {
|
||||
return STI->getFeatureBits()[X86::Mode16Bit];
|
||||
}
|
||||
@ -498,7 +512,7 @@ public:
|
||||
X86AddressSanitizer32(const MCSubtargetInfo *&STI)
|
||||
: X86AddressSanitizer(STI) {}
|
||||
|
||||
~X86AddressSanitizer32() override {}
|
||||
~X86AddressSanitizer32() override = default;
|
||||
|
||||
unsigned GetFrameReg(const MCContext &Ctx, MCStreamer &Out) {
|
||||
unsigned FrameReg = GetFrameRegGeneric(Ctx, Out);
|
||||
@ -604,9 +618,9 @@ private:
|
||||
EmitInstruction(
|
||||
Out, MCInstBuilder(X86::PUSH32r).addReg(RegCtx.AddressReg(32)));
|
||||
|
||||
MCSymbol *FnSym = Ctx.getOrCreateSymbol(llvm::Twine("__asan_report_") +
|
||||
MCSymbol *FnSym = Ctx.getOrCreateSymbol(Twine("__asan_report_") +
|
||||
(IsWrite ? "store" : "load") +
|
||||
llvm::Twine(AccessSize));
|
||||
Twine(AccessSize));
|
||||
const MCSymbolRefExpr *FnExpr =
|
||||
MCSymbolRefExpr::create(FnSym, MCSymbolRefExpr::VK_PLT, Ctx);
|
||||
EmitInstruction(Out, MCInstBuilder(X86::CALLpcrel32).addExpr(FnExpr));
|
||||
@ -756,7 +770,7 @@ public:
|
||||
X86AddressSanitizer64(const MCSubtargetInfo *&STI)
|
||||
: X86AddressSanitizer(STI) {}
|
||||
|
||||
~X86AddressSanitizer64() override {}
|
||||
~X86AddressSanitizer64() override = default;
|
||||
|
||||
unsigned GetFrameReg(const MCContext &Ctx, MCStreamer &Out) {
|
||||
unsigned FrameReg = GetFrameRegGeneric(Ctx, Out);
|
||||
@ -875,15 +889,17 @@ private:
|
||||
EmitInstruction(Out, MCInstBuilder(X86::MOV64rr).addReg(X86::RDI).addReg(
|
||||
RegCtx.AddressReg(64)));
|
||||
}
|
||||
MCSymbol *FnSym = Ctx.getOrCreateSymbol(llvm::Twine("__asan_report_") +
|
||||
MCSymbol *FnSym = Ctx.getOrCreateSymbol(Twine("__asan_report_") +
|
||||
(IsWrite ? "store" : "load") +
|
||||
llvm::Twine(AccessSize));
|
||||
Twine(AccessSize));
|
||||
const MCSymbolRefExpr *FnExpr =
|
||||
MCSymbolRefExpr::create(FnSym, MCSymbolRefExpr::VK_PLT, Ctx);
|
||||
EmitInstruction(Out, MCInstBuilder(X86::CALL64pcrel32).addExpr(FnExpr));
|
||||
}
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
void X86AddressSanitizer64::InstrumentMemOperandSmall(
|
||||
X86Operand &Op, unsigned AccessSize, bool IsWrite,
|
||||
const RegisterContext &RegCtx, MCContext &Ctx, MCStreamer &Out) {
|
||||
@ -1022,12 +1038,10 @@ void X86AddressSanitizer64::InstrumentMOVSImpl(unsigned AccessSize,
|
||||
RestoreFlags(Out);
|
||||
}
|
||||
|
||||
} // End anonymous namespace
|
||||
|
||||
X86AsmInstrumentation::X86AsmInstrumentation(const MCSubtargetInfo *&STI)
|
||||
: STI(STI), InitialFrameReg(0) {}
|
||||
: STI(STI) {}
|
||||
|
||||
X86AsmInstrumentation::~X86AsmInstrumentation() {}
|
||||
X86AsmInstrumentation::~X86AsmInstrumentation() = default;
|
||||
|
||||
void X86AsmInstrumentation::InstrumentAndEmitInstruction(
|
||||
const MCInst &Inst, OperandVector &Operands, MCContext &Ctx,
|
||||
@ -1060,8 +1074,9 @@ unsigned X86AsmInstrumentation::GetFrameRegGeneric(const MCContext &Ctx,
|
||||
}
|
||||
|
||||
X86AsmInstrumentation *
|
||||
CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions,
|
||||
const MCContext &Ctx, const MCSubtargetInfo *&STI) {
|
||||
llvm::CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions,
|
||||
const MCContext &Ctx,
|
||||
const MCSubtargetInfo *&STI) {
|
||||
Triple T(STI->getTargetTriple());
|
||||
const bool hasCompilerRTSupport = T.isOSLinux();
|
||||
if (ClAsanInstrumentAssembly && hasCompilerRTSupport &&
|
||||
@ -1073,5 +1088,3 @@ CreateX86AsmInstrumentation(const MCTargetOptions &MCOptions,
|
||||
}
|
||||
return new X86AsmInstrumentation(STI);
|
||||
}
|
||||
|
||||
} // end llvm namespace
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- X86AsmInstrumentation.h - Instrument X86 inline assembly *- C++ -*-===//
|
||||
//===- X86AsmInstrumentation.h - Instrument X86 inline assembly -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -11,7 +11,6 @@
|
||||
#define LLVM_LIB_TARGET_X86_ASMPARSER_X86ASMINSTRUMENTATION_H
|
||||
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace llvm {
|
||||
@ -23,7 +22,6 @@ class MCParsedAsmOperand;
|
||||
class MCStreamer;
|
||||
class MCSubtargetInfo;
|
||||
class MCTargetOptions;
|
||||
|
||||
class X86AsmInstrumentation;
|
||||
|
||||
X86AsmInstrumentation *
|
||||
@ -43,7 +41,7 @@ public:
|
||||
// Tries to instrument and emit instruction.
|
||||
virtual void InstrumentAndEmitInstruction(
|
||||
const MCInst &Inst,
|
||||
SmallVectorImpl<std::unique_ptr<MCParsedAsmOperand> > &Operands,
|
||||
SmallVectorImpl<std::unique_ptr<MCParsedAsmOperand>> &Operands,
|
||||
MCContext &Ctx, const MCInstrInfo &MII, MCStreamer &Out);
|
||||
|
||||
protected:
|
||||
@ -60,9 +58,9 @@ protected:
|
||||
|
||||
const MCSubtargetInfo *&STI;
|
||||
|
||||
unsigned InitialFrameReg;
|
||||
unsigned InitialFrameReg = 0;
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_LIB_TARGET_X86_ASMPARSER_X86ASMINSTRUMENTATION_H
|
||||
|
@ -13,24 +13,28 @@
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCELFObjectWriter.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCFixup.h"
|
||||
#include "llvm/MC/MCValue.h"
|
||||
#include "llvm/Support/ELF.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class X86ELFObjectWriter : public MCELFObjectTargetWriter {
|
||||
public:
|
||||
X86ELFObjectWriter(bool IsELF64, uint8_t OSABI, uint16_t EMachine);
|
||||
|
||||
~X86ELFObjectWriter() override;
|
||||
class X86ELFObjectWriter : public MCELFObjectTargetWriter {
|
||||
public:
|
||||
X86ELFObjectWriter(bool IsELF64, uint8_t OSABI, uint16_t EMachine);
|
||||
~X86ELFObjectWriter() override = default;
|
||||
|
||||
protected:
|
||||
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
|
||||
const MCFixup &Fixup, bool IsPCRel) const override;
|
||||
};
|
||||
}
|
||||
protected:
|
||||
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
|
||||
const MCFixup &Fixup, bool IsPCRel) const override;
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
X86ELFObjectWriter::X86ELFObjectWriter(bool IsELF64, uint8_t OSABI,
|
||||
uint16_t EMachine)
|
||||
@ -40,9 +44,6 @@ X86ELFObjectWriter::X86ELFObjectWriter(bool IsELF64, uint8_t OSABI,
|
||||
(EMachine != ELF::EM_386) &&
|
||||
(EMachine != ELF::EM_IAMCU)) {}
|
||||
|
||||
X86ELFObjectWriter::~X86ELFObjectWriter()
|
||||
{}
|
||||
|
||||
enum X86_64RelType { RT64_64, RT64_32, RT64_32S, RT64_16, RT64_8 };
|
||||
|
||||
static X86_64RelType getType64(unsigned Kind,
|
||||
|
@ -11,35 +11,43 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "MCTargetDesc/X86MCTargetDesc.h"
|
||||
#include "MCTargetDesc/X86BaseInfo.h"
|
||||
#include "MCTargetDesc/X86FixupKinds.h"
|
||||
#include "MCTargetDesc/X86MCTargetDesc.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/MC/MCCodeEmitter.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCFixup.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCInstrDesc.h"
|
||||
#include "llvm/MC/MCInstrInfo.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "mccodeemitter"
|
||||
|
||||
namespace {
|
||||
|
||||
class X86MCCodeEmitter : public MCCodeEmitter {
|
||||
X86MCCodeEmitter(const X86MCCodeEmitter &) = delete;
|
||||
void operator=(const X86MCCodeEmitter &) = delete;
|
||||
const MCInstrInfo &MCII;
|
||||
MCContext &Ctx;
|
||||
|
||||
public:
|
||||
X86MCCodeEmitter(const MCInstrInfo &mcii, MCContext &ctx)
|
||||
: MCII(mcii), Ctx(ctx) {
|
||||
}
|
||||
|
||||
~X86MCCodeEmitter() override {}
|
||||
X86MCCodeEmitter(const X86MCCodeEmitter &) = delete;
|
||||
X86MCCodeEmitter &operator=(const X86MCCodeEmitter &) = delete;
|
||||
~X86MCCodeEmitter() override = default;
|
||||
|
||||
bool is64BitMode(const MCSubtargetInfo &STI) const {
|
||||
return STI.getFeatureBits()[X86::Mode64Bit];
|
||||
@ -106,8 +114,7 @@ public:
|
||||
SmallVectorImpl<MCFixup> &Fixups,
|
||||
int ImmOffset = 0) const;
|
||||
|
||||
inline static uint8_t ModRMByte(unsigned Mod, unsigned RegOpcode,
|
||||
unsigned RM) {
|
||||
static uint8_t ModRMByte(unsigned Mod, unsigned RegOpcode, unsigned RM) {
|
||||
assert(Mod < 4 && RegOpcode < 8 && RM < 8 && "ModRM Fields out of range!");
|
||||
return RM | (RegOpcode << 3) | (Mod << 6);
|
||||
}
|
||||
@ -149,12 +156,6 @@ public:
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
MCCodeEmitter *llvm::createX86MCCodeEmitter(const MCInstrInfo &MCII,
|
||||
const MCRegisterInfo &MRI,
|
||||
MCContext &Ctx) {
|
||||
return new X86MCCodeEmitter(MCII, Ctx);
|
||||
}
|
||||
|
||||
/// isDisp8 - Return true if this signed displacement fits in a 8-bit
|
||||
/// sign-extended field.
|
||||
static bool isDisp8(int Value) {
|
||||
@ -1436,7 +1437,7 @@ encodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
case X86II::MRM0r: case X86II::MRM1r:
|
||||
case X86II::MRM2r: case X86II::MRM3r:
|
||||
case X86II::MRM4r: case X86II::MRM5r:
|
||||
case X86II::MRM6r: case X86II::MRM7r: {
|
||||
case X86II::MRM6r: case X86II::MRM7r:
|
||||
if (HasVEX_4V) // Skip the register dst (which is encoded in VEX_VVVV).
|
||||
++CurOp;
|
||||
if (HasEVEX_K) // Skip writemask
|
||||
@ -1446,13 +1447,12 @@ encodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
(Form == X86II::MRMXr) ? 0 : Form-X86II::MRM0r,
|
||||
CurByte, OS);
|
||||
break;
|
||||
}
|
||||
|
||||
case X86II::MRMXm:
|
||||
case X86II::MRM0m: case X86II::MRM1m:
|
||||
case X86II::MRM2m: case X86II::MRM3m:
|
||||
case X86II::MRM4m: case X86II::MRM5m:
|
||||
case X86II::MRM6m: case X86II::MRM7m: {
|
||||
case X86II::MRM6m: case X86II::MRM7m:
|
||||
if (HasVEX_4V) // Skip the register dst (which is encoded in VEX_VVVV).
|
||||
++CurOp;
|
||||
if (HasEVEX_K) // Skip writemask
|
||||
@ -1463,7 +1463,7 @@ encodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
Rex, CurByte, OS, Fixups, STI);
|
||||
CurOp += X86::AddrNumOperands;
|
||||
break;
|
||||
}
|
||||
|
||||
case X86II::MRM_C0: case X86II::MRM_C1: case X86II::MRM_C2:
|
||||
case X86II::MRM_C3: case X86II::MRM_C4: case X86II::MRM_C5:
|
||||
case X86II::MRM_C6: case X86II::MRM_C7: case X86II::MRM_C8:
|
||||
@ -1527,3 +1527,9 @@ encodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
MCCodeEmitter *llvm::createX86MCCodeEmitter(const MCInstrInfo &MCII,
|
||||
const MCRegisterInfo &MRI,
|
||||
MCContext &Ctx) {
|
||||
return new X86MCCodeEmitter(MCII, Ctx);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "MCTargetDesc/X86FixupKinds.h"
|
||||
#include "MCTargetDesc/X86MCTargetDesc.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCFixup.h"
|
||||
#include "llvm/MC/MCValue.h"
|
||||
#include "llvm/MC/MCWinCOFFObjectWriter.h"
|
||||
#include "llvm/Support/COFF.h"
|
||||
@ -17,28 +18,24 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace llvm {
|
||||
class MCObjectWriter;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class X86WinCOFFObjectWriter : public MCWinCOFFObjectTargetWriter {
|
||||
public:
|
||||
X86WinCOFFObjectWriter(bool Is64Bit);
|
||||
~X86WinCOFFObjectWriter() override;
|
||||
|
||||
unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup,
|
||||
bool IsCrossSection,
|
||||
const MCAsmBackend &MAB) const override;
|
||||
};
|
||||
}
|
||||
class X86WinCOFFObjectWriter : public MCWinCOFFObjectTargetWriter {
|
||||
public:
|
||||
X86WinCOFFObjectWriter(bool Is64Bit);
|
||||
~X86WinCOFFObjectWriter() override = default;
|
||||
|
||||
unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup,
|
||||
bool IsCrossSection,
|
||||
const MCAsmBackend &MAB) const override;
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
X86WinCOFFObjectWriter::X86WinCOFFObjectWriter(bool Is64Bit)
|
||||
: MCWinCOFFObjectTargetWriter(Is64Bit ? COFF::IMAGE_FILE_MACHINE_AMD64
|
||||
: COFF::IMAGE_FILE_MACHINE_I386) {}
|
||||
|
||||
X86WinCOFFObjectWriter::~X86WinCOFFObjectWriter() {}
|
||||
|
||||
unsigned X86WinCOFFObjectWriter::getRelocType(const MCValue &Target,
|
||||
const MCFixup &Fixup,
|
||||
bool IsCrossSection,
|
||||
|
@ -17,22 +17,35 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "X86.h"
|
||||
#include "MCTargetDesc/X86BaseInfo.h"
|
||||
#include "X86FrameLowering.h"
|
||||
#include "X86InstrInfo.h"
|
||||
#include "X86MachineFunctionInfo.h"
|
||||
#include "X86RegisterInfo.h"
|
||||
#include "X86Subtarget.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/CodeGen/MachineOperand.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/Passes.h"
|
||||
#include "llvm/IR/DebugLoc.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/MC/MCDwarf.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@ -44,6 +57,7 @@ static cl::opt<bool>
|
||||
cl::init(false), cl::Hidden);
|
||||
|
||||
namespace {
|
||||
|
||||
class X86CallFrameOptimization : public MachineFunctionPass {
|
||||
public:
|
||||
X86CallFrameOptimization() : MachineFunctionPass(ID) {}
|
||||
@ -53,30 +67,28 @@ public:
|
||||
private:
|
||||
// Information we know about a particular call site
|
||||
struct CallContext {
|
||||
CallContext()
|
||||
: FrameSetup(nullptr), Call(nullptr), SPCopy(nullptr), ExpectedDist(0),
|
||||
MovVector(4, nullptr), NoStackParams(false), UsePush(false) {}
|
||||
CallContext() : FrameSetup(nullptr), MovVector(4, nullptr) {}
|
||||
|
||||
// Iterator referring to the frame setup instruction
|
||||
MachineBasicBlock::iterator FrameSetup;
|
||||
|
||||
// Actual call instruction
|
||||
MachineInstr *Call;
|
||||
MachineInstr *Call = nullptr;
|
||||
|
||||
// A copy of the stack pointer
|
||||
MachineInstr *SPCopy;
|
||||
MachineInstr *SPCopy = nullptr;
|
||||
|
||||
// The total displacement of all passed parameters
|
||||
int64_t ExpectedDist;
|
||||
int64_t ExpectedDist = 0;
|
||||
|
||||
// The sequence of movs used to pass the parameters
|
||||
SmallVector<MachineInstr *, 4> MovVector;
|
||||
|
||||
// True if this call site has no stack parameters
|
||||
bool NoStackParams;
|
||||
bool NoStackParams = false;
|
||||
|
||||
// True if this call site can use push instructions
|
||||
bool UsePush;
|
||||
bool UsePush = false;
|
||||
};
|
||||
|
||||
typedef SmallVector<CallContext, 8> ContextVector;
|
||||
@ -112,11 +124,8 @@ private:
|
||||
};
|
||||
|
||||
char X86CallFrameOptimization::ID = 0;
|
||||
} // end anonymous namespace
|
||||
|
||||
FunctionPass *llvm::createX86CallFrameOptimization() {
|
||||
return new X86CallFrameOptimization();
|
||||
}
|
||||
} // end anonymous namespace
|
||||
|
||||
// This checks whether the transformation is legal.
|
||||
// Also returns false in cases where it's potentially legal, but
|
||||
@ -485,7 +494,7 @@ void X86CallFrameOptimization::adjustCallSequence(MachineFunction &MF,
|
||||
Push = BuildMI(MBB, Context.Call, DL, TII->get(PushOpcode)).add(PushOp);
|
||||
break;
|
||||
case X86::MOV32mr:
|
||||
case X86::MOV64mr:
|
||||
case X86::MOV64mr: {
|
||||
unsigned int Reg = PushOp.getReg();
|
||||
|
||||
// If storing a 32-bit vreg on 64-bit targets, extend to a 64-bit vreg
|
||||
@ -524,6 +533,7 @@ void X86CallFrameOptimization::adjustCallSequence(MachineFunction &MF,
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// For debugging, when using SP-based CFA, we need to adjust the CFA
|
||||
// offset after each push.
|
||||
@ -583,3 +593,7 @@ MachineInstr *X86CallFrameOptimization::canFoldIntoRegPush(
|
||||
|
||||
return &DefMI;
|
||||
}
|
||||
|
||||
FunctionPass *llvm::createX86CallFrameOptimization() {
|
||||
return new X86CallFrameOptimization();
|
||||
}
|
||||
|
@ -20,13 +20,21 @@
|
||||
//===---------------------------------------------------------------------===//
|
||||
|
||||
#include "InstPrinter/X86InstComments.h"
|
||||
#include "MCTargetDesc/X86BaseInfo.h"
|
||||
#include "X86.h"
|
||||
#include "X86InstrBuilder.h"
|
||||
#include "X86InstrInfo.h"
|
||||
#include "X86InstrTablesInfo.h"
|
||||
#include "X86MachineFunctionInfo.h"
|
||||
#include "X86Subtarget.h"
|
||||
#include "X86TargetMachine.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
#include "llvm/CodeGen/MachineOperand.h"
|
||||
#include "llvm/MC/MCInstrDesc.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@ -56,8 +64,6 @@ class EvexToVexInstPass : public MachineFunctionPass {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
StringRef getPassName() const override { return EVEX2VEX_DESC; }
|
||||
|
||||
EvexToVexInstPass() : MachineFunctionPass(ID) {
|
||||
initializeEvexToVexInstPassPass(*PassRegistry::getPassRegistry());
|
||||
|
||||
@ -72,6 +78,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
StringRef getPassName() const override { return EVEX2VEX_DESC; }
|
||||
|
||||
/// Loop over all of the basic blocks, replacing EVEX instructions
|
||||
/// by equivalent VEX instructions when possible for reducing code size.
|
||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||
@ -88,13 +96,8 @@ private:
|
||||
};
|
||||
|
||||
char EvexToVexInstPass::ID = 0;
|
||||
}
|
||||
|
||||
INITIALIZE_PASS(EvexToVexInstPass, EVEX2VEX_NAME, EVEX2VEX_DESC, false, false)
|
||||
|
||||
FunctionPass *llvm::createX86EvexToVexInsts() {
|
||||
return new EvexToVexInstPass();
|
||||
}
|
||||
} // end anonymous namespace
|
||||
|
||||
bool EvexToVexInstPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
TII = MF.getSubtarget<X86Subtarget>().getInstrInfo();
|
||||
@ -125,7 +128,6 @@ void EvexToVexInstPass::AddTableEntry(EvexToVexTableType &EvexToVexTable,
|
||||
// For EVEX instructions that can be encoded using VEX encoding
|
||||
// replace them by the VEX encoding in order to reduce size.
|
||||
bool EvexToVexInstPass::CompressEvexToVexImpl(MachineInstr &MI) const {
|
||||
|
||||
// VEX format.
|
||||
// # of bytes: 0,2,3 1 1 0,1 0,1,2,4 0,1
|
||||
// [Prefixes] [VEX] OPCODE ModR/M [SIB] [DISP] [IMM]
|
||||
@ -211,3 +213,9 @@ bool EvexToVexInstPass::CompressEvexToVexImpl(MachineInstr &MI) const {
|
||||
MI.setAsmPrinterFlag(AC_EVEX_2_VEX);
|
||||
return true;
|
||||
}
|
||||
|
||||
INITIALIZE_PASS(EvexToVexInstPass, EVEX2VEX_NAME, EVEX2VEX_DESC, false, false)
|
||||
|
||||
FunctionPass *llvm::createX86EvexToVexInsts() {
|
||||
return new EvexToVexInstPass();
|
||||
}
|
||||
|
@ -16,6 +16,9 @@
|
||||
#include "X86InstrInfo.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/Threading.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
/// This flag is used in the method llvm::call_once() used below to make the
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- X86InstrFMA3Info.h - X86 FMA3 Instruction Information -------------===//
|
||||
//===- X86InstrFMA3Info.h - X86 FMA3 Instruction Information ----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -18,9 +18,11 @@
|
||||
#include "X86.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// This class is used to group {132, 213, 231} forms of FMA opcodes together.
|
||||
/// Each of the groups has either 3 register opcodes, 3 memory opcodes,
|
||||
/// or 6 register and memory opcodes. Also, each group has an attrubutes field
|
||||
@ -201,7 +203,7 @@ public:
|
||||
static X86InstrFMA3Info *getX86InstrFMA3Info();
|
||||
|
||||
/// Constructor. Just creates an object of the class.
|
||||
X86InstrFMA3Info() {}
|
||||
X86InstrFMA3Info() = default;
|
||||
|
||||
/// Destructor. Deallocates the memory used for FMA3 Groups.
|
||||
~X86InstrFMA3Info() {
|
||||
@ -310,6 +312,7 @@ public:
|
||||
return rm_iterator(getX86InstrFMA3Info()->OpcodeToGroup.end());
|
||||
}
|
||||
};
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_LIB_TARGET_X86_UTILS_X86INSTRFMA3INFO_H
|
||||
|
@ -11,20 +11,23 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "MCTargetDesc/X86BaseInfo.h"
|
||||
#include "X86Subtarget.h"
|
||||
#include "X86InstrInfo.h"
|
||||
#include "X86TargetMachine.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/IR/Attributes.h"
|
||||
#include "llvm/IR/ConstantRange.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/GlobalValue.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/CodeGen.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/Host.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include <intrin.h>
|
||||
@ -205,7 +208,6 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
|
||||
FullFS = "+sahf";
|
||||
}
|
||||
|
||||
|
||||
// Parse features string and set the CPU.
|
||||
ParseSubtargetFeatures(CPUName, FullFS);
|
||||
|
||||
@ -331,7 +333,7 @@ X86Subtarget::X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
|
||||
TargetTriple.getEnvironment() != Triple::CODE16),
|
||||
In16BitMode(TargetTriple.getArch() == Triple::x86 &&
|
||||
TargetTriple.getEnvironment() == Triple::CODE16),
|
||||
TSInfo(), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
|
||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)),
|
||||
TLInfo(TM, *this), FrameLowering(*this, getStackAlignment()) {
|
||||
// Determine the PICStyle based on the target selected.
|
||||
if (!isPositionIndependent())
|
||||
@ -369,4 +371,3 @@ const RegisterBankInfo *X86Subtarget::getRegBankInfo() const {
|
||||
bool X86Subtarget::enableEarlyIfConversion() const {
|
||||
return hasCMov() && X86EarlyIfConv;
|
||||
}
|
||||
|
||||
|
@ -18,33 +18,36 @@
|
||||
#include "X86ISelLowering.h"
|
||||
#include "X86InstrInfo.h"
|
||||
#include "X86SelectionDAGInfo.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
|
||||
#include "llvm/IR/CallingConv.h"
|
||||
#include "llvm/MC/MCInstrItineraries.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#define GET_SUBTARGETINFO_HEADER
|
||||
#include "X86GenSubtargetInfo.inc"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class GlobalValue;
|
||||
class StringRef;
|
||||
class TargetMachine;
|
||||
|
||||
/// The X86 backend supports a number of different styles of PIC.
|
||||
///
|
||||
namespace PICStyles {
|
||||
|
||||
enum Style {
|
||||
StubPIC, // Used on i386-darwin in pic mode.
|
||||
GOT, // Used on 32 bit elf on when in pic mode.
|
||||
RIPRel, // Used on X86-64 when in pic mode.
|
||||
None // Set when not in pic mode.
|
||||
};
|
||||
}
|
||||
|
||||
} // end namespace PICStyles
|
||||
|
||||
class X86Subtarget final : public X86GenSubtargetInfo {
|
||||
|
||||
protected:
|
||||
enum X86SSEEnum {
|
||||
NoSSE, SSE1, SSE2, SSE3, SSSE3, SSE41, SSE42, AVX, AVX2, AVX512F
|
||||
@ -96,10 +99,13 @@ protected:
|
||||
|
||||
/// Target has XSAVE instructions
|
||||
bool HasXSAVE;
|
||||
|
||||
/// Target has XSAVEOPT instructions
|
||||
bool HasXSAVEOPT;
|
||||
|
||||
/// Target has XSAVEC instructions
|
||||
bool HasXSAVEC;
|
||||
|
||||
/// Target has XSAVES instructions
|
||||
bool HasXSAVES;
|
||||
|
||||
@ -307,8 +313,8 @@ protected:
|
||||
/// This is used to avoid ifndefs spreading around while GISel is
|
||||
/// an optional library.
|
||||
std::unique_ptr<GISelAccessor> GISel;
|
||||
private:
|
||||
|
||||
private:
|
||||
/// Override the stack alignment.
|
||||
unsigned StackAlignOverride;
|
||||
|
||||
@ -341,13 +347,17 @@ public:
|
||||
const X86TargetLowering *getTargetLowering() const override {
|
||||
return &TLInfo;
|
||||
}
|
||||
|
||||
const X86InstrInfo *getInstrInfo() const override { return &InstrInfo; }
|
||||
|
||||
const X86FrameLowering *getFrameLowering() const override {
|
||||
return &FrameLowering;
|
||||
}
|
||||
|
||||
const X86SelectionDAGInfo *getSelectionDAGInfo() const override {
|
||||
return &TSInfo;
|
||||
}
|
||||
|
||||
const X86RegisterInfo *getRegisterInfo() const override {
|
||||
return &getInstrInfo()->getRegisterInfo();
|
||||
}
|
||||
@ -370,12 +380,14 @@ public:
|
||||
const InstructionSelector *getInstructionSelector() const override;
|
||||
const LegalizerInfo *getLegalizerInfo() const override;
|
||||
const RegisterBankInfo *getRegBankInfo() const override;
|
||||
|
||||
private:
|
||||
/// Initialize the full set of dependencies so we can use an initializer
|
||||
/// list for X86Subtarget.
|
||||
X86Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
|
||||
void initializeEnvironment();
|
||||
void initSubtargetFeatures(StringRef CPU, StringRef FS);
|
||||
|
||||
public:
|
||||
/// Is this x86_64? (disregarding specific ABI / programming model)
|
||||
bool is64Bit() const {
|
||||
@ -482,7 +494,7 @@ public:
|
||||
bool hasPKU() const { return HasPKU; }
|
||||
bool hasMPX() const { return HasMPX; }
|
||||
|
||||
virtual bool isXRaySupported() const override { return is64Bit(); }
|
||||
bool isXRaySupported() const override { return is64Bit(); }
|
||||
|
||||
bool isAtom() const { return X86ProcFamily == IntelAtom; }
|
||||
bool isSLM() const { return X86ProcFamily == IntelSLM; }
|
||||
@ -628,6 +640,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_LIB_TARGET_X86_X86SUBTARGET_H
|
||||
|
@ -11,23 +11,39 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "X86TargetMachine.h"
|
||||
#include "MCTargetDesc/X86MCTargetDesc.h"
|
||||
#include "X86.h"
|
||||
#include "X86CallLowering.h"
|
||||
#include "X86MacroFusion.h"
|
||||
#include "X86Subtarget.h"
|
||||
#include "X86TargetMachine.h"
|
||||
#include "X86TargetObjectFile.h"
|
||||
#include "X86TargetTransformInfo.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
|
||||
#include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
|
||||
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
|
||||
#include "llvm/CodeGen/MachineScheduler.h"
|
||||
#include "llvm/CodeGen/Passes.h"
|
||||
#include "llvm/CodeGen/TargetPassConfig.h"
|
||||
#include "llvm/IR/Attributes.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/CodeGen.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static cl::opt<bool> EnableMachineCombinerPass("x86-machine-combiner",
|
||||
@ -35,8 +51,10 @@ static cl::opt<bool> EnableMachineCombinerPass("x86-machine-combiner",
|
||||
cl::init(true), cl::Hidden);
|
||||
|
||||
namespace llvm {
|
||||
|
||||
void initializeWinEHStatePassPass(PassRegistry &);
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
extern "C" void LLVMInitializeX86Target() {
|
||||
// Register the target.
|
||||
@ -53,22 +71,22 @@ extern "C" void LLVMInitializeX86Target() {
|
||||
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
|
||||
if (TT.isOSBinFormatMachO()) {
|
||||
if (TT.getArch() == Triple::x86_64)
|
||||
return make_unique<X86_64MachoTargetObjectFile>();
|
||||
return make_unique<TargetLoweringObjectFileMachO>();
|
||||
return llvm::make_unique<X86_64MachoTargetObjectFile>();
|
||||
return llvm::make_unique<TargetLoweringObjectFileMachO>();
|
||||
}
|
||||
|
||||
if (TT.isOSFreeBSD())
|
||||
return make_unique<X86FreeBSDTargetObjectFile>();
|
||||
return llvm::make_unique<X86FreeBSDTargetObjectFile>();
|
||||
if (TT.isOSLinux() || TT.isOSNaCl())
|
||||
return make_unique<X86LinuxNaClTargetObjectFile>();
|
||||
return llvm::make_unique<X86LinuxNaClTargetObjectFile>();
|
||||
if (TT.isOSFuchsia())
|
||||
return make_unique<X86FuchsiaTargetObjectFile>();
|
||||
return llvm::make_unique<X86FuchsiaTargetObjectFile>();
|
||||
if (TT.isOSBinFormatELF())
|
||||
return make_unique<X86ELFTargetObjectFile>();
|
||||
return llvm::make_unique<X86ELFTargetObjectFile>();
|
||||
if (TT.isKnownWindowsMSVCEnvironment() || TT.isWindowsCoreCLREnvironment())
|
||||
return make_unique<X86WindowsTargetObjectFile>();
|
||||
return llvm::make_unique<X86WindowsTargetObjectFile>();
|
||||
if (TT.isOSBinFormatCOFF())
|
||||
return make_unique<TargetLoweringObjectFileCOFF>();
|
||||
return llvm::make_unique<TargetLoweringObjectFileCOFF>();
|
||||
llvm_unreachable("unknown subtarget type");
|
||||
}
|
||||
|
||||
@ -178,31 +196,39 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT,
|
||||
initAsmInfo();
|
||||
}
|
||||
|
||||
X86TargetMachine::~X86TargetMachine() {}
|
||||
X86TargetMachine::~X86TargetMachine() = default;
|
||||
|
||||
#ifdef LLVM_BUILD_GLOBAL_ISEL
|
||||
namespace {
|
||||
|
||||
struct X86GISelActualAccessor : public GISelAccessor {
|
||||
std::unique_ptr<CallLowering> CL;
|
||||
|
||||
X86GISelActualAccessor(CallLowering* CL): CL(CL) {}
|
||||
|
||||
const CallLowering *getCallLowering() const override {
|
||||
return CL.get();
|
||||
}
|
||||
|
||||
const InstructionSelector *getInstructionSelector() const override {
|
||||
//TODO: Implement
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const LegalizerInfo *getLegalizerInfo() const override {
|
||||
//TODO: Implement
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const RegisterBankInfo *getRegBankInfo() const override {
|
||||
//TODO: Implement
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
} // End anonymous namespace.
|
||||
|
||||
} // end anonymous namespace
|
||||
#endif
|
||||
|
||||
const X86Subtarget *
|
||||
X86TargetMachine::getSubtargetImpl(const Function &F) const {
|
||||
Attribute CPUAttr = F.getFnAttribute("target-cpu");
|
||||
@ -271,12 +297,12 @@ TargetIRAnalysis X86TargetMachine::getTargetIRAnalysis() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Pass Pipeline Configuration
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
/// X86 Code Generator Pass Configuration Options.
|
||||
class X86PassConfig : public TargetPassConfig {
|
||||
public:
|
||||
@ -302,14 +328,15 @@ public:
|
||||
bool addRegBankSelect() override;
|
||||
bool addGlobalInstructionSelect() override;
|
||||
#endif
|
||||
bool addILPOpts() override;
|
||||
bool addILPOpts() override;
|
||||
bool addPreISel() override;
|
||||
void addPreRegAlloc() override;
|
||||
void addPostRegAlloc() override;
|
||||
void addPreEmitPass() override;
|
||||
void addPreSched2() override;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
TargetPassConfig *X86TargetMachine::createPassConfig(PassManagerBase &PM) {
|
||||
return new X86PassConfig(this, PM);
|
||||
|
@ -13,10 +13,14 @@
|
||||
|
||||
#ifndef LLVM_LIB_TARGET_X86_X86TARGETMACHINE_H
|
||||
#define LLVM_LIB_TARGET_X86_X86TARGETMACHINE_H
|
||||
#include "X86InstrInfo.h"
|
||||
|
||||
#include "X86Subtarget.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include "llvm/Support/CodeGen.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include <memory>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -32,17 +36,19 @@ public:
|
||||
Optional<Reloc::Model> RM, CodeModel::Model CM,
|
||||
CodeGenOpt::Level OL);
|
||||
~X86TargetMachine() override;
|
||||
|
||||
const X86Subtarget *getSubtargetImpl(const Function &F) const override;
|
||||
|
||||
TargetIRAnalysis getTargetIRAnalysis() override;
|
||||
|
||||
// Set up the pass pipeline.
|
||||
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
|
||||
|
||||
TargetLoweringObjectFile *getObjFileLowering() const override {
|
||||
return TLOF.get();
|
||||
}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_LIB_TARGET_X86_X86TARGETMACHINE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user