26 for (
const auto &
I : Insns) {
27 switch (static_cast<Win64EH::UnwindOpcodes>(
I.Operation)) {
45 Count += (
I.Offset > 512 * 1024 - 8) ? 3 : 2;
66 switch (static_cast<Win64EH::UnwindOpcodes>(inst.
Operation)) {
76 if (inst.
Offset > 512 * 1024 - 8) {
89 b2 |= (((inst.
Offset - 8) >> 3) & 0x0F) << 4;
167 uint8_t flags = 0x01;
196 for (uint8_t c = 0; c < numInst; ++c) {
217 else if (numCodes == 0) {
262 if (!Diff->evaluateAsAbsolute(value, OS->
getAssembler()))
270 for (
const auto &
I : Insns) {
271 switch (static_cast<Win64EH::UnwindOpcodes>(
I.Operation)) {
335 switch (static_cast<Win64EH::UnwindOpcodes>(inst.
Operation)) {
339 b = (inst.
Offset >> 4) & 0x1F;
356 b = (w & 0x00FF0000) >> 16;
358 b = (w & 0x0000FF00) >> 8;
380 b |= ((inst.
Offset - 1) >> 3) & 0x3F;
385 b |= (inst.
Offset >> 3) & 0x3F;
391 b = 0xD0 | ((reg & 0xC) >> 2);
393 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
399 b = 0xD4 | ((reg & 0x8) >> 3);
401 b = ((reg & 0x7) << 5) | ((inst.
Offset >> 3) - 1);
407 b = 0xC8 | ((reg & 0xC) >> 2);
409 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
415 b = 0xCC | ((reg & 0xC) >> 2);
417 b = ((reg & 0x3) << 6) | ((inst.
Offset >> 3) - 1);
423 b = 0xDC | ((reg & 0x4) >> 2);
425 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
433 b = ((reg & 0x7) << 5) | ((inst.
Offset >> 3) - 1);
439 b = 0xD8 | ((reg & 0x4) >> 2);
441 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
447 b = 0xDA | ((reg & 0x4) >> 2);
449 b = ((reg & 0x3) << 6) | ((inst.
Offset >> 3) - 1);
465 const std::vector<MCSymbol *>& Epilogs,
467 for (
auto *EpilogStart : Epilogs) {
468 auto InstrsIter = info->
EpilogMap.find(EpilogStart);
470 "Epilog not found in EpilogMap");
471 const auto &Instrs = InstrsIter->second;
473 if (Instrs.size() != EpilogInstrs.size())
477 for (
unsigned i = 0; i < Instrs.size(); ++i)
505 int64_t RawFuncLength;
540 if (RawFuncLength > 0xFFFFF)
544 uint32_t TotalCodeBytes = PrologCodeBytes;
549 std::vector<MCSymbol *> AddedEpilogs;
553 auto &EpilogInstrs =
I.second;
558 if (MatchingEpilog) {
559 assert(EpilogInfo.
find(MatchingEpilog) != EpilogInfo.
end() &&
560 "Duplicate epilog not found");
561 EpilogInfo[EpilogStart] = EpilogInfo.
lookup(MatchingEpilog);
564 EpilogInstrs.clear();
566 EpilogInfo[EpilogStart] = TotalCodeBytes;
567 TotalCodeBytes += CodeBytes;
568 AddedEpilogs.push_back(EpilogStart);
574 uint32_t CodeWords = TotalCodeBytes / 4;
575 uint32_t CodeWordsMod = TotalCodeBytes % 4;
579 bool ExtensionWord = EpilogCount > 31 || TotalCodeBytes > 124;
580 if (!ExtensionWord) {
581 row1 |= (EpilogCount & 0x1F) << 22;
582 row1 |= (CodeWords & 0x1F) << 27;
587 row1 |= FuncLength & 0x3FFFF;
595 if (CodeWords > 0xFF || EpilogCount > 0xFFFF)
598 row2 |= (CodeWords & 0xFF) << 16;
599 row2 |= (EpilogCount & 0xFFFF);
604 for (
auto &
I : EpilogInfo) {
612 row3 |= (EpilogIndex & 0x3FF) << 22;
618 for (uint8_t c = 0; c < numInst; ++c) {
626 auto &EpilogInstrs =
I.second;
627 for (
uint32_t i = 0; i < EpilogInstrs.size(); i++) {
633 int32_t BytesMod = CodeWords * 4 - TotalCodeBytes;
635 for (
int i = 0; i < BytesMod; i++)
Instances of this class represent a uniqued identifier for a section in the current translation unit...
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static void ARM64EmitRuntimeFunction(MCStreamer &streamer, const WinEH::FrameInfo *info)
UNW_ExceptionHandler - Specifies that this function has an exception handler.
static void EmitUnwindCode(MCStreamer &streamer, const MCSymbol *begin, WinEH::Instruction &inst)
This class implements a map that also provides access to all stored values in a deterministic order...
std::vector< Instruction > Instructions
static void ARM64EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info)
MCContext & getContext() const
Base class for the full range of assembler expressions which are needed for parsing.
Represent a reference to a symbol from inside an expression.
static void EmitAbsDifference(MCStreamer &Streamer, const MCSymbol *LHS, const MCSymbol *RHS)
ArrayRef< std::unique_ptr< WinEH::FrameInfo > > getWinFrameInfos() const
Context object for machine code objects.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Streaming object file generation interface.
UNW_TerminateHandler - Specifies that this function has a termination handler.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
iterator find(const KeyT &Key)
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
static uint32_t ARM64CountOfUnwindCodes(const std::vector< WinEH::Instruction > &Insns)
static void EmitSymbolRefWithOfs(MCStreamer &streamer, const MCSymbol *Base, const MCSymbol *Other)
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
const FrameInfo * ChainedParent
static void EmitRuntimeFunction(MCStreamer &streamer, const WinEH::FrameInfo *info)
PowerPC Reduce CR logical Operation
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
MCAssembler & getAssembler()
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI) const override
UNW_ChainInfo - Specifies that this UnwindInfo structure is chained to another one.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCSymbol * PrologEnd
const MCSection * TextSection
void Emit(MCStreamer &Streamer) const override
This emits the unwind info sections (.pdata and .xdata in PE/COFF).
MapVector< MCSymbol *, std::vector< Instruction > > EpilogMap
const MCSymbol * Function
ValueT lookup(const KeyT &Key) const
static MCSymbol * FindMatchingEpilog(const std::vector< WinEH::Instruction > &EpilogInstrs, const std::vector< MCSymbol *> &Epilogs, const WinEH::FrameInfo *info)
const MCSymbol * FuncletOrFuncEnd
static uint8_t CountOfUnwindCodes(std::vector< WinEH::Instruction > &Insns)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static int64_t GetAbsDifference(MCStreamer &Streamer, const MCSymbol *LHS, const MCSymbol *RHS)
static void ARM64EmitUnwindCode(MCStreamer &streamer, const MCSymbol *begin, WinEH::Instruction &inst)
void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI) const override
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
static void EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info)
const MCSymbol * ExceptionHandler
Wrapper class representing virtual and physical registers.
void Emit(MCStreamer &Streamer) const override
This emits the unwind info sections (.pdata and .xdata in PE/COFF).
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.