Small Data Adressing support

Hi all,

I'm trying figure out how to implement support for Small Data
Addressing (SDA) for an out-of-tree PowerPC target. The short
description of SDA is that small globals are gathered in the same
memory area and addressed using a base register + an offset. From what
I've seen the Hexagon target already support this but as that target
doesn't seem to support writing object files it doesn't take me all
the way.

My plan has been:
1. Use custom lowering for GlobalAddress and insert a target specific
ADDR_SDA node if the object pointed to is suitable for SDA. The target
specific node gets a TargetGlobalAddress node as leaf.
2. Use a pattern to match the graph "set->load->ADDR_SDA" and create a
load instruction with fixed base register from this pattern. The
pattern is similar to the one I use for the normal load instruction.

When I tried to implement this I hit an assert during tablegenning
which claims that "set" is an unknown node.

If I compare this approach with Hexagon it instead matches against
"atomic_load_32". I tried this too but then I don't have any
destination register available and can't use the load instruction.

If someone has a good picture of how to implement this I would really
appreciate some advice. I suspect other targets have similar
addressing modes and if so it would be nice to be pointed towards the
implementation.

Thanks in advance!

- David

Hi David,

If someone has a good picture of how to implement this I would really
appreciate some advice.

Have you looked at the GlobalMerge pass, used by ARM & AArch64? It
doesn't seem to discriminate based on size, but its intent is
definitely to create a single base pointer. Obviously, it also works
with object emission.

Cheers.

Tim.

Hi Tim,

Hi David,

If someone has a good picture of how to implement this I would really
appreciate some advice.

Have you looked at the GlobalMerge pass, used by ARM & AArch64? It
doesn't seem to discriminate based on size, but its intent is
definitely to create a single base pointer. Obviously, it also works
with object emission.

Thanks for your suggestion.

I have taken a look at the pass now and it contains similar logic as I
have in my custom lowering for GlobalAddress to determine if a global
is suitable for SDA addressing. One difference (unless I've
misunderstood something) is that the pass operates on IR level which I
don't think is optimal in my case. The reason is that the ABI dictates
which register to use as base pointer. As such I have a feeling that
it would better to do this at a lower level but I don't have enough
knowledge to say this for certain (please feel free to correct me if
I'm wrong).

- David