Skip to content

Commit 665371d

Browse files
committed
[mlir] Split alloc-like op LLVM lowerings into base and separate derived classes.
The previous code did the lowering to alloca, malloc, and aligned_malloc in a single class with different code paths that are somewhat difficult to follow. This change moves the common code to a base class and has a separte derived class per lowering target that contains the specifics. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D88696
1 parent c3f12dd commit 665371d

File tree

4 files changed

+328
-294
lines changed

4 files changed

+328
-294
lines changed

mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,18 @@ class ConvertToLLVMPattern : public ConversionPattern {
412412
LLVMTypeConverter &typeConverter,
413413
PatternBenefit benefit = 1);
414414

415+
protected:
415416
/// Returns the LLVM dialect.
416417
LLVM::LLVMDialect &getDialect() const;
417418

418419
/// Gets the MLIR type wrapping the LLVM integer type whose bit width is
419420
/// defined by the used type converter.
420421
LLVM::LLVMType getIndexType() const;
421422

423+
/// Gets the MLIR type wrapping the LLVM integer type whose bit width
424+
/// corresponds to that of a LLVM pointer type.
425+
LLVM::LLVMType getIntPtrType(unsigned addressSpace = 0) const;
426+
422427
/// Gets the MLIR type wrapping the LLVM void type.
423428
LLVM::LLVMType getVoidType() const;
424429

@@ -470,6 +475,15 @@ class ConvertToLLVMPattern : public ConversionPattern {
470475
ArrayRef<Value> shape,
471476
ConversionPatternRewriter &rewriter) const;
472477

478+
/// Creates and populates the memref descriptor struct given all its fields.
479+
/// 'strides' can be either dynamic (kDynamicStrideOrOffset) or static, but
480+
/// not a mix of the two.
481+
MemRefDescriptor
482+
createMemRefDescriptor(Location loc, MemRefType memRefType,
483+
Value allocatedPtr, Value alignedPtr, uint64_t offset,
484+
ArrayRef<int64_t> strides, ArrayRef<Value> sizes,
485+
ConversionPatternRewriter &rewriter) const;
486+
473487
protected:
474488
/// Reference to the type converter, with potential extensions.
475489
LLVMTypeConverter &typeConverter;

0 commit comments

Comments
 (0)