Remove access to the DataLayout in the TargetMachine

Summary:
Replace getDataLayout() with a createDataLayout() method to make
explicit that it is intended to create a DataLayout only and not
accessing it for other purpose.

This change is the last of a series of commits dedicated to have a
single DataLayout during compilation by using always the one owned
by the module.

Reviewers: echristo

Subscribers: jholewinski, llvm-commits, rafael, yaron.keren

Differential Revision: http://reviews.llvm.org/D11103

(cherry picked from commit 5609fc56bca971e5a7efeaa6ca4676638eaec5ea)

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243114 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mehdi Amini
2015-07-24 16:04:22 +00:00
parent 87663dbefa
commit 15e1e7f179
17 changed files with 74 additions and 60 deletions

View File

@ -76,7 +76,12 @@ protected: // Can only create subclasses.
/// The Target that this machine was created for.
const Target &TheTarget;
/// For ABI type size and alignment.
/// DataLayout for the target: keep ABI type size and alignment.
///
/// The DataLayout is created based on the string representation provided
/// during construction. It is kept here only to avoid reparsing the string
/// but should not really be used during compilation, because it has an
/// internal cache that is context specific.
const DataLayout DL;
/// Triple string, CPU name, and target feature strings the TargetMachine
@ -125,9 +130,13 @@ public:
return *static_cast<const STC*>(getSubtargetImpl(F));
}
/// This method returns a pointer to the DataLayout for the target. It should
/// be unchanging for every subtarget.
const DataLayout *getDataLayout() const { return &DL; }
/// Create a DataLayout.
const DataLayout createDataLayout() const { return DL; }
/// Get the pointer size for this target.
///
/// This is the only time the DataLayout in the TargetMachine is used.
unsigned getPointerSize() const { return DL.getPointerSize(); }
/// \brief Reset the target options based on the function's attributes.
// FIXME: Remove TargetOptions that affect per-function code generation