LLVM  8.0.1
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
llvm::MCCodePaddingPolicy Class Referenceabstract

The base class for all padding policies, i.e. More...

#include "llvm/MC/MCCodePadder.h"

Collaboration diagram for llvm::MCCodePaddingPolicy:
Collaboration graph
[legend]

Public Member Functions

virtual ~MCCodePaddingPolicy ()
 
uint64_t getKindMask () const
 Returns the kind mask of this policy - A mask holding the kind of this policy, i.e. More...
 
uint64_t getWindowSize () const
 Returns the instruction window size relevant to this policy. More...
 
bool isInstByteLastByte () const
 Returns true if the last byte of an instruction determines its instruction window, or false if the first of an instruction determines it. More...
 
virtual bool basicBlockRequiresPaddingFragment (const MCCodePaddingContext &Context) const
 Returns true iff this policy needs padding for a given basic block. More...
 
virtual bool instructionRequiresPaddingFragment (const MCInst &Inst) const
 Returns true iff this policy needs padding for a given instruction. More...
 
double computeRangePenaltyWeight (const MCPFRange &Range, uint64_t Offset, MCAsmLayout &Layout) const
 Computes and returns the penalty caused by a range of instruction windows. More...
 

Protected Member Functions

 MCCodePaddingPolicy (uint64_t Kind, uint64_t WindowSize, bool InstByteIsLastByte)
 
uint64_t getFragmentInstByte (const MCPaddingFragment *Fragment, MCAsmLayout &Layout) const
 Returns the instruction byte of an instruction pointed by a given MCPaddingFragment. More...
 
uint64_t computeWindowEndAddress (const MCPaddingFragment *Fragment, uint64_t Offset, MCAsmLayout &Layout) const
 
double computeFirstWindowPenaltyWeight (const MCPFRange &Window, uint64_t Offset, MCAsmLayout &Layout) const
 Computes and returns the penalty weight of a first instruction window in a range. More...
 
virtual double computeWindowPenaltyWeight (const MCPFRange &Window, uint64_t Offset, MCAsmLayout &Layout) const =0
 Computes and returns the penalty caused by an instruction window. More...
 

Static Protected Member Functions

static uint64_t getNextFragmentOffset (const MCFragment *Fragment, const MCAsmLayout &Layout)
 Computes and returns the offset of the consecutive fragment of a given fragment. More...
 

Protected Attributes

const uint64_t KindMask
 A mask holding the kind of this policy, i.e. More...
 
const uint64_t WindowSize
 Instruction window size relevant to this policy. More...
 
const bool InstByteIsLastByte
 A boolean indicating which byte of the instruction determies its instruction window. More...
 

Detailed Description

The base class for all padding policies, i.e.

a rule or set of rules to pad the generated code.

Definition at line 127 of file MCCodePadder.h.

Constructor & Destructor Documentation

◆ MCCodePaddingPolicy()

llvm::MCCodePaddingPolicy::MCCodePaddingPolicy ( uint64_t  Kind,
uint64_t  WindowSize,
bool  InstByteIsLastByte 
)
inlineprotected

Definition at line 143 of file MCCodePadder.h.

◆ ~MCCodePaddingPolicy()

virtual llvm::MCCodePaddingPolicy::~MCCodePaddingPolicy ( )
inlinevirtual

Definition at line 198 of file MCCodePadder.h.

Member Function Documentation

◆ basicBlockRequiresPaddingFragment()

virtual bool llvm::MCCodePaddingPolicy::basicBlockRequiresPaddingFragment ( const MCCodePaddingContext Context) const
inlinevirtual

Returns true iff this policy needs padding for a given basic block.

Parameters
Contextthe context of the padding, Embeds the basic block's parameters.
Returns
true iff this policy needs padding for the basic block.

Definition at line 216 of file MCCodePadder.h.

◆ computeFirstWindowPenaltyWeight()

double MCCodePaddingPolicy::computeFirstWindowPenaltyWeight ( const MCPFRange Window,
uint64_t  Offset,
MCAsmLayout Layout 
) const
protected

Computes and returns the penalty weight of a first instruction window in a range.

This requires a special function since the first window does not contain all the padding fragments in that window. It only contains all the padding fragments starting from the relevant insertion point.

Parameters
WindowThe first window.
OffsetThe offset of the parent section relative to the beginning of the file, mod the window size.
LayoutCode layout information.
Returns
the penalty weight of a first instruction window in a range, Window.

Definition at line 330 of file MCCodePadder.cpp.

