32 : Assembler(Asm), LastValidFragment()
36 if (!Sec.isVirtualSection())
37 SectionOrder.push_back(&Sec);
39 if (Sec.isVirtualSection())
40 SectionOrder.push_back(&Sec);
43 bool MCAsmLayout::isFragmentValid(
const MCFragment *
F)
const {
45 const MCFragment *LastValid = LastValidFragment.lookup(Sec);
54 if (!isFragmentValid(F))
62 void MCAsmLayout::ensureValid(
const MCFragment *F)
const {
71 while (!isFragmentValid(F)) {
72 assert(I != Sec->end() &&
"Layout bookkeeping error");
80 assert(F->Offset != ~UINT64_C(0) &&
"Address not set!");
86 bool ReportError, uint64_t &Val) {
98 bool ReportError, uint64_t &Val) {
148 SMLoc(),
"expression could not be evaluated");
156 "' could not be evaluated in a subtraction expression");
169 "Common symbol '" + ASym.
getName() +
170 "' cannot be used in assignment expr");
194 uint64_t FOffset, uint64_t FSize) {
197 "computeBundlePadding should only be called if bundling is enabled");
198 uint64_t BundleMask = BundleSize - 1;
199 uint64_t OffsetInBundle = FOffset & BundleMask;
200 uint64_t EndOfFragment = OffsetInBundle + FSize;
220 if (EndOfFragment == BundleSize)
222 else if (EndOfFragment < BundleSize)
223 return BundleSize - EndOfFragment;
225 return 2 * BundleSize - EndOfFragment;
227 }
else if (OffsetInBundle > 0 && EndOfFragment > BundleSize)
228 return BundleSize - OffsetInBundle;
240 uint8_t BundlePadding,
MCSection *Parent)
241 : Kind(Kind), HasInstructions(HasInstructions), AlignToBundleEnd(
false),
242 BundlePadding(BundlePadding), Parent(Parent), Atom(nullptr),
257 delete cast<MCAlignFragment>(
this);
260 delete cast<MCDataFragment>(
this);
263 delete cast<MCCompactEncodedInstFragment>(
this);
266 delete cast<MCFillFragment>(
this);
269 delete cast<MCRelaxableFragment>(
this);
272 delete cast<MCOrgFragment>(
this);
275 delete cast<MCDwarfLineAddrFragment>(
this);
278 delete cast<MCDwarfCallFrameFragment>(
this);
281 delete cast<MCLEBFragment>(
this);
284 delete cast<MCSafeSEHFragment>(
this);
287 delete cast<MCCVInlineLineTableFragment>(
this);
290 delete cast<MCCVDefRangeFragment>(
this);
293 delete cast<MCDummyFragment>(
this);
305 OS <<
"<MCFixup" <<
" Offset:" << AF.
getOffset()
307 <<
" Kind:" << AF.
getKind() <<
">";
321 OS <<
"MCCompactEncodedInstFragment";
break;
334 OS <<
"<MCFragment " << (
void*)
this <<
" LayoutOrder:" << LayoutOrder
335 <<
" Offset:" << Offset
343 OS <<
" (emit nops)";
355 for (
unsigned i = 0, e = Contents.
size();
i != e; ++
i) {
357 OS << hexdigit((Contents[i] >> 4) & 0xF) <<
hexdigit(Contents[
i] & 0xF);
359 OS <<
"] (" << Contents.
size() <<
" bytes)";
375 cast<MCCompactEncodedInstFragment>(
this);
379 for (
unsigned i = 0, e = Contents.
size();
i != e; ++
i) {
381 OS << hexdigit((Contents[i] >> 4) & 0xF) <<
hexdigit(Contents[
i] & 0xF);
383 OS <<
"] (" << Contents.
size() <<
" bytes)";
430 const auto *F = cast<MCCVInlineLineTableFragment>(
this);
432 OS <<
" Sym:" << *F->getFnStartSym();
436 const auto *F = cast<MCCVDefRangeFragment>(
this);
438 for (std::pair<const MCSymbol *, const MCSymbol *> RangeStartEnd :
440 OS <<
" RangeStart:" << RangeStartEnd.first;
441 OS <<
" RangeEnd:" << RangeStartEnd.second;
454 OS <<
"<MCAssembler\n";
455 OS <<
" Sections:[\n ";
457 if (it !=
begin()) OS <<
",\n ";
467 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...
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.
Function Alias Analysis false
const MCSymbol * getSymbol()
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
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...
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
FragmentListType::iterator iterator
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
Represents a location in source code.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
MCSection::FragmentListType & getFragmentList()
symbol_iterator symbol_end()