This is an archive of the discontinued LLVM Phabricator instance.

[globalisel] Move as much RegisterBank initialization to the constructor as possible
ClosedPublic

Authored by dsanders on Dec 15 2016, 7:49 AM.

Details

Summary

The register bank is now entirely initialized in the constructor. However,
we still have the hardcoded number of register classes which will be
dealt with in the TableGen patch (D27338) since we do not have access
to this information to resolve this at this stage. The number of register
classes is known to the TRI and to TableGen but the RegisterBank
constructor is too early for the former and too late for the latter.
This will be fixed when the data is tablegen-erated.

Event Timeline

dsanders updated this revision to Diff 81581.Dec 15 2016, 7:49 AM
dsanders retitled this revision from to [globalisel] Move as much RegisterBank initialization to the constructor as possible.
dsanders updated this object.
dsanders added reviewers: qcolombet, t.p.northover, ab, rovka.
dsanders added a subscriber: llvm-commits.
rovka accepted this revision.Dec 16 2016, 3:58 AM
rovka edited edge metadata.

LGTM with microscopic nits.

include/llvm/CodeGen/GlobalISel/RegisterBank.h
46

It's probably worthwhile to add the comment explaining why this is necessary here (instead of only in the commit message).

lib/CodeGen/GlobalISel/RegisterBank.cpp
25

Incomplete comment :)

lib/Target/AArch64/AArch64RegisterBankInfo.cpp
45

I think you should move the asserts checking that getRegBank returns the expected banks before this loop (I can see how this will make the loop a bit more "buried", but it seems like the proper thing to do).

This revision is now accepted and ready to land.Dec 16 2016, 3:58 AM
dsanders updated this revision to Diff 81945.Dec 19 2016, 6:54 AM
dsanders marked 3 inline comments as done.
dsanders edited edge metadata.

Fix incomplete comment.
Add comment about finishInit()
Check getRegBank() works before relying on it to finish initialisation().

qcolombet requested changes to this revision.Dec 19 2016, 5:49 PM
qcolombet edited edge metadata.
qcolombet added inline comments.
lib/CodeGen/GlobalISel/RegisterBank.cpp
30

We shouldn't need the TRI to do that.
By construction, we already have a limit of 64, but we will refine by making the tablegen backend smarter.

Indeed, eventually, TableGen shouldn't need this method, otherwise we missed something.
In particular, it is not unlikely that the TableGen backend will need to process the TargetRegisterInfo.td file with the TargetRegisterBank.td.

That should be automatic as I expect something like this in the XXXRegisterBank.td:

include XXXRegisterInfo.td

def MyBank : RegisterBank<(list of register classes)>

This revision now requires changes to proceed.Dec 19 2016, 5:49 PM
dsanders updated this revision to Diff 82079.Dec 20 2016, 2:43 AM
dsanders edited edge metadata.

Rebase and support ARM

dsanders updated this revision to Diff 83601.Jan 9 2017, 2:42 AM
dsanders edited edge metadata.

Rebased onto new D27808.

Finished moving to TargetRegisterClass initialization style.

RegisterBanks are now expected to be valid immediately after construction and
finishInit() is no longer needed.

dsanders updated this object.Jan 9 2017, 2:47 AM
dsanders added a subscriber: aditya_nandakumar.
qcolombet accepted this revision.Jan 9 2017, 4:55 PM
qcolombet edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jan 9 2017, 4:55 PM
dsanders updated this revision to Diff 84123.Jan 12 2017, 7:56 AM
dsanders edited edge metadata.

Refresh before commit

dsanders updated this object.Jan 12 2017, 7:58 AM
dsanders closed this revision.Jan 12 2017, 8:22 AM