This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Reduce the amount of storage space used for AddrSpaces in TypeSetByHwMode. NFC
ClosedPublic

Authored by craig.topper on Apr 12 2023, 10:43 PM.

Details

Summary

We reserved 16 AddrSpaces in every TypeSetByHwMode. But we only ever
use the first one on targets that make use of the AddrSpace feature.

The vector was populated by pushing for each entry in the ArrayRef
passed to the TypeSetByHwMode constructor. Each entry is a
ValueTypeByHwMode that stores one VT for each HwMode.

The vector is accessed by a loop in TypeSetByHwMode::getValueTypeByHwMode.
That loop is over HwModes with in the TypeSetByHwMode. This is
unrelated to how the vector was created. The entries in the vector
don't represent HwModes.

The targets that use AddrSpace don't make use of HwModes so the
loop in getValueTypeByHwMode will only run 1 iteration. So we only
the first entry in the vector is meaningful used.

This patch simplifies things by storing only 1 AddrSpace in
TypeSetByMode. Reducing the memory used by TypeSetByHwMode.
More work will be needed to support HwModes with AddrSpace if we
need a different AddrSpace for each HwModes.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 12 2023, 10:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 10:43 PM
craig.topper requested review of this revision.Apr 12 2023, 10:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 10:43 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm added inline comments.Apr 18 2023, 4:21 AM
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
86–91

I've never really understood TypeSetByHwMode. Currently the address space would largely be unused since it doesn't actually work in SelectionDAG. Would this stop you from parameterizing the same pattern over multiple address spaces, or just swapping out the address space based on the hwmode?

craig.topper added inline comments.Apr 18 2023, 12:44 PM
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
86–91

TypeSetByHwMode is a set of possible types for each hardware mode.
ValueTypeByHwMode is a single MVT for each hardware mode.

If we needed a different address space for each hardware mode TypeSetByHwMode and ValueTypeByHwMode would both need to store the AddrSpace for each HwMode inside the HwMode map. The PtrValueType class in tablegen would need to support HwMode like ValueTypeByHwMode and RegInfoByHwMode.

If we need to support multiple AddrSpaces with in the possible types for a single hardware mode, that would probably require some enhancement to MachineValueTypeSet.

I don't think either of these were supported before and I don't think this patch makes it worse. I just want to get back the large waste of space. We can add support when we have a use case.

arsenm accepted this revision.Apr 18 2023, 3:05 PM
This revision is now accepted and ready to land.Apr 18 2023, 3:05 PM
This revision was landed with ongoing or failed builds.Apr 18 2023, 3:34 PM
This revision was automatically updated to reflect the committed changes.