/// Returns the MLIR context.
MLIRContext &getContext();
- /// Returns the LLVM context.
- llvm::LLVMContext &getLLVMContext();
/// Returns the LLVM dialect.
LLVM::LLVMDialect *getDialect() { return llvmDialect; }
/// Returns the LLVM dialect.
LLVM::LLVMDialect &getDialect() const;
- /// Returns the LLVM IR context.
- llvm::LLVMContext &getContext() const;
-
/// Gets the MLIR type wrapping the LLVM integer type whose bit width is
/// defined by the used type converter.
LLVM::LLVMType getIndexType() const;
let hasRegionArgAttrVerify = 1;
let extraClassDeclaration = [{
~LLVMDialect();
- llvm::LLVMContext &getLLVMContext();
- llvm::Module &getLLVMModule();
- llvm::sys::SmartMutex<true> &getLLVMContextMutex();
const llvm::DataLayout &getDataLayout();
private:
return *getDialect()->getContext();
}
-/// Get the LLVM context.
-llvm::LLVMContext &LLVMTypeConverter::getLLVMContext() {
- return llvmDialect->getLLVMContext();
-}
-
LLVM::LLVMType LLVMTypeConverter::getIndexType() {
return LLVM::LLVMType::getIntNTy(&getContext(), getIndexTypeBitwidth());
}
return *typeConverter.getDialect();
}
-llvm::LLVMContext &ConvertToLLVMPattern::getContext() const {
- return typeConverter.getLLVMContext();
-}
-
LLVM::LLVMType ConvertToLLVMPattern::getIndexType() const {
return typeConverter.getIndexType();
}
// TODO: this should use the MLIR data layout when it becomes available and
// stop depending on translation.
LLVM::LLVMDialect *dialect = typeConverter.getDialect();
- align = LLVM::TypeToLLVMIRTranslator(dialect->getLLVMContext())
+ llvm::LLVMContext llvmContext;
+ align = LLVM::TypeToLLVMIRTranslator(llvmContext)
.getPreferredAlignment(elementTy.cast<LLVM::LLVMType>(),
dialect->getDataLayout());
return success();
namespace LLVM {
namespace detail {
struct LLVMDialectImpl {
- LLVMDialectImpl() : module("LLVMDialectModule", llvmContext) {}
+ LLVMDialectImpl() : layout("") {}
- llvm::LLVMContext llvmContext;
- llvm::Module module;
-
- /// A smart mutex to lock access to the llvm context. Unlike MLIR, LLVM is not
- /// multi-threaded and requires locked access to prevent race conditions.
- llvm::sys::SmartMutex<true> mutex;
+ /// Default data layout to use.
+ // TODO: this should be moved to some Op equivalent to LLVM module and
+ // eventually replaced with a proper MLIR data layout.
+ llvm::DataLayout layout;
};
} // end namespace detail
} // end namespace LLVM
#define GET_OP_CLASSES
#include "mlir/Dialect/LLVMIR/LLVMOps.cpp.inc"
-llvm::LLVMContext &LLVMDialect::getLLVMContext() { return impl->llvmContext; }
-llvm::Module &LLVMDialect::getLLVMModule() { return impl->module; }
-llvm::sys::SmartMutex<true> &LLVMDialect::getLLVMContextMutex() {
- return impl->mutex;
-}
-const llvm::DataLayout &LLVMDialect::getDataLayout() {
- return impl->module.getDataLayout();
-}
+const llvm::DataLayout &LLVMDialect::getDataLayout() { return impl->layout; }
/// Parse a type registered to this dialect.
Type LLVMDialect::parseType(DialectAsmParser &parser) const {