This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Add APInt/MathExtras isShiftedMask variant returning mask offset/length
ClosedPublic

Authored by RKSimon on Feb 4 2022, 10:06 AM.

Details

Summary

In many cases, calls to isShiftedMask are immediately followed with checks to determine the size and position of the bitmask.

This patch adds variants of APInt::isShiftedMask, isShiftedMask_32 and isShiftedMask_64 that return these values as additional arguments.

I've updated a number of cases that were either performing seperate size/position calculations or had created their own local wrapper versions of these.

Diff Detail

Event Timeline

RKSimon created this revision.Feb 4 2022, 10:06 AM
RKSimon requested review of this revision.Feb 4 2022, 10:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2022, 10:06 AM
foad added inline comments.Feb 4 2022, 11:19 AM
llvm/include/llvm/ADT/APInt.h
499

Should probably say it's a non-empty sequence of ones, like you do in MathExtras.

RKSimon updated this revision to Diff 406076.Feb 4 2022, 12:40 PM

Update APInt::isShiftedMask description

RKSimon marked an inline comment as done.Feb 4 2022, 12:40 PM
nikic accepted this revision.Feb 8 2022, 2:30 AM

LGTM

This revision is now accepted and ready to land.Feb 8 2022, 2:30 AM
This revision was landed with ongoing or failed builds.Feb 8 2022, 4:04 AM
This revision was automatically updated to reflect the committed changes.