This is an archive of the discontinued LLVM Phabricator instance.

[MCInstPrinter] Enable MCInstPrinter to change its behavior based on the per-function subtarget
ClosedPublic

Authored by ahatanak on Mar 27 2015, 11:54 AM.

Details

Summary

Currently, code-gen passes the default or generic subtarget to the constructors of MCInstPrinter subclasses (see LLVMTargetMachine::addPassesToEmitFile), which enables some targets (AArch64, ARM, and X86) to change their instprinter's behavior based on the subtarget feature bits. Since the backend can now use different subtargets for each function, instprinter has to be changed to use the per-function subtarget rather than the default subtarget.

This patch takes the first step towards enabling instprinter to change its behavior based on the per-function subtarget. It adds a bit "PassSubtarget" to AsmWriter which tells table-gen to pass a reference to MCSubtargetInfo to the various print methods table-gen auto-generates. In this patch, I've turned on this bit only for AArch64, but I plan to make the same changes for ARM and X86 and remove AvailableFeatures from MCInstPrinter.

Diff Detail

Repository
rL LLVM

Event Timeline

ahatanak updated this revision to Diff 22809.Mar 27 2015, 11:54 AM
ahatanak retitled this revision from to [MCInstPrinter] Enable MCInstPrinter to change its behavior based on the per-function subtarget.
ahatanak updated this object.
ahatanak edited the test plan for this revision. (Show Details)
ahatanak added a reviewer: echristo.
ahatanak added a subscriber: Unknown Object (MLST).
echristo edited edge metadata.Mar 27 2015, 11:58 AM

Clever hack with PassSubtarget to make sure you don't have to update all of the ports and reduce churn I gather?

Looks pretty decent in general. First follow up will be to remove the passing of the subtarget to the inst printer constructor yes? (Also the ARM port I think needs to be fixed up).

-eric

Clever hack with PassSubtarget to make sure you don't have to update all of the ports and reduce churn I gather?

Yes, I did it to reduce churn.

Looks pretty decent in general. First follow up will be to remove the passing of the subtarget to the inst printer constructor yes? (Also the ARM port I think needs to be fixed up).

My plan was to commit this patch first (possibly separating the changes in AArch64InstPrinter and the test case from the rest), make similar changes to ARM and X86, and then remove the passing of the subtarget and remove MCInstPrinter::AvailableFeatures.

-eric

echristo accepted this revision.Mar 27 2015, 12:40 PM
echristo edited edge metadata.

Excellent. We're in agreement then.

One inline comment and then LGTM.

-eric

utils/TableGen/AsmWriterInst.h
56 ↗(On Diff #22809)

Document this please. What it's for, why it exists, etc. Possibly even a FIXME for "remove after all ports are updated".

This revision is now accepted and ready to land.Mar 27 2015, 12:40 PM

Thanks.

I wasn't planning to make the changes I made for AArch64 for other ports that don't use subtarget feature bits in their instprinters, but if it's important to have a uniform interface for the print methods table-gen generates, I can update those ports later and remove PassSubtarget.

Excellent. We're in agreement then.

One inline comment and then LGTM.

-eric

This revision was automatically updated to reflect the committed changes.