This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Make getInstSizeInBytes() use instruction size from InstrInfo.td
ClosedPublic

Authored by tyb0807 on Jan 22 2022, 2:56 PM.

Details

Summary

Currently, AArch64InstrInfo::getInstSizeInBytes() uses hard-coded
instruction size for some pseudo-instructions, while this
information should ideally be found in AArch64InstrInfo.td file (which
can be accessed via MCInstrDesc). Hence, the .td file should be updated
and no hard-coded instruction sizes should be used by
getInstSizeInBytes() anymore.

Diff Detail

Event Timeline

tyb0807 created this revision.Jan 22 2022, 2:56 PM
tyb0807 requested review of this revision.Jan 22 2022, 2:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 22 2022, 2:56 PM
tyb0807 updated this revision to Diff 402373.Jan 23 2022, 2:23 PM

Add tests for SPACE and STATEPOINT pseudo-instructions

tyb0807 updated this revision to Diff 402375.Jan 23 2022, 2:39 PM
tyb0807 edited the summary of this revision. (Show Details)

Update commit message to better describe the context

lenary added inline comments.Jan 24 2022, 2:59 AM
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
119

I am slighly concerned about losing these comments - could you move them to the tablegen too (as the tablegen also doesn't tell us what they're eventually lowered to)

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
97–100

should this case become llvm_unreachable now?

119

+1

Also, perhaps a comment at the top of this switch to prefer setting a Size for new insts in llvm/lib/Target/AArch64/AArch64InstrInfo.td when possible?

tyb0807 marked 2 inline comments as done.Jan 24 2022, 2:38 PM
tyb0807 added inline comments.
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
97–100

Well, this is actually handling cases where the fixed constant size is not specified in .td file. I think the intention was to assume that a pseudo-instruction w/o specified size is always expanded to a 4-byte instruction. Is this correct?

tyb0807 updated this revision to Diff 402672.Jan 24 2022, 2:40 PM

Add comments about fixed constant size pseudo-instructions in .td file.

tyb0807 updated this revision to Diff 402808.Jan 25 2022, 2:19 AM

Move the tablegen querying to the default case to make the code consistent with
ARM version. Update the comment accordingly to clarify the intention of the code

Matt added a subscriber: Matt.Jan 25 2022, 3:12 PM

I'm concerned there is no test coverage for:

  • SpeculationBarrierISBDSBEndBB and SpeculationBarrierSBEndBB
  • StoreSwiftAsyncContext
  • JumpTableDest{32,16,8}
tyb0807 updated this revision to Diff 404603.Jan 31 2022, 10:29 AM

Add more tests

This revision was not accepted when it landed; it landed in state Needs Review.Feb 1 2022, 2:39 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
lenary added a comment.Feb 1 2022, 3:31 AM

This was landed accidentally before it was approved, but given @tyb0807 had made the changes I asked, I have not asked him to revert it. I've given Post-commit approval on the specific commit.