LLVM  12.0.0git
Namespaces | Macros | Enumerations | Functions
X86AsmBackend.cpp File Reference
#include "MCTargetDesc/X86BaseInfo.h"
#include "MCTargetDesc/X86FixupKinds.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCELFObjectWriter.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
#include "llvm/BinaryFormat/ELFRelocs/i386.def"
Include dependency graph for X86AsmBackend.cpp:

Go to the source code of this file.

Namespaces

 CU
 

Macros

#define ELF_RELOC(X, Y)   .Case(#X, Y)
 
#define ELF_RELOC(X, Y)   .Case(#X, Y)
 

Enumerations

enum  CompactUnwindEncodings
 Compact unwind encoding values. More...
 

Functions

static unsigned getRelaxedOpcodeBranch (const MCInst &Inst, bool Is16BitMode)
 
static unsigned getRelaxedOpcodeArith (const MCInst &Inst)
 
static unsigned getRelaxedOpcode (const MCInst &Inst, bool Is16BitMode)
 
static X86::CondCode getCondFromBranch (const MCInst &MI, const MCInstrInfo &MCII)
 
static X86::SecondMacroFusionInstKind classifySecondInstInMacroFusion (const MCInst &MI, const MCInstrInfo &MCII)
 
static bool isRIPRelative (const MCInst &MI, const MCInstrInfo &MCII)
 Check if the instruction uses RIP relative addressing. More...
 
static bool isPrefix (const MCInst &MI, const MCInstrInfo &MCII)
 Check if the instruction is a prefix. More...
 
static bool isFirstMacroFusibleInst (const MCInst &Inst, const MCInstrInfo &MCII)
 Check if the instruction is valid as the first instruction in macro fusion. More...
 
static bool hasVariantSymbol (const MCInst &MI)
 Check if the instruction has a variant symbol operand. More...
 
static bool hasInterruptDelaySlot (const MCInst &Inst)
 X86 has certain instructions which enable interrupts exactly one instruction after the instruction which stores to SS. More...
 
static bool isRightAfterData (MCFragment *CurrentFragment, const std::pair< MCFragment *, size_t > &PrevInstPosition)
 Check if the instruction to be emitted is right after any data. More...
 
static size_t getSizeForInstFragment (const MCFragment *F)
 
static unsigned getFixupKindSize (unsigned Kind)
 
static bool isFullyRelaxed (const MCRelaxableFragment &RF)
 Return true if this instruction has been fully relaxed into it's most general available form. More...
 

Macro Definition Documentation

◆ ELF_RELOC [1/2]

#define ELF_RELOC (   X,
  Y 
)    .Case(#X, Y)

Referenced by getSizeForInstFragment().

◆ ELF_RELOC [2/2]

#define ELF_RELOC (   X,
  Y 
)    .Case(#X, Y)

Enumeration Type Documentation

◆ CompactUnwindEncodings

Compact unwind encoding values.

Definition at line 1220 of file X86AsmBackend.cpp.

Function Documentation

◆ classifySecondInstInMacroFusion()

static X86::SecondMacroFusionInstKind classifySecondInstInMacroFusion ( const MCInst MI,
const MCInstrInfo MCII 
)
static

◆ getCondFromBranch()

static X86::CondCode getCondFromBranch ( const MCInst MI,
const MCInstrInfo MCII 
)
static

◆ getFixupKindSize()

static unsigned getFixupKindSize ( unsigned  Kind)
static

◆ getRelaxedOpcode()

static unsigned getRelaxedOpcode ( const MCInst Inst,
bool  Is16BitMode 
)
static

◆ getRelaxedOpcodeArith()

static unsigned getRelaxedOpcodeArith ( const MCInst Inst)
static

Definition at line 228 of file X86AsmBackend.cpp.

References llvm::MCInst::getOpcode().

Referenced by getFixupKindSize(), and getRelaxedOpcode().

◆ getRelaxedOpcodeBranch()

static unsigned getRelaxedOpcodeBranch ( const MCInst Inst,
bool  Is16BitMode 
)
static

Definition at line 216 of file X86AsmBackend.cpp.

References llvm::MCInst::getOpcode().

Referenced by getFixupKindSize(), and getRelaxedOpcode().

◆ getSizeForInstFragment()

static size_t getSizeForInstFragment ( const MCFragment F)
static
Returns
the fragment size if it has instructions, otherwise returns 0.

Definition at line 519 of file X86AsmBackend.cpp.

References llvm::X86::AlignBranchCall, llvm::X86::AlignBranchFused, llvm::X86::AlignBranchIndirect, llvm::X86::AlignBranchJcc, llvm::X86::AlignBranchJmp, llvm::X86::AlignBranchRet, assert(), ELF_RELOC, F(), llvm::FirstLiteralRelocationKind, llvm::FirstTargetFixupKind, Fixup, llvm::FK_NONE, llvm::MCFixupKindInfo::FKF_IsPCRel, llvm::MCFragment::FT_CompactEncodedInst, llvm::MCFragment::FT_Data, llvm::MCFragment::FT_Relaxable, llvm::MCSection::getAlignment(), llvm::MCStreamer::getAllowAutoPadding(), llvm::Triple::getArch(), llvm::MCObjectStreamer::getAssembler(), llvm::MCObjectStreamer::getCurrentFragment(), llvm::MCStreamer::getCurrentSectionOnly(), llvm::MCAsmBackend::getFixupKind(), llvm::MCAsmBackend::getFixupKindInfo(), llvm::MCFragment::getKind(), llvm::MCSection::getKind(), llvm::MCFixup::getKind(), llvm::MCInst::getOpcode(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode(), llvm::MCSubtargetInfo::getTargetTriple(), llvm::MCSubtargetInfo::hasFeature(), llvm::MCFragment::hasInstructions(), hasInterruptDelaySlot(), hasVariantSymbol(), llvm::MCObjectStreamer::insert(), llvm::MCAssembler::isBundlingEnabled(), llvm::MCInstrDesc::isCall(), llvm::MCInstrDesc::isConditionalBranch(), isFirstMacroFusibleInst(), llvm::MCInstrDesc::isIndirectBranch(), llvm::X86::isMacroFused(), llvm::Triple::isOSBinFormatELF(), isPrefix(), llvm::MCInstrDesc::isReturn(), isRightAfterData(), llvm::SectionKind::isText(), llvm::MCInstrDesc::isUnconditionalBranch(), llvm_unreachable, llvm::None, llvm::X86::NumTargetFixupKinds, llvm::MCSection::setAlignment(), llvm::MCBoundaryAlignFragment::setLastFragment(), llvm::Align::value(), X, llvm::Triple::x86_64, and Y.

◆ hasInterruptDelaySlot()

static bool hasInterruptDelaySlot ( const MCInst Inst)
static

X86 has certain instructions which enable interrupts exactly one instruction after the instruction which stores to SS.

Return true if the given instruction has such an interrupt delay slot.

Definition at line 471 of file X86AsmBackend.cpp.

References llvm::MCInst::getOpcode(), llvm::MCInst::getOperand(), llvm::MCOperand::getReg(), and llvm::X86AS::SS.

Referenced by getSizeForInstFragment().

◆ hasVariantSymbol()

static bool hasVariantSymbol ( const MCInst MI)
static

Check if the instruction has a variant symbol operand.

Definition at line 448 of file X86AsmBackend.cpp.

References llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, llvm::X86::AlignBranchNone, llvm::MCExpr::getKind(), llvm::MCExpr::SymbolRef, and llvm::MCSymbolRefExpr::VK_None.

Referenced by getSizeForInstFragment().

◆ isFirstMacroFusibleInst()

static bool isFirstMacroFusibleInst ( const MCInst Inst,
const MCInstrInfo MCII 
)
static

◆ isFullyRelaxed()

static bool isFullyRelaxed ( const MCRelaxableFragment RF)
static

Return true if this instruction has been fully relaxed into it's most general available form.

Definition at line 849 of file X86AsmBackend.cpp.

References assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::StringSwitch< T, R >::Case(), llvm::SmallVectorImpl< T >::clear(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::count(), llvm::createX86ELFObjectWriter(), llvm::createX86WinCOFFObjectWriter(), llvm::StringSwitch< T, R >::Default(), llvm::ELF::EM_386, llvm::ELF::EM_IAMCU, llvm::ELF::EM_X86_64, llvm::MCCodeEmitter::emitPrefix(), llvm::SmallVectorBase< SmallVectorSizeType< T > >::empty(), llvm::MCCodeEmitter::encodeInstruction(), llvm::SmallVectorTemplateCommon< T, typename >::end(), F(), llvm::FK_Data_4, llvm::FK_SecRel_2, llvm::FK_SecRel_4, llvm::MCFragment::FT_Align, llvm::MCFragment::FT_BoundaryAlign, llvm::MCFragment::FT_CompactEncodedInst, llvm::MCFragment::FT_Data, llvm::MCFragment::FT_Relaxable, llvm::MCRelaxableFragment::getAllowAutoPadding(), llvm::MCEncodedFragmentWithContents< ContentsSize >::getContents(), llvm::MCSubtargetInfo::getFeatureBits(), llvm::MCAsmBackend::getFixupKind(), llvm::MCEncodedFragmentWithFixups< ContentsSize, FixupsSize >::getFixups(), llvm::MCSection::getFragmentList(), llvm::MCAsmLayout::getFragmentOffset(), llvm::MCRelaxableFragment::getInst(), llvm::MCFragment::getKind(), llvm::MCInst::getOpcode(), getRelaxedOpcode(), llvm::MCAsmLayout::getSectionOrder(), llvm::MCEncodedFragment::getSubtargetInfo(), llvm::MCSubtargetInfo::hasFeature(), I, llvm::ARM_PROC::IE, llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), llvm::MCAsmLayout::invalidateFragmentsFrom(), is64Bit(), llvm::min(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::cl::Prefix, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::ARMBuildAttrs::Section, llvm::MCRelaxableFragment::setInst(), llvm::SmallVectorBase< SmallVectorSizeType< T > >::size(), llvm::SmallVectorBase< Size_T >::size(), llvm::MCAssembler::symbols(), and llvm::raw_ostream::write().

◆ isPrefix()

static bool isPrefix ( const MCInst MI,
const MCInstrInfo MCII 
)
static

Check if the instruction is a prefix.

Definition at line 355 of file X86AsmBackend.cpp.

References llvm::MCInstrInfo::get(), llvm::MCInst::getOpcode(), and llvm::X86II::isPrefix().

Referenced by getSizeForInstFragment().

◆ isRightAfterData()

static bool isRightAfterData ( MCFragment CurrentFragment,
const std::pair< MCFragment *, size_t > &  PrevInstPosition 
)
static

Check if the instruction to be emitted is right after any data.

Definition at line 491 of file X86AsmBackend.cpp.

References DF, F(), and llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode().

Referenced by getSizeForInstFragment().

◆ isRIPRelative()

static bool isRIPRelative ( const MCInst MI,
const MCInstrInfo MCII 
)
static