#include "llvm/Pass.h"
#include "llvm/Support/DataTypes.h"
+// this needs to be outside of the namespace, to avoid conflict with llvm-c decl
+typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
+
namespace llvm {
class Value;
/// Initialize target data from properties stored in the module.
explicit DataLayout(const Module *M);
+ void init(const Module *M);
+
DataLayout(const DataLayout &DL) : LayoutMap(nullptr) { *this = DL; }
DataLayout &operator=(const DataLayout &DL) {
return (LargestSize == 0) ? nullptr : Type::getIntNTy(C, LargestSize);
}
- /// getLargestLegalIntType - Return the size of largest legal integer type
- /// size, or 0 if none are set.
+ /// getLargestLegalIntTypeSize - Return the size of largest legal integer
+ /// type size, or 0 if none are set.
unsigned getLargestLegalIntTypeSize() const;
/// getIndexedOffset - return the offset from the beginning of the type for
}
};
+inline DataLayout *unwrap(LLVMTargetDataRef P) {
+ return reinterpret_cast<DataLayout*>(P);
+}
+
+inline LLVMTargetDataRef wrap(const DataLayout *P) {
+ return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout*>(P));
+}
+
class DataLayoutPass : public ImmutablePass {
DataLayout DL;
const DataLayout &getDataLayout() const { return DL; }
- // For use with the C API. C++ code should always use the constructor that
- // takes a module.
- explicit DataLayoutPass(const DataLayout &DL);
-
- explicit DataLayoutPass(const Module *M);
-
static char ID; // Pass identification, replacement for typeid
+
+ bool doFinalization(Module &M) override;
+ bool doInitialization(Module &M) override;
};
/// StructLayout - used to lazily calculate structure layout information for a