mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-02 07:17:36 +00:00
Make DataLayout a plain object, not a pass.
Instead, have a DataLayoutPass that holds one. This will allow parts of LLVM don't don't handle passes to also use DataLayout. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202168 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
@@ -248,7 +248,7 @@ void initializeStripSymbolsPass(PassRegistry&);
|
||||
void initializeTailCallElimPass(PassRegistry&);
|
||||
void initializeTailDuplicatePassPass(PassRegistry&);
|
||||
void initializeTargetPassConfigPass(PassRegistry&);
|
||||
void initializeDataLayoutPass(PassRegistry&);
|
||||
void initializeDataLayoutPassPass(PassRegistry &);
|
||||
void initializeTargetTransformInfoAnalysisGroup(PassRegistry&);
|
||||
void initializeNoTTIPass(PassRegistry&);
|
||||
void initializeTargetLibraryInfoPass(PassRegistry&);
|
||||
|
||||
Reference in New Issue
Block a user