This is an archive of the discontinued LLVM Phabricator instance.

[MCInstrDesc] [TableGen] Reduce size of MCOperandInfo instances
ClosedPublic

Authored by Paul-C-Anagnostopoulos on Dec 15 2020, 11:32 AM.

Details

Summary

This patch reduces the size of the MCOperandInfo instances. The Constraints member is reduced to 16 bits, since it contains only two values of 5 bits each. This leaves room for one more constraint before the member needs to be enlarged to 32 bits.

The next step is to reduce the size of MCInstrDesc instances. But that means changing pointers to indexes, which might get some pushback.

Diff Detail

Event Timeline

Paul-C-Anagnostopoulos requested review of this revision.Dec 15 2020, 11:32 AM
Paul-C-Anagnostopoulos created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2020, 11:32 AM
craig.topper added inline comments.Dec 15 2020, 12:31 PM
llvm/include/llvm/MC/MCInstrDesc.h
43

What is "bit" here? There's no data associated with EARLY_CLOBBER. The original code just did (1 << MCOI::EARLY_CLOBBER) to set the flag, there was nothing in the upper bits.

llvm/utils/TableGen/InstrInfoEmitter.cpp
186

Drop commented out code?

Cleaned out the commented-out code.

I will auto-LGTM this early next week.

Let's try this again.

I don't think auto-LGTM is consistent with LLVM's code review policy. https://llvm.org/docs/CodeReview.html#code-review-workflow @dblaikie raised this on another review recently https://reviews.llvm.org/D92514

llvm/include/llvm/MC/MCInstrDesc.h
43

What about this?

I've been doing it for documentation changes, commenting, and certain other relatively trivial changes, That was suggested by @lattner, not decided unilaterally.

You are right, though, that this is not trivial, so I withdraw my auto-LGTM comment.

llvm/include/llvm/MC/MCInstrDesc.h
43

All the calls to get the EARLY_CLOBBER constraint only check for -1, the value returned when the constraint is not present. So it's a boolean, but based on its presence rather than its value. That seemed odd to me, so my plan is to change the calls to check for =1 rather than !=-1.

I could be convinced that presence/absence is a perfectly good boolean.

llvm/utils/TableGen/InstrInfoEmitter.cpp
186

Oh yes, I will clean out the old code.

llvm/include/llvm/MC/MCInstrDesc.h
43

I was going to wait to make the =1 change until after this is pushed. Do you think I should do it now?

craig.topper added inline comments.Dec 19 2020, 2:11 PM
llvm/include/llvm/MC/MCInstrDesc.h
43

I think I must have wrote my comment at the same time you were writing yours.

I think this patch should keep just (1 << MCOI::EARLY_CLOBBER) and not have the bit argument. That would be consistent with what tablegen is doing before this patch.

llvm/include/llvm/MC/MCInstrDesc.h
43

I will do that, but with the MCOI_EARLY_CLOBBER macro. That keeps all the weird bit field positions, sizes, and shifting in the header file.

This comment was removed by Paul-C-Anagnostopoulos.

Change early clobber so its presence is all that matters.

craig.topper accepted this revision.Dec 20 2020, 11:56 AM

LGTM, thanks!

This revision is now accepted and ready to land.Dec 20 2020, 11:56 AM