This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Legalize more G_FP(EXT|TRUNC) libcalls.
ClosedPublic

Authored by kschwarz on Feb 4 2020, 2:12 AM.

Details

Reviewers
dsanders
arsenm
Summary

This adds a new helper function for retrieving the floating point type corresponding to the specified bit-width.

Diff Detail

Event Timeline

kschwarz created this revision.Feb 4 2020, 2:12 AM
arsenm added inline comments.Feb 4 2020, 7:55 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
118

It might be better to pass the LLT instead of just the size in case new exotic LLTs are introduced for weird FP types in the future

129

Return null and report legalization failure?

kschwarz updated this revision to Diff 242563.Feb 5 2020, 5:08 AM

Address review comments

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
118

Makes sense

129

Definitely better than crashing. It requires all call sites to handle the nullptr though.

arsenm added a comment.Feb 5 2020, 5:43 AM

Testcase?

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
740

demorgan this

Should this be a unit test then, since there is no in-tree target currently requiring a libcall for this?

arsenm added a comment.Feb 5 2020, 6:56 AM

Should this be a unit test then, since there is no in-tree target currently requiring a libcall for this?

That would work

kschwarz updated this revision to Diff 242847.Feb 6 2020, 3:08 AM

Unit tests added for the previously unsupported extensions & truncations.
Tightened the size check for simple libcalls to avoid crash on unsupported libcalls.

arsenm added inline comments.Feb 6 2020, 6:25 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
725

You can move this under the getFloatTypeForLLT check since it's somewhat redundant

llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
1205–1206

EXPECT_EQ(Legalized, ...)

1247–1251

Ditto

kschwarz updated this revision to Diff 242908.Feb 6 2020, 8:06 AM

Move check
Change EXPECT_TRUE -> EXPECT_EQ

arsenm accepted this revision.Feb 6 2020, 8:17 AM
This revision is now accepted and ready to land.Feb 6 2020, 8:17 AM

@arsenm, thanks for the review! Would you mind committing this for me?