This is an archive of the discontinued LLVM Phabricator instance.

Emit <regmask R1 R2 R3 ...> instead of just <regmask> in IR dumps.
ClosedPublic

Authored by dsanders on Jul 30 2015, 6:22 AM.

Diff Detail

Event Timeline

dsanders updated this revision to Diff 31022.Jul 30 2015, 6:22 AM
dsanders retitled this revision from to Emit <regmask R1 R2 R3 ...> instead of just <regmask> in IR dumps..
dsanders updated this object.
dsanders added a subscriber: llvm-commits.

Hi Daniel,

Sometimes masks are quite big. I wonder if this behavior should be behind a flag, maybe on by default though.

Cheers,
-Quentin

lib/CodeGen/MachineInstr.cpp
420

I would have expected the loop to look a bit differently to avoid the divide and modulo:
const uint32_t *MaskWord = getRegMask();
unsigned BaseIdx = 0;
for (; MaskWord; ++MaskWord, BaseIdx += 32) {

for (unsigned Idx = BaseIdx; Offset < BaseIdx + 32; ++Offset)
  OS << " " << PrintReg(Idx, TRI);

}

Sometimes masks are quite big. I wonder if this behavior should be behind a flag, maybe on by default though.

Ok. I'll post an updated patch that adds an option shortly.

lib/CodeGen/MachineInstr.cpp
420

A good compiler will reduce the divide and modulo to 'x>>5' and 'x&31', but I thought it was clearer to use 'x/32' and 'x%32' in the source.

const uint32_t *MaskWord = getRegMask();
unsigned BaseIdx = 0;
for (; MaskWord; ++MaskWord, BaseIdx += 32) {

for (unsigned Idx = BaseIdx; Offset < BaseIdx + 32; ++Offset)
  OS << " " << PrintReg(Idx, TRI);

}

I don't think this loop works correctly. The array can have runs of zero words inside it and is not guaranteed to end in a zero word.

kparzysz added a subscriber: kparzysz.EditedAug 13 2015, 9:02 AM

Or it can print up to a certain number of registers (by default) followed by ..., e.g <regmask R1 R2 R3 R4 R5 ...>. Then an option could be used to print all of them.

Edit: I just noticed that the title of the page shows the regmask in exactly that form (the actual code does not, though).

qcolombet added inline comments.Aug 13 2015, 9:04 AM
lib/CodeGen/MachineInstr.cpp
420

I don't think this loop works correctly. The array can have runs of zero words inside it and is not guaranteed to end in a zero word.

Of course, you’re right. I must have mixed that with another API :).

dsanders updated this revision to Diff 32396.Aug 18 2015, 3:13 AM

Add an option to print the whole regmask (currently on by default but I don't
mind either way). When disabled, the first 10 will be printed followed by
"and %d more...".

qcolombet accepted this revision.Aug 18 2015, 10:20 AM
qcolombet added a reviewer: qcolombet.

Hi Daniel,

LGTM.

Thanks,
-Quentin

This revision is now accepted and ready to land.Aug 18 2015, 10:20 AM
dsanders closed this revision.Aug 19 2015, 5:03 AM