Skip to content

Commit 5e3fa84

Browse files
committed
[WIP][AArch64] Support CodeView debug info with SVE.
From quick testing, there are two major things that need to be added to make the debug info work: one, we need to encode the register numbers themselves into the debug info, and two, we need to be able to encode the offsets of SVE variables on the stack. This patch adds hacks for both, as a demonstration of what's required. Hopefully we can do better... but this is better than nothing.
1 parent 1814b32 commit 5e3fa84

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,12 +1278,14 @@ void CodeViewDebug::collectVariableInfoFromMFTable(
12781278
TFI->getFrameIndexReference(*Asm->MF, VI.getStackSlot(), FrameReg);
12791279
uint16_t CVReg = TRI->getCodeViewRegNum(FrameReg);
12801280

1281-
assert(!FrameOffset.getScalable() &&
1282-
"Frame offsets with a scalable component are not supported");
1281+
// FIXME: Assume the scale factor is one, to avoid crashing. We can fix
1282+
// once we have information on the correct encoding.
1283+
uint64_t FrameOffsetFixed =
1284+
FrameOffset.getFixed() + FrameOffset.getScalable();
12831285

12841286
// Calculate the label ranges.
12851287
LocalVarDef DefRange =
1286-
createDefRangeMem(CVReg, FrameOffset.getFixed() + ExprOffset);
1288+
createDefRangeMem(CVReg, FrameOffsetFixed + ExprOffset);
12871289

12881290
LocalVariable Var;
12891291
Var.DIVar = VI.Var;

llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,41 @@ void AArch64_MC::initLLVMToCVRegMapping(MCRegisterInfo *MRI) {
298298
{codeview::RegisterId::ARM64_H29, AArch64::H29},
299299
{codeview::RegisterId::ARM64_H30, AArch64::H30},
300300
{codeview::RegisterId::ARM64_H31, AArch64::H31},
301+
// FIXME: Temporarily map Z registers using Q register IDs until we
302+
// get the actual numbers.
303+
{codeview::RegisterId::ARM64_Q0, AArch64::Z0},
304+
{codeview::RegisterId::ARM64_Q1, AArch64::Z1},
305+
{codeview::RegisterId::ARM64_Q2, AArch64::Z2},
306+
{codeview::RegisterId::ARM64_Q3, AArch64::Z3},
307+
{codeview::RegisterId::ARM64_Q4, AArch64::Z4},
308+
{codeview::RegisterId::ARM64_Q5, AArch64::Z5},
309+
{codeview::RegisterId::ARM64_Q6, AArch64::Z6},
310+
{codeview::RegisterId::ARM64_Q7, AArch64::Z7},
311+
{codeview::RegisterId::ARM64_Q8, AArch64::Z8},
312+
{codeview::RegisterId::ARM64_Q9, AArch64::Z9},
313+
{codeview::RegisterId::ARM64_Q10, AArch64::Z10},
314+
{codeview::RegisterId::ARM64_Q11, AArch64::Z11},
315+
{codeview::RegisterId::ARM64_Q12, AArch64::Z12},
316+
{codeview::RegisterId::ARM64_Q13, AArch64::Z13},
317+
{codeview::RegisterId::ARM64_Q14, AArch64::Z14},
318+
{codeview::RegisterId::ARM64_Q15, AArch64::Z15},
319+
{codeview::RegisterId::ARM64_Q16, AArch64::Z16},
320+
{codeview::RegisterId::ARM64_Q17, AArch64::Z17},
321+
{codeview::RegisterId::ARM64_Q18, AArch64::Z18},
322+
{codeview::RegisterId::ARM64_Q19, AArch64::Z19},
323+
{codeview::RegisterId::ARM64_Q20, AArch64::Z20},
324+
{codeview::RegisterId::ARM64_Q21, AArch64::Z21},
325+
{codeview::RegisterId::ARM64_Q22, AArch64::Z22},
326+
{codeview::RegisterId::ARM64_Q23, AArch64::Z23},
327+
{codeview::RegisterId::ARM64_Q24, AArch64::Z24},
328+
{codeview::RegisterId::ARM64_Q25, AArch64::Z25},
329+
{codeview::RegisterId::ARM64_Q26, AArch64::Z26},
330+
{codeview::RegisterId::ARM64_Q27, AArch64::Z27},
331+
{codeview::RegisterId::ARM64_Q28, AArch64::Z28},
332+
{codeview::RegisterId::ARM64_Q29, AArch64::Z29},
333+
{codeview::RegisterId::ARM64_Q30, AArch64::Z30},
334+
{codeview::RegisterId::ARM64_Q31, AArch64::Z31},
335+
301336
};
302337
for (const auto &I : RegMap)
303338
MRI->mapLLVMRegToCVReg(I.Reg, static_cast<int>(I.CVReg));

0 commit comments

Comments
 (0)