diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-25 20:01:08 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-02-25 20:01:08 +0000 |
commit | aab87fe0ec98072580586850ed00bac3d00df6c0 (patch) | |
tree | 7a7439c4180e01a3804eb528022a98f6d024cdfc /include/llvm/IR | |
parent | dbaa6ab8b5527ca32969f4baa0931a674b9f4eef (diff) | |
download | llvm-aab87fe0ec98072580586850ed00bac3d00df6c0.tar.gz llvm-aab87fe0ec98072580586850ed00bac3d00df6c0.tar.bz2 llvm-aab87fe0ec98072580586850ed00bac3d00df6c0.tar.xz |
Store a DataLayout in Module.
Now that DataLayout is not a pass, store one in Module.
Since the C API expects to be able to get a char* to the datalayout description,
we have to keep a std::string somewhere. This patch keeps it in Module and also
uses it to represent modules without a DataLayout.
Once DataLayout is mandatory, we should probably move the string to DataLayout
itself since it won't be necessary anymore to represent the special case of a
module without a DataLayout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202190 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/IR')
-rw-r--r-- | include/llvm/IR/Module.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/include/llvm/IR/Module.h b/include/llvm/IR/Module.h index b965c9ee56..d489bd6c0c 100644 --- a/include/llvm/IR/Module.h +++ b/include/llvm/IR/Module.h @@ -16,6 +16,7 @@ #define LLVM_IR_MODULE_H #include "llvm/ADT/OwningPtr.h" +#include "llvm/IR/DataLayout.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalAlias.h" #include "llvm/IR/GlobalVariable.h" @@ -199,9 +200,16 @@ private: OwningPtr<GVMaterializer> Materializer; ///< Used to materialize GlobalValues std::string ModuleID; ///< Human readable identifier for the module std::string TargetTriple; ///< Platform target triple Module compiled on - std::string DataLayout; ///< Target data description void *NamedMDSymTab; ///< NamedMDNode names. + // We need to keep the string because the C API expects us to own the string + // representation. + // Since we have it, we also use an empty string to represent a module without + // a DataLayout. If it has a DataLayout, these variables are in sync and the + // string is just a cache of getDataLayout()->getStringRepresentation(). + std::string DataLayoutStr; + DataLayout DL; + friend class Constant; /// @} @@ -222,10 +230,12 @@ public: /// @returns the module identifier as a string const std::string &getModuleIdentifier() const { return ModuleID; } - /// Get the data layout string for the module's target platform. This encodes - /// the type sizes and alignments expected by this module. - /// @returns the data layout as a string - const std::string &getDataLayout() const { return DataLayout; } + /// Get the data layout string for the module's target platform. This is + /// equivalent to getDataLayout()->getStringRepresentation(). + const std::string &getDataLayoutStr() const { return DataLayoutStr; } + + /// Get the data layout for the module's target platform. + const DataLayout *getDataLayout() const; /// Get the target triple which is a string describing the target host. /// @returns a string containing the target triple. @@ -247,7 +257,8 @@ public: void setModuleIdentifier(StringRef ID) { ModuleID = ID; } /// Set the data layout - void setDataLayout(StringRef DL) { DataLayout = DL; } + void setDataLayout(StringRef Desc); + void setDataLayout(const DataLayout *Other); /// Set the target triple. void setTargetTriple(StringRef T) { TargetTriple = T; } |