This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen]Refactor CpuSupports/CPUIs Builtin Code Gen to better work with "target" implementation
ClosedPublic

Authored by erichkeane on Aug 14 2017, 12:24 PM.

Details

Summary

A small set of refactors that'll make it easier for me to implement 'target' support.

First, extract the CPUSupports functionality into its own function. THis has the advantage of not wasting time in this builtin to deal with arguments.
Second, pulls both CPUSupports and CPUIs implementation into a member-function, so that it can be called from the resolver generation that I'm working on.
Third, creates an overload that takes simply the feature/cpu name (rather than extracting it from a callexpr), since that info isn't available later.

Note that despite how the 'diff' looks, the EmitX86CPUSupports function simply takes the implementation out of the 'switch'.

Diff Detail

Event Timeline

erichkeane created this revision.Aug 14 2017, 12:24 PM

Thinking about it further, the emit functions should be private in this case.

Of course, overnight I realized I am probably better off having the 'CpuSupports' validate MULTIPLE features at a time! I'll update this patch with an improvement when I get one that I think is really useful. Sorry for the thrash.

This revision is now accepted and ready to land.Aug 19 2017, 10:01 AM
erichkeane planned changes to this revision.Aug 22 2017, 8:17 AM

I actually updated it a bit since then, so I'll hold off on committing until my replacement version is perfect, I'd prefer to stop churning. Thanks for the review though Craig!

I figured out that combining the CpuSupports items via an array is a REALLY useful function for dispatch. I've got most of gcc's target implemented, so I believe that this is sufficient for that purpose.

Thanks in advance for the reviews :)

This revision is now accepted and ready to land.Aug 30 2017, 11:43 AM

Woops, messed up my rebase!

craig.topper added inline comments.Aug 31 2017, 9:54 AM
lib/CodeGen/CGBuiltin.cpp
7414

You shouldn't need curly braces here. ArrayRef has a conversion constructor that should take care of this.

7456

Declare as uint32_t?

7494

No need for 64-bit OR here. FeaturesMask is only 32-bits.

7525

I think you have the builtin handline at the top and in the switch. Bad rebase?

craig.topper requested changes to this revision.Aug 31 2017, 9:54 AM
This revision now requires changes to proceed.Aug 31 2017, 9:54 AM
erichkeane edited edge metadata.
erichkeane marked 4 inline comments as done.
This revision is now accepted and ready to land.Aug 31 2017, 10:53 PM