Page MenuHomePhabricator

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

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

Details

Summary

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

Repository
rL LLVM

Event Timeline

aemerson created this revision.Thu, Aug 8, 4:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Aug 8, 4:27 PM
This revision is now accepted and ready to land.Mon, Aug 12, 1:04 PM
dsanders accepted this revision.Mon, Aug 12, 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

llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
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.Mon, Aug 12, 6:12 PM
aemerson added inline comments.
llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
72 ↗(On Diff #214258)

setupForMF()?

This revision was automatically updated to reflect the committed changes.