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;
189 int First = -1;
196 printRange(OS, LS, First, RI - 1, Letter);
197 First = -1;
229 if (VA >= Address && (VA - Address) <= Size)
278 uint32_t Offset = CoffSym.getValue() + SymbolOffset - CS.getValue();
303 Expected<uint64_t> AddressOrErr = SymOrErr->getAddress();
331 SW.startLine() << format("0x%02x ; %s sp, #(%u * 4)\n",
348 SW.startLine() << format("0x%02x 0x%02x ; %s.w ",
361 SW.startLine() << format("0x%02x ; mov r%u, sp\n",
364 SW.startLine() << format("0x%02x ; mov sp, r%u\n",
376 | (((1 << (Count + 1)) - 1) << 4);
378 SW.startLine() << format("0x%02x ; %s ", OC[Offset],
393 | (((1 << (Count + 1)) - 1) << 4);
395 SW.startLine() << format("0x%02x ; %s.w ", OC[Offset],
407 uint32_t VFPMask = (((1 << (High + 1)) - 1) << 8);
409 SW.startLine() << format("0x%02x ; %s ", OC[Offset],
422 SW.startLine() << format("0x%02x 0x%02x ; %s.w sp, #(%u * 4)\n",
436 SW.startLine() << format("0x%02x 0x%02x ; %s ", OC[Offset + 0],
450 SW.startLine() << format("0x%02x 0x%02x ; reserved\n",
453 SW.startLine()
454 << format("0x%02x 0x%02x ; microsoft-specific (type: %u)\n",
464 SW.startLine() << format("0x%02x 0x%02x ; reserved\n",
467 SW.startLine()
468 << format("0x%02x 0x%02x ; str.w lr, [sp, #-%u]!\n",
471 SW.startLine()
483 uint32_t VFPMask = ((1 << (End + 1 - Start)) - 1) << Start;
485 SW.startLine() << format("0x%02x 0x%02x ; %s ", OC[Offset + 0],
498 uint32_t VFPMask = ((1 << (End + 1 - Start)) - 1) << (16 + Start);
500 SW.startLine() << format("0x%02x 0x%02x ; %s ", OC[Offset + 0],
513 SW.startLine() << format("0x%02x 0x%02x 0x%02x ; %s sp, sp, #(%u * 4)\n",
528 SW.startLine()
541 SW.startLine()
556 SW.startLine()
567 SW.startLine() << format("0x%02x ; nop\n", OC[Offset]);
574 SW.startLine() << format("0x%02x ; nop.w\n", OC[Offset]);
581 SW.startLine() << format("0x%02x ; bx <reg>\n", OC[Offset]);
588 SW.startLine() << format("0x%02x ; b.w <target>\n", OC[Offset]);
603 SW.startLine() << format("0x%02x ; %s sp, #%u\n", OC[Offset],
614 SW.startLine() << format(
615 "0x%02x ; stp x19, x20, [sp, #-%u]!\n", OC[Offset], Off);
617 SW.startLine() << format(
626 SW.startLine() << format(
637 SW.startLine() << format(
638 "0x%02x ; stp x29, x30, [sp, #-%u]!\n", OC[Offset], Off);
640 SW.startLine() << format(
651 SW.startLine() << format("0x%02x%02x ; %s sp, #%u\n",
666 SW.startLine() << format(
682 SW.startLine() << format(
683 "0x%02x%02x ; stp x%u, x%u, [sp, #-%u]!\n",
687 SW.startLine() << format(
702 SW.startLine() << format("0x%02x%02x ; %s x%u, [sp, #%u]\n",
718 SW.startLine() << format("0x%02x%02x ; str x%u, [sp, #-%u]!\n",
721 SW.startLine() << format("0x%02x%02x ; ldr x%u, [sp], #%u\n",
735 SW.startLine() << format("0x%02x%02x ; %s x%u, lr, [sp, #%u]\n",
750 SW.startLine() << format("0x%02x%02x ; %s d%u, d%u, [sp, #%u]\n",
766 SW.startLine() << format(
767 "0x%02x%02x ; stp d%u, d%u, [sp, #-%u]!\n", OC[Offset],
770 SW.startLine() << format(
784 SW.startLine() << format("0x%02x%02x ; %s d%u, [sp, #%u]\n",
797 SW.startLine() << format(
798 "0x%02x%02x ; str d%u, [sp, #-%u]!\n", OC[Offset],
801 SW.startLine() << format(
813 SW.startLine() << format(
823 SW.startLine() << format("0x%02x ; mov %s, %s\n", OC[Offset],
833 SW.startLine() << format(
844 SW.startLine() << format("0x%02x ; nop\n", OC[Offset]);
851 SW.startLine() << format("0x%02x ; end\n", OC[Offset]);
858 SW.startLine() << format("0x%02x ; end_c\n", OC[Offset]);
866 SW.startLine() << format("0x%02x ; save next\n", OC[Offset]);
868 SW.startLine() << format("0x%02x ; restore next\n",
882 // - 0 is an x register
883 // - 1 is the low half of a q register
884 // - 2 is a whole q register
886 // Encoded register name (0 -> x0/q0, 1 -> x1/q1, etc.)
897 SW.startLine() << format("0x%02x%02x%02x ; ", OC[Offset],
905 --MaxReg;
907 --MaxReg;
909 SW.getOStream() << "invalid save_any_reg encoding\n";
916 SW.getOStream() << "stp ";
918 SW.getOStream() << "ldp ";
921 SW.getOStream() << "str ";
923 SW.getOStream() << "ldr ";
934 SW.getOStream() << format("%c%d, %c%d, ", RegChar, Reg, RegChar, Reg + 1);
936 SW.getOStream() << format("%c%d, ", RegChar, Reg);
940 SW.getOStream() << format("[sp, #-%d]!\n", StackOffset);
942 SW.getOStream() << format("[sp], #%d\n", StackOffset);
944 SW.getOStream() << format("[sp, #%d]\n", StackOffset);
953 SW.startLine() << format("0x%02x ; trap frame\n", OC[Offset]);
960 SW.startLine() << format("0x%02x ; machine frame\n",
968 SW.startLine() << format("0x%02x ; context\n", OC[Offset]);
975 SW.startLine() << format("0x%02x ; EC context\n", OC[Offset]);
982 SW.startLine() << format("0x%02x ; clear unwound to call\n",
991 SW.startLine() << format("0x%02x ; pacibsp\n", OC[Offset]);
993 SW.startLine() << format("0x%02x ; autibsp\n", OC[Offset]);
1007 SW.startLine() << format("0x%02x ; Bad opcode!\n",
1015 SW.startLine() << format("Opcode 0x%02x goes past the unwind data\n",
1021 (this->*DecodeRing[DI].Routine)(Opcodes.data(), OI, 0, Prologue);
1036 uint64_t Offset = VA - SectionVA;
1043 if (Contents.size() - Offset < 8)
1047 DictScope XRS(SW, "ExceptionData");
1048 SW.printNumber("FunctionLength",
1051 SW.printNumber("Version", XData.Vers());
1052 SW.printBoolean("ExceptionData", XData.X());
1053 SW.printBoolean("EpiloguePacked", XData.E());
1055 SW.printBoolean("Fragment", XData.F());
1056 SW.printNumber(XData.E() ? "EpilogueOffset" : "EpilogueScopes",
1059 SW.printNumber("ByteCodeLength", ByteCodeLength);
1061 if ((int64_t)(Contents.size() - Offset - 4 * HeaderWords(XData) -
1062 (XData.E() ? 0 : XData.EpilogueCount() * 4) -
1064 SW.flush();
1071 ListScope PS(SW, "Prologue");
1075 ListScope ES(SW, "Epilogue");
1080 ListScope PS(SW, "Prologue");
1084 ListScope ESS(SW, "EpilogueScopes");
1086 DictScope ESES(SW, "EpilogueScope");
1087 SW.printNumber("StartOffset", ES.EpilogueStartOffset());
1089 SW.printNumber("Condition", ES.Condition());
1090 SW.printNumber("EpilogueStartIndex",
1095 SW.printNumber("ReservedBits", (ES.ES >> 18) & ReservedMask);
1097 ListScope Opcodes(SW, "Opcodes");
1117 ListScope EHS(SW, "ExceptionHandler");
1118 SW.printHex("Routine", Address);
1119 SW.printHex("Parameter", Parameter);
1123 Expected<StringRef> Name = Symbol->getName();
1131 ListScope EHS(SW, "ExceptionHandler");
1132 SW.printString("Routine", formatSymbol(*Name, Address, SymbolOffset));
1133 SW.printHex("Parameter", Parameter);
1162 Expected<StringRef> FunctionNameOrErr = Function->getName();
1172 SW.printString("Function",
1176 Expected<StringRef> Name = XDataRecord->getName();
1184 SW.printString("ExceptionRecord",
1187 Expected<section_iterator> SIOrErr = XDataRecord->getSection();
1197 SW.printString("ExceptionRecord", formatSymbol("", XDataAddress));
1221 Expected<StringRef> FunctionNameOrErr = Function->getName();
1231 SW.printString("Function",
1233 SW.printBoolean("Fragment",
1235 SW.printNumber("FunctionLength", RF.FunctionLength());
1236 SW.startLine() << "ReturnType: " << RF.Ret() << '\n';
1237 SW.printBoolean("HomedParameters", RF.H());
1238 SW.printNumber("Reg", RF.Reg());
1239 SW.printNumber("R", RF.R());
1240 SW.printBoolean("LinkRegister", RF.L());
1241 SW.printBoolean("Chaining", RF.C());
1242 SW.printNumber("StackAdjustment", StackAdjustment(RF) << 2);
1245 ListScope PS(SW, "Prologue");
1251 SW.startLine() << "sub sp, sp, #" << StackAdjustment(RF) * 4 << "\n";
1253 SW.startLine() << "vpush ";
1259 int FpOffset = 4 * llvm::popcount(GPRMask & ((1U << 11) - 1));
1261 SW.startLine() << "add.w r11, sp, #" << FpOffset << "\n";
1263 SW.startLine() << "mov r11, sp\n";
1266 SW.startLine() << "push ";
1271 SW.startLine() << "push {r0-r3}\n";
1275 ListScope PS(SW, "Epilogue");
1281 SW.startLine() << "add sp, sp, #" << StackAdjustment(RF) * 4 << "\n";
1283 SW.startLine() << "vpop ";
1288 SW.startLine() << "pop ";
1294 SW.startLine() << "add sp, sp, #16\n";
1296 SW.startLine() << "ldr pc, [sp], #20\n";
1299 SW.startLine() << RF.Ret() << '\n';
1320 Expected<StringRef> FunctionNameOrErr = Function->getName();
1330 SW.printString("Function",
1332 SW.printBoolean("Fragment",
1334 SW.printNumber("FunctionLength", RF.FunctionLength());
1335 SW.printNumber("RegF", RF.RegF());
1336 SW.printNumber("RegI", RF.RegI());
1337 SW.printBoolean("HomedParameters", RF.H());
1338 SW.printNumber("CR", RF.CR());
1339 SW.printNumber("FrameSize", RF.FrameSize() << 4);
1340 ListScope PS(SW, "Prologue");
1343 // at https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling,
1345 // are printed for the non-packed case.
1353 int LocSZ = (RF.FrameSize() << 4) - SavSZ;
1356 SW.startLine() << "mov x29, sp\n";
1358 SW.startLine() << format("stp x29, lr, [sp, #-%d]!\n", LocSZ);
1360 SW.startLine() << "stp x29, lr, [sp, #0]\n";
1364 SW.startLine() << format("sub sp, sp, #%d\n", LocSZ - 4080);
1365 SW.startLine() << "sub sp, sp, #4080\n";
1367 SW.startLine() << format("sub sp, sp, #%d\n", LocSZ);
1370 SW.startLine() << format("stp x6, x7, [sp, #%d]\n", SavSZ - 16);
1371 SW.startLine() << format("stp x4, x5, [sp, #%d]\n", SavSZ - 32);
1372 SW.startLine() << format("stp x2, x3, [sp, #%d]\n", SavSZ - 48);
1374 SW.startLine() << format("stp x0, x1, [sp, #%d]\n", SavSZ - 64);
1379 SW.startLine() << format("stp x0, x1, [sp, #-%d]!\n", SavSZ);
1383 for (int I = (FloatRegs + 1) / 2 - 1; I >= 0; I--) {
1384 if (I == (FloatRegs + 1) / 2 - 1 && FloatRegs % 2 == 1) {
1386 SW.startLine() << format("str d%d, [sp, #%d]\n", 8 + 2 * I,
1389 SW.startLine() << format("stp d%d, d%d, [sp, #-%d]!\n", 8 + 2 * I,
1392 SW.startLine() << format("stp d%d, d%d, [sp, #%d]\n", 8 + 2 * I,
1398 SW.startLine() << format("str lr, [sp, #-%d]!\n", SavSZ);
1400 SW.startLine() << format("str lr, [sp, #%d]\n", IntSZ - 8);
1402 for (int I = (RF.RegI() + 1) / 2 - 1; I >= 0; I--) {
1403 if (I == (RF.RegI() + 1) / 2 - 1 && RF.RegI() % 2 == 1) {
1410 SW.startLine() << "INVALID!\n";
1412 SW.startLine() << format("stp x%d, lr, [sp, #%d]\n", 19 + 2 * I,
1416 SW.startLine() << format("str x%d, [sp, #-%d]!\n", 19 + 2 * I, SavSZ);
1418 SW.startLine() << format("str x%d, [sp, #%d]\n", 19 + 2 * I, 16 * I);
1422 SW.startLine() << format("stp x19, x20, [sp, #-%d]!\n", SavSZ);
1424 SW.startLine() << format("stp x%d, x%d, [sp, #%d]\n", 19 + 2 * I,
1429 // https://github.com/MicrosoftDocs/cpp-docs/pull/4202 for upstream
1432 SW.startLine() << "pacibsp\n";
1433 SW.startLine() << "end\n";
1446 DictScope RFS(SW, "RuntimeFunction");
1463 errs() << ".pdata content is not " << PDataEntrySize << "-byte aligned\n";
1479 if (NameOrErr->starts_with(".pdata"))