Lines Matching +full:sw +full:- +full:exception
1 //===-- ARMWinEHPrinter.cpp - Windows on ARM EH Data Printer ----*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
15 // RuntimeFunction's remaining 30-bits and can fully describe the entire frame.
17 // +---------------------------------------+
19 // +---------------------------------------+
21 // +---------------------------------------+
30 // split up into two portions, with the actual data residing in the "exception
34 // The exception data contains information about the frame setup, all of the
36 // the associated exception handler. Additionally, the entry contains byte-code
39 // +---------------------------------------+
41 // +---------------------------------------+
42 // | Exception Data Entry Address |
43 // +---------------------------------------+
46 // first resolve the exception data entry address. This structure
53 // The decoder itself is table-driven, using the first byte to determine the
59 // The byte-code maintains a 1-1 instruction mapping, indicating both the width
119 { 0x80, 0x00, 1, &Decoder::opcode_0xxxxxxx }, // UOP_STACK_FREE (16-bit)
120 { 0xc0, 0x80, 2, &Decoder::opcode_10Lxxxxx }, // UOP_POP (32-bit)
121 { 0xf0, 0xc0, 1, &Decoder::opcode_1100xxxx }, // UOP_STACK_SAVE (16-bit)
122 { 0xf8, 0xd0, 1, &Decoder::opcode_11010Lxx }, // UOP_POP (16-bit)
123 { 0xf8, 0xd8, 1, &Decoder::opcode_11011Lxx }, // UOP_POP (32-bit)
124 { 0xf8, 0xe0, 1, &Decoder::opcode_11100xxx }, // UOP_VPOP (32-bit)
125 { 0xfc, 0xe8, 2, &Decoder::opcode_111010xx }, // UOP_STACK_FREE (32-bit)
126 { 0xfe, 0xec, 2, &Decoder::opcode_1110110L }, // UOP_POP (16-bit)
127 { 0xff, 0xee, 2, &Decoder::opcode_11101110 }, // UOP_MICROSOFT_SPECIFIC (16-bit)
132 { 0xff, 0xef, 2, &Decoder::opcode_11101111 }, // UOP_LDRPC_POSTINC (32-bit)
133 { 0xff, 0xf5, 2, &Decoder::opcode_11110101 }, // UOP_VPOP (32-bit)
134 { 0xff, 0xf6, 2, &Decoder::opcode_11110110 }, // UOP_VPOP (32-bit)
135 { 0xff, 0xf7, 3, &Decoder::opcode_11110111 }, // UOP_STACK_RESTORE (16-bit)
136 { 0xff, 0xf8, 4, &Decoder::opcode_11111000 }, // UOP_STACK_RESTORE (16-bit)
137 { 0xff, 0xf9, 3, &Decoder::opcode_11111001 }, // UOP_STACK_RESTORE (32-bit)
138 { 0xff, 0xfa, 4, &Decoder::opcode_11111010 }, // UOP_STACK_RESTORE (32-bit)
139 { 0xff, 0xfb, 1, &Decoder::opcode_11111011 }, // UOP_NOP (16-bit)
140 { 0xff, 0xfc, 1, &Decoder::opcode_11111100 }, // UOP_NOP (32-bit)
141 { 0xff, 0xfd, 1, &Decoder::opcode_11111101 }, // UOP_NOP (16-bit) / END
142 { 0xff, 0xfe, 1, &Decoder::opcode_11111110 }, // UOP_NOP (32-bit) / END
147 // https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling
184 OS << LS << Letter << First << "-" << Letter << Last; in printRange()
189 int First = -1; in printRange()
196 printRange(OS, LS, First, RI - 1, Letter); in printRange()
197 First = -1; in printRange()
229 if (VA >= Address && (VA - Address) <= Size) in getSectionContaining()
278 uint32_t Offset = CoffSym.getValue() + SymbolOffset - CS.getValue(); in getPreferredSymbol()
303 Expected<uint64_t> AddressOrErr = SymOrErr->getAddress(); in getSymbolForLocation()
331 SW.startLine() << format("0x%02x ; %s sp, #(%u * 4)\n", in opcode_0xxxxxxx()
348 SW.startLine() << format("0x%02x 0x%02x ; %s.w ", in opcode_10Lxxxxx()
361 SW.startLine() << format("0x%02x ; mov r%u, sp\n", in opcode_1100xxxx()
364 SW.startLine() << format("0x%02x ; mov sp, r%u\n", in opcode_1100xxxx()
376 | (((1 << (Count + 1)) - 1) << 4); in opcode_11010Lxx()
378 SW.startLine() << format("0x%02x ; %s ", OC[Offset], in opcode_11010Lxx()
393 | (((1 << (Count + 1)) - 1) << 4); in opcode_11011Lxx()
395 SW.startLine() << format("0x%02x ; %s.w ", OC[Offset], in opcode_11011Lxx()
407 uint32_t VFPMask = (((1 << (High + 1)) - 1) << 8); in opcode_11100xxx()
409 SW.startLine() << format("0x%02x ; %s ", OC[Offset], in opcode_11100xxx()
422 SW.startLine() << format("0x%02x 0x%02x ; %s.w sp, #(%u * 4)\n", in opcode_111010xx()
436 SW.startLine() << format("0x%02x 0x%02x ; %s ", OC[Offset + 0], in opcode_1110110L()
450 SW.startLine() << format("0x%02x 0x%02x ; reserved\n", in opcode_11101110()
453 SW.startLine() in opcode_11101110()
454 << format("0x%02x 0x%02x ; microsoft-specific (type: %u)\n", in opcode_11101110()
464 SW.startLine() << format("0x%02x 0x%02x ; reserved\n", in opcode_11101111()
467 SW.startLine() in opcode_11101111()
468 << format("0x%02x 0x%02x ; str.w lr, [sp, #-%u]!\n", in opcode_11101111()
471 SW.startLine() in opcode_11101111()
483 uint32_t VFPMask = ((1 << (End + 1 - Start)) - 1) << Start; in opcode_11110101()
485 SW.startLine() << format("0x%02x 0x%02x ; %s ", OC[Offset + 0], in opcode_11110101()
498 uint32_t VFPMask = ((1 << (End + 1 - Start)) - 1) << (16 + Start); in opcode_11110110()
500 SW.startLine() << format("0x%02x 0x%02x ; %s ", OC[Offset + 0], in opcode_11110110()
513 SW.startLine() << format("0x%02x 0x%02x 0x%02x ; %s sp, sp, #(%u * 4)\n", in opcode_11110111()
528 SW.startLine() in opcode_11111000()
541 SW.startLine() in opcode_11111001()
556 SW.startLine() in opcode_11111010()
567 SW.startLine() << format("0x%02x ; nop\n", OC[Offset]); in opcode_11111011()
574 SW.startLine() << format("0x%02x ; nop.w\n", OC[Offset]); in opcode_11111100()
581 SW.startLine() << format("0x%02x ; bx <reg>\n", OC[Offset]); in opcode_11111101()
588 SW.startLine() << format("0x%02x ; b.w <target>\n", OC[Offset]); in opcode_11111110()
603 SW.startLine() << format("0x%02x ; %s sp, #%u\n", OC[Offset], in opcode_alloc_s()
614 SW.startLine() << format( in opcode_save_r19r20_x()
615 "0x%02x ; stp x19, x20, [sp, #-%u]!\n", OC[Offset], Off); in opcode_save_r19r20_x()
617 SW.startLine() << format( in opcode_save_r19r20_x()
626 SW.startLine() << format( in opcode_save_fplr()
637 SW.startLine() << format( in opcode_save_fplr_x()
638 "0x%02x ; stp x29, x30, [sp, #-%u]!\n", OC[Offset], Off); in opcode_save_fplr_x()
640 SW.startLine() << format( in opcode_save_fplr_x()
651 SW.startLine() << format("0x%02x%02x ; %s sp, #%u\n", in opcode_alloc_m()
666 SW.startLine() << format( in opcode_save_regp()
682 SW.startLine() << format( in opcode_save_regp_x()
683 "0x%02x%02x ; stp x%u, x%u, [sp, #-%u]!\n", in opcode_save_regp_x()
687 SW.startLine() << format( in opcode_save_regp_x()
702 SW.startLine() << format("0x%02x%02x ; %s x%u, [sp, #%u]\n", in opcode_save_reg()
718 SW.startLine() << format("0x%02x%02x ; str x%u, [sp, #-%u]!\n", in opcode_save_reg_x()
721 SW.startLine() << format("0x%02x%02x ; ldr x%u, [sp], #%u\n", in opcode_save_reg_x()
735 SW.startLine() << format("0x%02x%02x ; %s x%u, lr, [sp, #%u]\n", in opcode_save_lrpair()
750 SW.startLine() << format("0x%02x%02x ; %s d%u, d%u, [sp, #%u]\n", in opcode_save_fregp()
766 SW.startLine() << format( in opcode_save_fregp_x()
767 "0x%02x%02x ; stp d%u, d%u, [sp, #-%u]!\n", OC[Offset], in opcode_save_fregp_x()
770 SW.startLine() << format( in opcode_save_fregp_x()
784 SW.startLine() << format("0x%02x%02x ; %s d%u, [sp, #%u]\n", in opcode_save_freg()
797 SW.startLine() << format( in opcode_save_freg_x()
798 "0x%02x%02x ; str d%u, [sp, #-%u]!\n", OC[Offset], in opcode_save_freg_x()
801 SW.startLine() << format( in opcode_save_freg_x()
813 SW.startLine() << format( in opcode_alloc_l()
823 SW.startLine() << format("0x%02x ; mov %s, %s\n", OC[Offset], in opcode_setfp()
833 SW.startLine() << format( in opcode_addfp()
844 SW.startLine() << format("0x%02x ; nop\n", OC[Offset]); in opcode_nop()
851 SW.startLine() << format("0x%02x ; end\n", OC[Offset]); in opcode_end()
858 SW.startLine() << format("0x%02x ; end_c\n", OC[Offset]); in opcode_end_c()
866 SW.startLine() << format("0x%02x ; save next\n", OC[Offset]); in opcode_save_next()
868 SW.startLine() << format("0x%02x ; restore next\n", in opcode_save_next()
882 // - 0 is an x register in opcode_save_any_reg()
883 // - 1 is the low half of a q register in opcode_save_any_reg()
884 // - 2 is a whole q register in opcode_save_any_reg()
886 // Encoded register name (0 -> x0/q0, 1 -> x1/q1, etc.) in opcode_save_any_reg()
897 SW.startLine() << format("0x%02x%02x%02x ; ", OC[Offset], in opcode_save_any_reg()
905 --MaxReg; in opcode_save_any_reg()
907 --MaxReg; in opcode_save_any_reg()
909 SW.getOStream() << "invalid save_any_reg encoding\n"; in opcode_save_any_reg()
916 SW.getOStream() << "stp "; in opcode_save_any_reg()
918 SW.getOStream() << "ldp "; in opcode_save_any_reg()
921 SW.getOStream() << "str "; in opcode_save_any_reg()
923 SW.getOStream() << "ldr "; in opcode_save_any_reg()
934 SW.getOStream() << format("%c%d, %c%d, ", RegChar, Reg, RegChar, Reg + 1); in opcode_save_any_reg()
936 SW.getOStream() << format("%c%d, ", RegChar, Reg); in opcode_save_any_reg()
940 SW.getOStream() << format("[sp, #-%d]!\n", StackOffset); in opcode_save_any_reg()
942 SW.getOStream() << format("[sp], #%d\n", StackOffset); in opcode_save_any_reg()
944 SW.getOStream() << format("[sp, #%d]\n", StackOffset); in opcode_save_any_reg()
953 SW.startLine() << format("0x%02x ; trap frame\n", OC[Offset]); in opcode_trap_frame()
960 SW.startLine() << format("0x%02x ; machine frame\n", in opcode_machine_frame()
968 SW.startLine() << format("0x%02x ; context\n", OC[Offset]); in opcode_context()
975 SW.startLine() << format("0x%02x ; EC context\n", OC[Offset]); in opcode_ec_context()
982 SW.startLine() << format("0x%02x ; clear unwound to call\n", in opcode_clear_unwound_to_call()
991 SW.startLine() << format("0x%02x ; pacibsp\n", OC[Offset]); in opcode_pac_sign_lr()
993 SW.startLine() << format("0x%02x ; autibsp\n", OC[Offset]); in opcode_pac_sign_lr()
1007 SW.startLine() << format("0x%02x ; Bad opcode!\n", in decodeOpcodes()
1015 SW.startLine() << format("Opcode 0x%02x goes past the unwind data\n", in decodeOpcodes()
1021 (this->*DecodeRing[DI].Routine)(Opcodes.data(), OI, 0, Prologue); in decodeOpcodes()
1036 uint64_t Offset = VA - SectionVA; in dumpXDataRecord()
1043 if (Contents.size() - Offset < 8) in dumpXDataRecord()
1047 DictScope XRS(SW, "ExceptionData"); in dumpXDataRecord()
1048 SW.printNumber("FunctionLength", in dumpXDataRecord()
1051 SW.printNumber("Version", XData.Vers()); in dumpXDataRecord()
1052 SW.printBoolean("ExceptionData", XData.X()); in dumpXDataRecord()
1053 SW.printBoolean("EpiloguePacked", XData.E()); in dumpXDataRecord()
1055 SW.printBoolean("Fragment", XData.F()); in dumpXDataRecord()
1056 SW.printNumber(XData.E() ? "EpilogueOffset" : "EpilogueScopes", in dumpXDataRecord()
1059 SW.printNumber("ByteCodeLength", ByteCodeLength); in dumpXDataRecord()
1061 if ((int64_t)(Contents.size() - Offset - 4 * HeaderWords(XData) - in dumpXDataRecord()
1062 (XData.E() ? 0 : XData.EpilogueCount() * 4) - in dumpXDataRecord()
1064 SW.flush(); in dumpXDataRecord()
1071 ListScope PS(SW, "Prologue"); in dumpXDataRecord()
1075 ListScope ES(SW, "Epilogue"); in dumpXDataRecord()
1080 ListScope PS(SW, "Prologue"); in dumpXDataRecord()
1084 ListScope ESS(SW, "EpilogueScopes"); in dumpXDataRecord()
1086 DictScope ESES(SW, "EpilogueScope"); in dumpXDataRecord()
1087 SW.printNumber("StartOffset", ES.EpilogueStartOffset()); in dumpXDataRecord()
1089 SW.printNumber("Condition", ES.Condition()); in dumpXDataRecord()
1090 SW.printNumber("EpilogueStartIndex", in dumpXDataRecord()
1095 SW.printNumber("ReservedBits", (ES.ES >> 18) & ReservedMask); in dumpXDataRecord()
1097 ListScope Opcodes(SW, "Opcodes"); in dumpXDataRecord()
1117 ListScope EHS(SW, "ExceptionHandler"); in dumpXDataRecord()
1118 SW.printHex("Routine", Address); in dumpXDataRecord()
1119 SW.printHex("Parameter", Parameter); in dumpXDataRecord()
1123 Expected<StringRef> Name = Symbol->getName(); in dumpXDataRecord()
1131 ListScope EHS(SW, "ExceptionHandler"); in dumpXDataRecord()
1132 SW.printString("Routine", formatSymbol(*Name, Address, SymbolOffset)); in dumpXDataRecord()
1133 SW.printHex("Parameter", Parameter); in dumpXDataRecord()
1162 Expected<StringRef> FunctionNameOrErr = Function->getName(); in dumpUnpackedEntry()
1172 SW.printString("Function", in dumpUnpackedEntry()
1176 Expected<StringRef> Name = XDataRecord->getName(); in dumpUnpackedEntry()
1184 SW.printString("ExceptionRecord", in dumpUnpackedEntry()
1187 Expected<section_iterator> SIOrErr = XDataRecord->getSection(); in dumpUnpackedEntry()
1197 SW.printString("ExceptionRecord", formatSymbol("", XDataAddress)); in dumpUnpackedEntry()
1221 Expected<StringRef> FunctionNameOrErr = Function->getName(); in dumpPackedEntry()
1231 SW.printString("Function", in dumpPackedEntry()
1233 SW.printBoolean("Fragment", in dumpPackedEntry()
1235 SW.printNumber("FunctionLength", RF.FunctionLength()); in dumpPackedEntry()
1236 SW.startLine() << "ReturnType: " << RF.Ret() << '\n'; in dumpPackedEntry()
1237 SW.printBoolean("HomedParameters", RF.H()); in dumpPackedEntry()
1238 SW.printNumber("Reg", RF.Reg()); in dumpPackedEntry()
1239 SW.printNumber("R", RF.R()); in dumpPackedEntry()
1240 SW.printBoolean("LinkRegister", RF.L()); in dumpPackedEntry()
1241 SW.printBoolean("Chaining", RF.C()); in dumpPackedEntry()
1242 SW.printNumber("StackAdjustment", StackAdjustment(RF) << 2); in dumpPackedEntry()
1245 ListScope PS(SW, "Prologue"); in dumpPackedEntry()
1251 SW.startLine() << "sub sp, sp, #" << StackAdjustment(RF) * 4 << "\n"; in dumpPackedEntry()
1253 SW.startLine() << "vpush "; in dumpPackedEntry()
1259 int FpOffset = 4 * llvm::popcount(GPRMask & ((1U << 11) - 1)); in dumpPackedEntry()
1261 SW.startLine() << "add.w r11, sp, #" << FpOffset << "\n"; in dumpPackedEntry()
1263 SW.startLine() << "mov r11, sp\n"; in dumpPackedEntry()
1266 SW.startLine() << "push "; in dumpPackedEntry()
1271 SW.startLine() << "push {r0-r3}\n"; in dumpPackedEntry()
1275 ListScope PS(SW, "Epilogue"); in dumpPackedEntry()
1281 SW.startLine() << "add sp, sp, #" << StackAdjustment(RF) * 4 << "\n"; in dumpPackedEntry()
1283 SW.startLine() << "vpop "; in dumpPackedEntry()
1288 SW.startLine() << "pop "; in dumpPackedEntry()
1294 SW.startLine() << "add sp, sp, #16\n"; in dumpPackedEntry()
1296 SW.startLine() << "ldr pc, [sp], #20\n"; in dumpPackedEntry()
1299 SW.startLine() << RF.Ret() << '\n'; in dumpPackedEntry()
1320 Expected<StringRef> FunctionNameOrErr = Function->getName(); in dumpPackedARM64Entry()
1330 SW.printString("Function", in dumpPackedARM64Entry()
1332 SW.printBoolean("Fragment", in dumpPackedARM64Entry()
1334 SW.printNumber("FunctionLength", RF.FunctionLength()); in dumpPackedARM64Entry()
1335 SW.printNumber("RegF", RF.RegF()); in dumpPackedARM64Entry()
1336 SW.printNumber("RegI", RF.RegI()); in dumpPackedARM64Entry()
1337 SW.printBoolean("HomedParameters", RF.H()); in dumpPackedARM64Entry()
1338 SW.printNumber("CR", RF.CR()); in dumpPackedARM64Entry()
1339 SW.printNumber("FrameSize", RF.FrameSize() << 4); in dumpPackedARM64Entry()
1340 ListScope PS(SW, "Prologue"); in dumpPackedARM64Entry()
1343 // at https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling, in dumpPackedARM64Entry()
1345 // are printed for the non-packed case. in dumpPackedARM64Entry()
1353 int LocSZ = (RF.FrameSize() << 4) - SavSZ; in dumpPackedARM64Entry()
1356 SW.startLine() << "mov x29, sp\n"; in dumpPackedARM64Entry()
1358 SW.startLine() << format("stp x29, lr, [sp, #-%d]!\n", LocSZ); in dumpPackedARM64Entry()
1360 SW.startLine() << "stp x29, lr, [sp, #0]\n"; in dumpPackedARM64Entry()
1364 SW.startLine() << format("sub sp, sp, #%d\n", LocSZ - 4080); in dumpPackedARM64Entry()
1365 SW.startLine() << "sub sp, sp, #4080\n"; in dumpPackedARM64Entry()
1367 SW.startLine() << format("sub sp, sp, #%d\n", LocSZ); in dumpPackedARM64Entry()
1370 SW.startLine() << format("stp x6, x7, [sp, #%d]\n", SavSZ - 16); in dumpPackedARM64Entry()
1371 SW.startLine() << format("stp x4, x5, [sp, #%d]\n", SavSZ - 32); in dumpPackedARM64Entry()
1372 SW.startLine() << format("stp x2, x3, [sp, #%d]\n", SavSZ - 48); in dumpPackedARM64Entry()
1374 SW.startLine() << format("stp x0, x1, [sp, #%d]\n", SavSZ - 64); in dumpPackedARM64Entry()
1379 SW.startLine() << format("stp x0, x1, [sp, #-%d]!\n", SavSZ); in dumpPackedARM64Entry()
1383 for (int I = (FloatRegs + 1) / 2 - 1; I >= 0; I--) { in dumpPackedARM64Entry()
1384 if (I == (FloatRegs + 1) / 2 - 1 && FloatRegs % 2 == 1) { in dumpPackedARM64Entry()
1386 SW.startLine() << format("str d%d, [sp, #%d]\n", 8 + 2 * I, in dumpPackedARM64Entry()
1389 SW.startLine() << format("stp d%d, d%d, [sp, #-%d]!\n", 8 + 2 * I, in dumpPackedARM64Entry()
1392 SW.startLine() << format("stp d%d, d%d, [sp, #%d]\n", 8 + 2 * I, in dumpPackedARM64Entry()
1398 SW.startLine() << format("str lr, [sp, #-%d]!\n", SavSZ); in dumpPackedARM64Entry()
1400 SW.startLine() << format("str lr, [sp, #%d]\n", IntSZ - 8); in dumpPackedARM64Entry()
1402 for (int I = (RF.RegI() + 1) / 2 - 1; I >= 0; I--) { in dumpPackedARM64Entry()
1403 if (I == (RF.RegI() + 1) / 2 - 1 && RF.RegI() % 2 == 1) { in dumpPackedARM64Entry()
1410 SW.startLine() << "INVALID!\n"; in dumpPackedARM64Entry()
1412 SW.startLine() << format("stp x%d, lr, [sp, #%d]\n", 19 + 2 * I, in dumpPackedARM64Entry()
1416 SW.startLine() << format("str x%d, [sp, #-%d]!\n", 19 + 2 * I, SavSZ); in dumpPackedARM64Entry()
1418 SW.startLine() << format("str x%d, [sp, #%d]\n", 19 + 2 * I, 16 * I); in dumpPackedARM64Entry()
1422 SW.startLine() << format("stp x19, x20, [sp, #-%d]!\n", SavSZ); in dumpPackedARM64Entry()
1424 SW.startLine() << format("stp x%d, x%d, [sp, #%d]\n", 19 + 2 * I, in dumpPackedARM64Entry()
1429 // https://github.com/MicrosoftDocs/cpp-docs/pull/4202 for upstream in dumpPackedARM64Entry()
1432 SW.startLine() << "pacibsp\n"; in dumpPackedARM64Entry()
1433 SW.startLine() << "end\n"; in dumpPackedARM64Entry()
1446 DictScope RFS(SW, "RuntimeFunction"); in dumpProcedureDataEntry()
1463 errs() << ".pdata content is not " << PDataEntrySize << "-byte aligned\n"; in dumpProcedureData()
1479 if (NameOrErr->starts_with(".pdata")) in dumpProcedureData()