This is an archive of the discontinued LLVM Phabricator instance.

[TargetLowering] Add NegatibleKind enum for isNegatibleForFree return codes
ClosedPublic

Authored by RKSimon on Feb 7 2020, 7:02 AM.

Details

Summary

The isNegatibleForFree/getNegatedExpression methods currently rely on a raw char value to indicate whether a negation is beneficial or not.

This patch replaces the char return value with an NegatibleKind enum to more clearly demonstrate what is implied.

It also renames isNegatibleForFree to getNegatibleKind to more accurately reflect whats going on.

Diff Detail

Event Timeline

RKSimon created this revision.Feb 7 2020, 7:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2020, 7:02 AM

+1, useful.

llvm/include/llvm/CodeGen/TargetLowering.h
3497

name - isNegatibleForFree - hints that that this function probably returns bool.

Maybe we should rename it too - what do you think?

getNegatibleKind?

RKSimon updated this revision to Diff 243226.Feb 7 2020, 10:31 AM
RKSimon edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Feb 11 2020, 6:08 AM
spatel accepted this revision.Feb 11 2020, 8:09 AM

LGTM. But would "{get}NegatibleCost" be more accurate than "{get}NegatibleKind"?

LGTM. But would "{get}NegatibleCost" be more accurate than "{get}NegatibleKind"?

I'll replace NegatibleKind with NegatibleCost - my initial prototype for this hadn't used cost style enum names, but I didn't change it as the patch developed

This revision was automatically updated to reflect the committed changes.