This is an archive of the discontinued LLVM Phabricator instance.

Move the DataLayout to the generic TargetMachine, making it mandatory.
ClosedPublic

Authored by mehdi_amini on Mar 10 2015, 10:52 PM.

Details

Summary

I don't know why every singled backend had to redeclare its own DataLayout.
There was a virtual getDataLayout() on the common base TargetMachine, the
default implementation returned nullptr. It was not clear from this that
we could assume at call site that a DataLayout will be available with
each Target.

Now getDataLayout() is no longer virtual and return a pointer to the
DataLayout member of the common base TargetMachine. I plan to turn it into
a reference in a future patch.

The only backend that didn't have a DataLayout previsouly was the CPPBackend.
It now initializes the default DataLayout. This commit is NFC for all the
other backends.

Diff Detail

Event Timeline

mehdi_amini retitled this revision from to Move the DataLayout to the generic TargetMachine, making it mandatory..
mehdi_amini updated this object.
mehdi_amini edited the test plan for this revision. (Show Details)
mehdi_amini added a reviewer: echristo.
mehdi_amini added a subscriber: Unknown Object (MLST).
echristo accepted this revision.Mar 10 2015, 11:51 PM
echristo edited edge metadata.

Seems reasonable. Vaguely unhappy with the string option for target machine - I'd rather it just be grabbed from the module and stored somewhere. That said this is a nice intermediate step at least.

-eric

This revision is now accepted and ready to land.Mar 10 2015, 11:51 PM

Yes, I see this as an intermediate step. In my mind, having a single point where the DataLayout is stored makes it easier to think about how to change it now.

There should be only two DataLayout object now: one in the Module, and one on the TargetMachine (I nuked the TargetLoweringInfo in an earlier patch).


Mehdi

Agreed. Thanks!

-eric