35 if (!Sec.isVirtualSection())
36 SectionOrder.push_back(&Sec);
38 if (Sec.isVirtualSection())
39 SectionOrder.push_back(&Sec);
42 bool MCAsmLayout::isFragmentValid(
const MCFragment *
F)
const {
44 const MCFragment *LastValid = LastValidFragment.lookup(Sec);
53 if (!isFragmentValid(F))
61 void MCAsmLayout::ensureValid(
const MCFragment *F)
const {
70 while (!isFragmentValid(F)) {
71 assert(I != Sec->end() &&
"Layout bookkeeping error");
79 assert(F->Offset != ~UINT64_C(0) &&
"Address not set!");
147 Expr->
getLoc(),
"expression could not be evaluated");
155 "' could not be evaluated in a subtraction expression");
167 "Common symbol '" + ASym.
getName() +
168 "' cannot be used in assignment expr");
192 uint64_t FOffset, uint64_t FSize) {
195 "computeBundlePadding should only be called if bundling is enabled");
196 uint64_t BundleMask = BundleSize - 1;
197 uint64_t OffsetInBundle = FOffset & BundleMask;
198 uint64_t EndOfFragment = OffsetInBundle + FSize;
218 if (EndOfFragment == BundleSize)
220 else if (EndOfFragment < BundleSize)
221 return BundleSize - EndOfFragment;
223 return 2 * BundleSize - EndOfFragment;
225 }
else if (OffsetInBundle > 0 && EndOfFragment > BundleSize)
226 return BundleSize - OffsetInBundle;
238 uint8_t BundlePadding,
MCSection *Parent)
239 : Kind(Kind), HasInstructions(HasInstructions), AlignToBundleEnd(
false),
240 BundlePadding(BundlePadding), Parent(Parent), Atom(nullptr),
255 delete cast<MCAlignFragment>(
this);
258 delete cast<MCDataFragment>(
this);
261 delete cast<MCCompactEncodedInstFragment>(
this);
264 delete cast<MCFillFragment>(
this);
267 delete cast<MCRelaxableFragment>(
this);
270 delete cast<MCOrgFragment>(
this);
273 delete cast<MCDwarfLineAddrFragment>(
this);
276 delete cast<MCDwarfCallFrameFragment>(
this);
279 delete cast<MCLEBFragment>(
this);
282 delete cast<MCSafeSEHFragment>(
this);
285 delete cast<MCCVInlineLineTableFragment>(
this);
288 delete cast<MCCVDefRangeFragment>(
this);
291 delete cast<MCDummyFragment>(
this);
301 OS <<
"<MCFixup" <<
" Offset:" << AF.
getOffset()
303 <<
" Kind:" << AF.
getKind() <<
">";
309 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
318 OS <<
"MCCompactEncodedInstFragment";
break;
331 OS <<
"<MCFragment " << (
const void*)
this <<
" LayoutOrder:" << LayoutOrder
332 <<
" Offset:" << Offset
340 OS <<
" (emit nops)";
352 for (
unsigned i = 0, e = Contents.
size(); i != e; ++i) {
354 OS << hexdigit((Contents[i] >> 4) & 0xF) <<
hexdigit(Contents[i] & 0xF);
356 OS <<
"] (" << Contents.
size() <<
" bytes)";
372 cast<MCCompactEncodedInstFragment>(
this);
376 for (
unsigned i = 0, e = Contents.
size(); i != e; ++i) {
378 OS << hexdigit((Contents[i] >> 4) & 0xF) <<
hexdigit(Contents[i] & 0xF);
380 OS <<
"] (" << Contents.
size() <<
" bytes)";
385 OS <<
" Value:" <<
static_cast<unsigned>(FF->
getValue())
400 <<
" Value:" <<
static_cast<unsigned>(OF->
getValue());
429 const auto *F = cast<MCCVInlineLineTableFragment>(
this);
431 OS <<
" Sym:" << *F->getFnStartSym();
435 const auto *F = cast<MCCVDefRangeFragment>(
this);
437 for (std::pair<const MCSymbol *, const MCSymbol *> RangeStartEnd :
439 OS <<
" RangeStart:" << RangeStartEnd.first;
440 OS <<
" RangeEnd:" << RangeStartEnd.second;
453 OS <<
"<MCAssembler\n";
454 OS <<
" Sections:[\n ";
456 if (it !=
begin()) OS <<
",\n ";
466 OS <<
", Index:" << it->getIndex() <<
", ";
uint8_t getBundlePadding() const
Get the padding size that must be inserted before this fragment.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
static bool getSymbolOffsetImpl(const MCAsmLayout &Layout, const MCSymbol &S, bool ReportError, uint64_t &Val)
unsigned getValueSize() const
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
const MCSymbol & getSymbol() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
This represents an "assembler immediate".
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
unsigned getAlignment() const
const MCExpr & getAddrDelta() const
unsigned getBundleAlignSize() const
bool alignToBundleEnd() const
Should this fragment be placed at the end of an aligned bundle?
bool getSymbolOffset(const MCSymbol &S, uint64_t &Val) const
Get the offset of the given symbol, as computed in the current layout.
This is a compact (memory-size-wise) fragment for holding an encoded instruction (non-relaxable) that...
MCContext & getContext() const
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S, bool ReportError, uint64_t &Val)
const MCExpr & getOffset() const
void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer=nullptr, StringRef Separator=" ") const
Dump the MCInst as prettily as possible using the additional MC structures, if given.
symbol_iterator symbol_begin()
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
const MCInst & getInst() const
fixup_iterator fixup_end()
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SmallVectorImpl< MCFixup >::const_iterator const_fixup_iterator
Encapsulates the layout of an assembly file at a particular point in time.
Base class for the full range of assembler expressions which are needed for parsing.
unsigned getMaxBytesToEmit() const
Represent a reference to a symbol from inside an expression.
int64_t getLineDelta() const
void destroy()
Destroys the current fragment.
const MCSymbol * getSymbol()
void layoutFragment(MCFragment *Fragment)
Perform layout for a single fragment, assuming that the previous fragment has already been laid out c...
SmallVectorImpl< char > & getContents()
uint32_t getOffset() const
const MCExpr & getAddrDelta() const
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Function Alias Analysis false
bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
MCAsmLayout(MCAssembler &Assembler)
const MCSymbol * getBaseSymbol(const MCSymbol &Symbol) const
If this symbol is equivalent to A + Constant, return A.
const MCExpr * getValue() const
uint64_t computeFragmentSize(const MCAsmLayout &Layout, const MCFragment &F) const
Compute the effective fragment size assuming it is laid out at the given SectionAddress and FragmentO...
bool isDummy() const
Return true if given frgment has FT_Dummy type.
FragmentType getKind() const
void invalidateFragmentsFrom(MCFragment *F)
Invalidate the fragments starting with F because it has been resized.
bool evaluateAsValue(MCValue &Res, const MCAsmLayout &Layout) const
Try to evaluate the expression to the form (a - b + constant) where neither a nor b are variables...
uint64_t getSectionAddressSize(const MCSection *Sec) const
Get the address space size of the given section, as it effects layout.
void reportError(SMLoc L, const Twine &Msg)
MCFixupKind getKind() const
const MCSymbolRefExpr * getSymB() const
uint64_t computeBundlePadding(const MCAssembler &Assembler, const MCFragment *F, uint64_t FOffset, uint64_t FSize)
Compute the amount of padding required before the fragment F to obey bundling restrictions, where FOffset is the fragment's offset in its section and FSize is the fragment's size.
Iterator for intrusive lists based on ilist_node.
const MCSymbolRefExpr * getSymA() const
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
An iterator type that allows iterating over the pointees via some other iterator. ...
static const char * Target
MCSection * getParent() const
static void deleteNode(NodeTy *V)
void push_back(pointer val)
const MCExpr * getVariableValue(bool SetUsed=true) const
getVariableValue - Get the value for variable symbols.
static char hexdigit(unsigned X, bool LowerCase=false)
hexdigit - Return the hexadecimal character for the given number X (which should be less than 16)...
StringRef getName() const
getName - Get the symbol name.
uint64_t getOffset() const
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool isCommon() const
Is this a 'common' symbol.
fixup_iterator fixup_begin()
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
bool isVariable() const
isVariable - Check if this is a variable symbol.
MCFragment * getFragment(bool SetUsed=true) const
Fragment for data and encoded instructions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
int64_t getConstant() const
LLVM Value Representation.
MCAssembler & getAssembler() const
Get the assembler object this is a layout for.
This class implements an extremely fast bulk output stream that can only output to a stream...
const MCExpr & getValue() const
uint64_t getSectionFileSize(const MCSection *Sec) const
Get the data size of the given section, as emitted to the object file.
unsigned getLayoutOrder() const
FragmentListType::iterator iterator
static void LLVM_ATTRIBUTE_NORETURN ReportError(uint32_t StartOffset, const char *ErrorMsg)
MCSection::FragmentListType & getFragmentList()
symbol_iterator symbol_end()