References llvm::SmallVectorImpl< T >::append(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode(), llvm::MCPaddingFragment::hasPaddingPolicy(), and llvm::reverse().

◆ computeRangePenaltyWeight()

double MCCodePaddingPolicy::computeRangePenaltyWeight ( const MCPFRange Range,
uint64_t  Offset,
MCAsmLayout Layout 
) const

Computes and returns the penalty caused by a range of instruction windows.

The weight is computed for each window separelty and then accumulated.

Parameters
RangeThe range.
OffsetThe offset of the parent section relative to the beginning of the file, mod the window size.
LayoutCode layout information.
Returns
the penalty caused by Range.

Definition at line 294 of file MCCodePadder.cpp.

References llvm::SmallVectorTemplateCommon< T >::begin(), llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::MCPaddingFragment::hasPaddingPolicy(), I, and llvm::SmallVectorTemplateBase< T >::push_back().

◆ computeWindowEndAddress()

uint64_t MCCodePaddingPolicy::computeWindowEndAddress ( const MCPaddingFragment Fragment,
uint64_t  Offset,
MCAsmLayout Layout 
) const
protected

Definition at line 287 of file MCCodePadder.cpp.

References llvm::alignTo().

◆ computeWindowPenaltyWeight()

virtual double llvm::MCCodePaddingPolicy::computeWindowPenaltyWeight ( const MCPFRange Window,
uint64_t  Offset,
MCAsmLayout Layout 
) const
protectedpure virtual

Computes and returns the penalty caused by an instruction window.

Parameters
WindowThe instruction window.
OffsetThe offset of the parent section relative to the beginning of the file, mod the window size.
LayoutCode layout information.
Returns
the penalty caused by Window.

◆ getFragmentInstByte()

uint64_t MCCodePaddingPolicy::getFragmentInstByte ( const MCPaddingFragment Fragment,
MCAsmLayout Layout 
) const
protected

Returns the instruction byte of an instruction pointed by a given MCPaddingFragment.

An instruction byte is the address of the byte of an instruction which determines its instruction window.

Parameters
FragmentThe fragment pointing to the instruction.
LayoutCode layout information.
Returns
the instruction byte of an instruction pointed by Fragment.

Definition at line 278 of file MCCodePadder.cpp.

References llvm::MCPaddingFragment::getInstSize().

◆ getKindMask()

uint64_t llvm::MCCodePaddingPolicy::getKindMask ( ) const
inline

Returns the kind mask of this policy - A mask holding the kind of this policy, i.e.

only the i'th bit will be set where i is the kind number.

Definition at line 202 of file MCCodePadder.h.

◆ getNextFragmentOffset()

uint64_t MCCodePaddingPolicy::getNextFragmentOffset ( const MCFragment Fragment,
const MCAsmLayout Layout 
)
staticprotected

Computes and returns the offset of the consecutive fragment of a given fragment.

Parameters
FragmentThe fragment whose consecutive offset will be computed.
LayoutCode layout information.
Returns
the offset of the consecutive fragment of Fragment.

Definition at line 268 of file MCCodePadder.cpp.

References assert(), llvm::MCAsmLayout::getFragmentOffset(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::MCFragment::getParent(), and llvm::MCAsmLayout::getSectionAddressSize().

◆ getWindowSize()

uint64_t llvm::MCCodePaddingPolicy::getWindowSize ( ) const
inline

Returns the instruction window size relevant to this policy.

Definition at line 204 of file MCCodePadder.h.

◆ instructionRequiresPaddingFragment()

virtual bool llvm::MCCodePaddingPolicy::instructionRequiresPaddingFragment ( const MCInst Inst) const
inlinevirtual

Returns true iff this policy needs padding for a given instruction.

Parameters
InstThe given instruction.
Returns
true iff this policy needs padding for Inst.

Definition at line 224 of file MCCodePadder.h.

◆ isInstByteLastByte()

bool llvm::MCCodePaddingPolicy::isInstByteLastByte ( ) const
inline

Returns true if the last byte of an instruction determines its instruction window, or false if the first of an instruction determines it.

Definition at line 207 of file MCCodePadder.h.

Member Data Documentation

◆ InstByteIsLastByte

const bool llvm::MCCodePaddingPolicy::InstByteIsLastByte
protected

A boolean indicating which byte of the instruction determies its instruction window.

If true - the last byte of the instructions, o.w. - the first byte of the instruction.

Definition at line 141 of file MCCodePadder.h.

◆ KindMask

const uint64_t llvm::MCCodePaddingPolicy::KindMask
protected

A mask holding the kind of this policy, i.e.

only the i'th bit will be set where i is the kind number.

Definition at line 135 of file MCCodePadder.h.

◆ WindowSize

const uint64_t llvm::MCCodePaddingPolicy::WindowSize
protected

Instruction window size relevant to this policy.

Definition at line 137 of file MCCodePadder.h.


The documentation for this class was generated from the following files: