summaryrefslogtreecommitdiff
path: root/include/llvm/IR/DataLayout.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/IR/DataLayout.h')
-rw-r--r--include/llvm/IR/DataLayout.h70
1 files changed, 36 insertions, 34 deletions
diff --git a/include/llvm/IR/DataLayout.h b/include/llvm/IR/DataLayout.h
index acd3d82555..f9ab9cf94c 100644
--- a/include/llvm/IR/DataLayout.h
+++ b/include/llvm/IR/DataLayout.h
@@ -88,14 +88,11 @@ struct PointerAlignElem {
bool operator==(const PointerAlignElem &rhs) const;
};
-
-/// DataLayout - This class holds a parsed version of the target data layout
-/// string in a module and provides methods for querying it. The target data
-/// layout string is specified *by the target* - a frontend generating LLVM IR
-/// is required to generate the right target data for the target being codegen'd
-/// to. If some measure of portability is desired, an empty string may be
-/// specified in the module.
-class DataLayout : public ImmutablePass {
+/// This class holds a parsed version of the target data layout string in a
+/// module and provides methods for querying it. The target data layout string
+/// is specified *by the target* - a frontend generating LLVM IR is required to
+/// generate the right target data for the target being codegen'd to.
+class DataLayout {
private:
bool LittleEndian; ///< Defaults to false
unsigned StackNaturalAlign; ///< Stack natural alignment
@@ -165,40 +162,28 @@ private:
void parseSpecifier(StringRef LayoutDescription);
public:
- /// Default ctor.
- ///
- /// @note This has to exist, because this is a pass, but it should never be
- /// used.
- DataLayout();
-
/// Constructs a DataLayout from a specification string. See init().
- explicit DataLayout(StringRef LayoutDescription)
- : ImmutablePass(ID) {
- init(LayoutDescription);
- }
+ explicit DataLayout(StringRef LayoutDescription) { init(LayoutDescription); }
/// Initialize target data from properties stored in the module.
explicit DataLayout(const Module *M);
- DataLayout(const DataLayout &DL) :
- ImmutablePass(ID),
- LittleEndian(DL.isLittleEndian()),
- StackNaturalAlign(DL.StackNaturalAlign),
- ManglingMode(DL.ManglingMode),
- LegalIntWidths(DL.LegalIntWidths),
- Alignments(DL.Alignments),
- Pointers(DL.Pointers),
- LayoutMap(0)
- { }
+ DataLayout(const DataLayout &DL) { *this = DL; }
+
+ DataLayout &operator=(const DataLayout &DL) {
+ LittleEndian = DL.isLittleEndian();
+ StackNaturalAlign = DL.StackNaturalAlign;
+ ManglingMode = DL.ManglingMode;
+ LegalIntWidths = DL.LegalIntWidths;
+ Alignments = DL.Alignments;
+ Pointers = DL.Pointers;
+ LayoutMap = 0;
+ return *this;
+ }
~DataLayout(); // Not virtual, do not subclass this class
- /// DataLayout is an immutable pass, but holds state. This allows the pass
- /// manager to clear its mutable state.
- bool doFinalization(Module &M);
-
- /// Parse a data layout string (with fallback to default values). Ensure that
- /// the data layout pass is registered.
+ /// Parse a data layout string (with fallback to default values).
void init(StringRef LayoutDescription);
/// Layout endianness...
@@ -458,6 +443,23 @@ public:
assert((Alignment & (Alignment-1)) == 0 && "Alignment must be power of 2!");
return (Val + (Alignment-1)) & ~UIntTy(Alignment-1);
}
+};
+
+class DataLayoutPass : public ImmutablePass {
+ DataLayout DL;
+
+public:
+ /// This has to exist, because this is a pass, but it should never be used.
+ DataLayoutPass();
+ ~DataLayoutPass();
+
+ const DataLayout &getDataLayout() const { return DL; }
+
+ explicit DataLayoutPass(const DataLayout &DL);
+
+ explicit DataLayoutPass(StringRef LayoutDescription);
+
+ explicit DataLayoutPass(const Module *M);
static char ID; // Pass identification, replacement for typeid
};