This is an archive of the discontinued LLVM Phabricator instance.

TargetInstrInfo: add virtual function GetInstSizeInBytes
ClosedPublic

Authored by SjoerdMeijer on Jul 27 2016, 1:21 PM.

Details

Summary

This adds virtual function GetInstSizeInBytes to TargetInstrInfo that a lot of subclasses already implement.

Diff Detail

Event Timeline

SjoerdMeijer retitled this revision from to TargetInstrInfo: add virtual function GetInstSizeInBytes.
SjoerdMeijer updated this object.
SjoerdMeijer added a subscriber: llvm-commits.
arsenm added a subscriber: arsenm.Jul 27 2016, 1:31 PM
arsenm added inline comments.
include/llvm/Target/TargetInstrInfo.h
255

This should start with a lowercase letter. It should also have a default implementation of llvm_unreachable since I don't think guessing 4 is a reasonable default

jmolloy requested changes to this revision.Jul 27 2016, 1:32 PM
jmolloy edited edge metadata.

This needs to have a conservatively correct return value or an 'unimplemented' sentinel value. 4 is not a correct assumption to make.

Cheers,

James

This revision now requires changes to proceed.Jul 27 2016, 1:32 PM
SjoerdMeijer edited edge metadata.

Thanks for reviewing.
I have added llvm_unreachable as the default implementation instead of 4.
Can we keep the function name that starts with a capital letter because that's the function that 6 targets already implement?

Thanks for reviewing.
I have added llvm_unreachable as the default implementation instead of 4.
Can we keep the function name that starts with a capital letter because that's the function that 6 targets already implement?

You have to touch all of them anyway to add the overrides, so might as well fix the name while you're at it

Ok, thanks, will do. And I actually need to double check if the "unreachable" solves my problem, or if I need to come up with a better default int value.

SjoerdMeijer edited edge metadata.

I have 1) changed the default value to ~0U, 2) renamed the function name to use a lowercase letter, and 3) added "override" to the different subclasses

jmolloy added inline comments.Jul 28 2016, 3:11 AM
include/llvm/Target/TargetInstrInfo.h
253

You must document the ~0U sentinel and what it means. Also mention that the unit is "bytes".

Thanks, that has been fixed.

The renaming is in a separate commit: https://reviews.llvm.org/D22925.
When that is accepted/committed, I will continue here with the functional change.

This now only implements the functional change to add getInstSizeInBytes to TargetInstrInfo.

arsenm accepted this revision.Jul 28 2016, 5:45 PM
arsenm added a reviewer: arsenm.

AMDGPU needs an override added in SIInstrInfo.h. LGTM with that fixed

This revision was automatically updated to reflect the committed changes.

I have fixed that and committed. Thanks!