Page MenuHomePhabricator

[Tablegen/SubtargetEmitter] Add Id field to ProcResource
Needs ReviewPublic

Authored by kariddi on Oct 2 2018, 8:34 PM.




I made a patch to add a Target managed Id field to the ProcResource structure in the backend scheduling infrastructure.

The idea is that it can be useful to make a scheduling decisions based on which resources a certain instruction/node is using.
The problem is that there's no way to tell what a resource is when you iterate over it in code and because of that you cannot make a decision. We would need a way to know that a certain resource is for example "ALU" or "Issue" to do so.
Another way would be to attach target flags to the instructions and check that (like TSFlags for example) or maintain a function that returns a predicate depending on the instruction opcode, but if the information you need is already encoded in the scheduling resources then duplicating it in the TSFlags and keeping it in sync with your scheduling model seems wasteful and error prone.

This patch adds an Id that the developer can assign any value he wants to and then in C++ code then you could have an enum connecting the values specified in the tablegen model that are easy to read.

For example you could have a procresource called ALU with TargetId = 1 and then have an enum in the scheduler that looks like this:

enum { ProcALU = 1, .... };

You can query the TargetId of a ProcResource by using the getProcResourceTargetId() function passing the ProcResourceId.

Diff Detail

Event Timeline

kariddi created this revision.Oct 2 2018, 8:34 PM