13#include "llvm/Config/llvm-config.h"
36 if (!Sec.isVirtualSection())
37 SectionOrder.push_back(&Sec);
39 if (Sec.isVirtualSection())
40 SectionOrder.push_back(&Sec);
44 F->getParent()->setHasLayout(
false);
108 if (!Symbol.isVariable())
111 const MCExpr *Expr = Symbol.getVariableValue();
115 Expr->
getLoc(),
"expression could not be evaluated");
123 "' could not be evaluated in a subtraction expression");
134 Asm.getContext().reportError(Expr->
getLoc(),
135 "Common symbol '" + ASym.
getName() +
136 "' cannot be used in assignment expr");
161 : Kind(Kind), HasInstructions(HasInstructions), LinkerRelaxable(
false) {}
166 cast<MCAlignFragment>(
this)->~MCAlignFragment();
169 cast<MCDataFragment>(
this)->~MCDataFragment();
172 cast<MCCompactEncodedInstFragment>(
this)->~MCCompactEncodedInstFragment();
175 cast<MCFillFragment>(
this)->~MCFillFragment();
178 cast<MCNopsFragment>(
this)->~MCNopsFragment();
181 cast<MCRelaxableFragment>(
this)->~MCRelaxableFragment();
184 cast<MCOrgFragment>(
this)->~MCOrgFragment();
187 cast<MCDwarfLineAddrFragment>(
this)->~MCDwarfLineAddrFragment();
190 cast<MCDwarfCallFrameFragment>(
this)->~MCDwarfCallFrameFragment();
193 cast<MCLEBFragment>(
this)->~MCLEBFragment();
196 cast<MCBoundaryAlignFragment>(
this)->~MCBoundaryAlignFragment();
199 cast<MCSymbolIdFragment>(
this)->~MCSymbolIdFragment();
202 cast<MCCVInlineLineTableFragment>(
this)->~MCCVInlineLineTableFragment();
205 cast<MCCVDefRangeFragment>(
this)->~MCCVDefRangeFragment();
208 cast<MCPseudoProbeAddrFragment>(
this)->~MCPseudoProbeAddrFragment();
211 cast<MCDummyFragment>(
this)->~MCDummyFragment();
217 return cast<MCSectionMachO>(Parent)->getAtom(LayoutOrder);
227 <<
" Kind:" << AF.
getKind() <<
">";
233#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
242 OS <<
"MCCompactEncodedInstFragment";
break;
245 OS <<
"MCFNopsFragment";
257 OS <<
"MCPseudoProbe";
262 OS <<
"<MCFragment " << (
const void *)
this <<
" LayoutOrder:" << LayoutOrder
264 if (
const auto *EF = dyn_cast<MCEncodedFragment>(
this))
265 OS <<
" BundlePadding:" <<
static_cast<unsigned>(EF->getBundlePadding());
270 const auto *AF = cast<MCAlignFragment>(
this);
271 if (AF->hasEmitNops())
272 OS <<
" (emit nops)";
274 OS <<
" Alignment:" << AF->getAlignment().value()
275 <<
" Value:" << AF->getValue() <<
" ValueSize:" << AF->getValueSize()
276 <<
" MaxBytesToEmit:" << AF->getMaxBytesToEmit() <<
">";
280 const auto *
DF = cast<MCDataFragment>(
this);
284 for (
unsigned i = 0, e = Contents.
size(); i != e; ++i) {
286 OS << hexdigit((Contents[i] >> 4) & 0xF) << hexdigit(Contents[i] & 0xF);
288 OS <<
"] (" << Contents.
size() <<
" bytes)";
290 if (
DF->fixup_begin() !=
DF->fixup_end()) {
294 ie =
DF->fixup_end(); it != ie; ++it) {
295 if (it !=
DF->fixup_begin())
OS <<
",\n ";
304 cast<MCCompactEncodedInstFragment>(
this);
308 for (
unsigned i = 0, e = Contents.
size(); i != e; ++i) {
310 OS << hexdigit((Contents[i] >> 4) & 0xF) << hexdigit(Contents[i] & 0xF);
312 OS <<
"] (" << Contents.
size() <<
" bytes)";
316 const auto *FF = cast<MCFillFragment>(
this);
317 OS <<
" Value:" <<
static_cast<unsigned>(FF->getValue())
318 <<
" ValueSize:" <<
static_cast<unsigned>(FF->getValueSize())
319 <<
" NumValues:" << FF->getNumValues();
323 const auto *NF = cast<MCNopsFragment>(
this);
324 OS <<
" NumBytes:" << NF->getNumBytes()
325 <<
" ControlledNopLength:" << NF->getControlledNopLength();
329 const auto *
F = cast<MCRelaxableFragment>(
this);
332 F->getInst().dump_pretty(
OS);
333 OS <<
" (" <<
F->getContents().size() <<
" bytes)";
337 const auto *OF = cast<MCOrgFragment>(
this);
339 OS <<
" Offset:" << OF->getOffset()
340 <<
" Value:" <<
static_cast<unsigned>(OF->getValue());
344 const auto *OF = cast<MCDwarfLineAddrFragment>(
this);
346 OS <<
" AddrDelta:" << OF->getAddrDelta()
347 <<
" LineDelta:" << OF->getLineDelta();
351 const auto *CF = cast<MCDwarfCallFrameFragment>(
this);
353 OS <<
" AddrDelta:" << CF->getAddrDelta();
357 const auto *LF = cast<MCLEBFragment>(
this);
359 OS <<
" Value:" << LF->getValue() <<
" Signed:" << LF->isSigned();
363 const auto *BF = cast<MCBoundaryAlignFragment>(
this);
365 OS <<
" BoundarySize:" << BF->getAlignment().value()
366 <<
" LastFragment:" << BF->getLastFragment()
367 <<
" Size:" << BF->getSize();
371 const auto *
F = cast<MCSymbolIdFragment>(
this);
373 OS <<
" Sym:" <<
F->getSymbol();
377 const auto *
F = cast<MCCVInlineLineTableFragment>(
this);
379 OS <<
" Sym:" << *
F->getFnStartSym();
383 const auto *
F = cast<MCCVDefRangeFragment>(
this);
385 for (std::pair<const MCSymbol *, const MCSymbol *> RangeStartEnd :
387 OS <<
" RangeStart:" << RangeStartEnd.first;
388 OS <<
" RangeEnd:" << RangeStartEnd.second;
393 const auto *OF = cast<MCPseudoProbeAddrFragment>(
this);
395 OS <<
" AddrDelta:" << OF->getAddrDelta();
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
static bool getSymbolOffsetImpl(const MCAsmLayout &Layout, const MCSymbol &S, bool ReportError, uint64_t &Val)
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S, bool ReportError, uint64_t &Val)
This file defines the SmallVector class.
Encapsulates the layout of an assembly file at a particular point in time.
void invalidateFragmentsFrom(MCFragment *F)
Invalidate the fragments starting with F because it has been resized.
const MCSymbol * getBaseSymbol(const MCSymbol &Symbol) const
If this symbol is equivalent to A + Constant, return A.
uint64_t getSectionAddressSize(const MCSection *Sec) const
Get the address space size of the given section, as it effects layout.
uint64_t getSectionFileSize(const MCSection *Sec) const
Get the data size of the given section, as emitted to the object file.
bool getSymbolOffset(const MCSymbol &S, uint64_t &Val) const
Get the offset of the given symbol, as computed in the current layout.
MCAsmLayout(MCAssembler &Assembler)
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
MCAssembler & getAssembler() const
Get the assembler object this is a layout for.
MCContext & getContext() 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...
void reportError(SMLoc L, const Twine &Msg)
SmallVectorImpl< MCFixup >::const_iterator const_fixup_iterator
Base class for the full range of assembler expressions which are needed for parsing.
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.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
const MCExpr * getValue() const
uint32_t getOffset() const
MCFixupKind getKind() const
FragmentType getKind() const
const MCSymbol * getAtom() const
void destroy()
Destroys the current fragment.
bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
Instances of this class represent a uniqued identifier for a section in the current translation unit.
bool isVirtualSection() const
Check whether this section is "virtual", that is has no actual object file contents.
FragList * curFragList() const
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MCExpr * getVariableValue(bool SetUsed=true) const
getVariableValue - Get the value for variable symbols.
bool isCommon() const
Is this a 'common' symbol.
StringRef getName() const
getName - Get the symbol name.
bool isVariable() const
isVariable - Check if this is a variable symbol.
uint64_t getOffset() const
MCFragment * getFragment(bool SetUsed=true) const
This represents an "assembler immediate".
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)