Lines Matching +full:- +full:rf
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 // +---------------------------------------+
36 // the associated exception handler. Additionally, the entry contains byte-code
39 // +---------------------------------------+
41 // +---------------------------------------+
43 // +---------------------------------------+
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();
376 | (((1 << (Count + 1)) - 1) << 4);
393 | (((1 << (Count + 1)) - 1) << 4);
407 uint32_t VFPMask = (((1 << (High + 1)) - 1) << 8);
454 << format("0x%02x 0x%02x ; microsoft-specific (type: %u)\n",
468 << format("0x%02x 0x%02x ; str.w lr, [sp, #-%u]!\n",
483 uint32_t VFPMask = ((1 << (End + 1 - Start)) - 1) << Start;
498 uint32_t VFPMask = ((1 << (End + 1 - Start)) - 1) << (16 + Start);
615 "0x%02x ; stp x19, x20, [sp, #-%u]!\n", OC[Offset], Off);
638 "0x%02x ; stp x29, x30, [sp, #-%u]!\n", OC[Offset], Off);
683 "0x%02x%02x ; stp x%u, x%u, [sp, #-%u]!\n",
718 SW.startLine() << format("0x%02x%02x ; str x%u, [sp, #-%u]!\n",
767 "0x%02x%02x ; stp d%u, d%u, [sp, #-%u]!\n", OC[Offset],
798 "0x%02x%02x ; str d%u, [sp, #-%u]!\n", OC[Offset],
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.)
905 --MaxReg;
907 --MaxReg;
940 SW.getOStream() << format("[sp, #-%d]!\n", StackOffset);
1021 (this->*DecodeRing[DI].Routine)(Opcodes.data(), OI, 0, Prologue);
1036 uint64_t Offset = VA - SectionVA;
1043 if (Contents.size() - Offset < 8)
1061 if ((int64_t)(Contents.size() - Offset - 4 * HeaderWords(XData) -
1062 (XData.E() ? 0 : XData.EpilogueCount() * 4) -
1123 Expected<StringRef> Name = Symbol->getName();
1141 unsigned Index, const RuntimeFunction &RF) {
1142 assert(RF.Flag() == RuntimeFunctionFlag::RFF_Unpacked &&
1147 COFF, Section, Offset, RF.BeginAddress, FunctionAddress, FunctionOffset,
1152 COFF, Section, Offset + 4, RF.ExceptionInformationRVA(), XDataAddress,
1155 if (!RF.BeginAddress && !Function)
1157 if (!RF.UnwindData && !XDataRecord)
1162 Expected<StringRef> FunctionNameOrErr = Function->getName();
1176 Expected<StringRef> Name = XDataRecord->getName();
1187 Expected<section_iterator> SIOrErr = XDataRecord->getSection();
1209 unsigned Index, const RuntimeFunction &RF) {
1210 assert((RF.Flag() == RuntimeFunctionFlag::RFF_Packed ||
1211 RF.Flag() == RuntimeFunctionFlag::RFF_PackedFragment) &&
1216 COFF, Section, Offset, RF.BeginAddress, FunctionAddress, FunctionOffset,
1221 Expected<StringRef> FunctionNameOrErr = Function->getName();
1234 RF.Flag() == RuntimeFunctionFlag::RFF_PackedFragment);
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);
1248 std::tie(GPRMask, VFPMask) = SavedRegisterMask(RF, /*Prologue=*/true);
1250 if (StackAdjustment(RF) && !PrologueFolding(RF))
1251 SW.startLine() << "sub sp, sp, #" << StackAdjustment(RF) * 4 << "\n";
1257 if (RF.C()) {
1259 int FpOffset = 4 * llvm::popcount(GPRMask & ((1U << 11) - 1));
1270 if (RF.H())
1271 SW.startLine() << "push {r0-r3}\n";
1274 if (RF.Ret() != ReturnType::RT_NoEpilogue) {
1278 std::tie(GPRMask, VFPMask) = SavedRegisterMask(RF, /*Prologue=*/false);
1280 if (StackAdjustment(RF) && !EpilogueFolding(RF))
1281 SW.startLine() << "add sp, sp, #" << StackAdjustment(RF) * 4 << "\n";
1292 if (RF.H()) {
1293 if (RF.L() == 0 || RF.Ret() != ReturnType::RT_POP)
1298 if (RF.Ret() != ReturnType::RT_POP)
1299 SW.startLine() << RF.Ret() << '\n';
1308 const RuntimeFunctionARM64 &RF) {
1309 assert((RF.Flag() == RuntimeFunctionFlag::RFF_Packed ||
1310 RF.Flag() == RuntimeFunctionFlag::RFF_PackedFragment) &&
1315 COFF, Section, Offset, RF.BeginAddress, FunctionAddress, FunctionOffset,
1320 Expected<StringRef> FunctionNameOrErr = Function->getName();
1333 RF.Flag() == RuntimeFunctionFlag::RFF_PackedFragment);
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);
1343 // at https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling,
1345 // are printed for the non-packed case.
1346 int IntSZ = 8 * RF.RegI();
1347 if (RF.CR() == 1)
1349 int FpSZ = 8 * RF.RegF();
1350 if (RF.RegF())
1352 int SavSZ = (IntSZ + FpSZ + 8 * 8 * RF.H() + 0xf) & ~0xf;
1353 int LocSZ = (RF.FrameSize() << 4) - SavSZ;
1355 if (RF.CR() == 2 || RF.CR() == 3) {
1358 SW.startLine() << format("stp x29, lr, [sp, #-%d]!\n", LocSZ);
1364 SW.startLine() << format("sub sp, sp, #%d\n", LocSZ - 4080);
1366 } else if ((RF.CR() != 3 && RF.CR() != 2 && LocSZ > 0) || LocSZ > 512) {
1369 if (RF.H()) {
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);
1373 if (RF.RegI() > 0 || RF.RegF() > 0 || RF.CR() == 1) {
1374 SW.startLine() << format("stp x0, x1, [sp, #%d]\n", SavSZ - 64);
1379 SW.startLine() << format("stp x0, x1, [sp, #-%d]!\n", SavSZ);
1382 int FloatRegs = RF.RegF() > 0 ? RF.RegF() + 1 : 0;
1383 for (int I = (FloatRegs + 1) / 2 - 1; I >= 0; I--) {
1384 if (I == (FloatRegs + 1) / 2 - 1 && FloatRegs % 2 == 1) {
1388 } else if (I == 0 && RF.RegI() == 0 && RF.CR() != 1) {
1389 SW.startLine() << format("stp d%d, d%d, [sp, #-%d]!\n", 8 + 2 * I,
1396 if (RF.CR() == 1 && (RF.RegI() % 2) == 0) {
1397 if (RF.RegI() == 0)
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) {
1405 if (RF.CR() == 1) {
1416 SW.startLine() << format("str x%d, [sp, #-%d]!\n", 19 + 2 * I, SavSZ);
1422 SW.startLine() << format("stp x19, x20, [sp, #-%d]!\n", SavSZ);
1429 // https://github.com/MicrosoftDocs/cpp-docs/pull/4202 for upstream
1431 if (RF.CR() == 2)
1463 errs() << ".pdata content is not " << PDataEntrySize << "-byte aligned\n";
1479 if (NameOrErr->starts_with(".pdata"))