Page MenuHomePhabricator

[GlobalISel] Make the InstructionSelector instance non-const, allowing state to be maintained.

Authored by aemerson on Aug 8 2019, 4:27 PM.



Currently we can't keep any state in the selector object that we get from subtarget. As a result we have to plumb through all our variables through multiple functions. This change makes it non-const and adds a virtual init() method to allow further state to be captured for each target.

AArch64 makes use of this in this patch to cache a call to hasFnAttribute() which is expensive to call, and is used on each selection of G_BRCOND.

Diff Detail


Event Timeline

aemerson created this revision.Aug 8 2019, 4:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2019, 4:27 PM
This revision is now accepted and ready to land.Aug 12 2019, 1:04 PM
dsanders accepted this revision.Aug 12 2019, 6:06 PM

I can't say I'm keen for it to have any state but collecting the result of expensive per-MF checks seems reasonable. LGTM with a naming nit pick

72 ↗(On Diff #214258)

Just a nit pick: init() gives the impression that it will only be run once per object. Could we name it runBeforeISel(), prepareForMF() or something to make it clear that it runs every time?

aemerson marked an inline comment as done.Aug 12 2019, 6:12 PM
aemerson added inline comments.
72 ↗(On Diff #214258)


This revision was automatically updated to reflect the committed changes.