Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mlir/include/mlir/Conversion/LLVMCommon/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ class ConvertToLLVMPattern : public ConversionPattern {
Type getVoidType() const;

/// Get the MLIR type wrapping the LLVM i8* type.
[[deprecated("Use getPtrType() instead!")]]
Type getVoidPtrType() const;

/// Get the MLIR type wrapping the LLVM ptr type.
Type getPtrType(unsigned addressSpace = 0) const;

/// Create a constant Op producing a value of `resultType` from an index-typed
/// integer attribute.
static Value createIndexAttrConstant(OpBuilder &builder, Location loc,
Expand Down
9 changes: 6 additions & 3 deletions mlir/lib/Conversion/LLVMCommon/Pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ Type ConvertToLLVMPattern::getVoidType() const {
return LLVM::LLVMVoidType::get(&getTypeConverter()->getContext());
}

Type ConvertToLLVMPattern::getVoidPtrType() const {
return LLVM::LLVMPointerType::get(&getTypeConverter()->getContext());
Type ConvertToLLVMPattern::getPtrType(unsigned addressSpace) const {
return LLVM::LLVMPointerType::get(&getTypeConverter()->getContext(),
addressSpace);
}

Type ConvertToLLVMPattern::getVoidPtrType() const { return getPtrType(); }

Value ConvertToLLVMPattern::createIndexAttrConstant(OpBuilder &builder,
Location loc,
Type resultType,
Expand Down Expand Up @@ -273,7 +276,7 @@ LogicalResult ConvertToLLVMPattern::copyUnrankedDescriptors(
? builder
.create<LLVM::CallOp>(loc, mallocFunc.value(), allocationSize)
.getResult()
: builder.create<LLVM::AllocaOp>(loc, getVoidPtrType(),
: builder.create<LLVM::AllocaOp>(loc, getPtrType(),
IntegerType::get(getContext(), 8),
allocationSize,
/*alignment=*/0);
Expand Down
11 changes: 4 additions & 7 deletions mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,7 @@ struct AllocaScopeOpLowering

// Save stack and then branch into the body of the region.
rewriter.setInsertionPointToEnd(currentBlock);
auto stackSaveOp =
rewriter.create<LLVM::StackSaveOp>(loc, getVoidPtrType());
auto stackSaveOp = rewriter.create<LLVM::StackSaveOp>(loc, getPtrType());
rewriter.create<LLVM::BrOp>(loc, ValueRange(), beforeBody);

// Replace the alloca_scope return with a branch that jumps out of the body.
Expand Down Expand Up @@ -1122,8 +1121,7 @@ class MemRefCopyOpLowering : public ConvertOpToLLVMPattern<memref::CopyOp> {
};

// Save stack position before promoting descriptors
auto stackSaveOp =
rewriter.create<LLVM::StackSaveOp>(loc, getVoidPtrType());
auto stackSaveOp = rewriter.create<LLVM::StackSaveOp>(loc, getPtrType());

auto srcMemRefType = dyn_cast<MemRefType>(srcType);
Value unrankedSource =
Expand Down Expand Up @@ -1249,7 +1247,7 @@ struct MemorySpaceCastOpLowering
result, resultAddrSpace, sizes);
Value resultUnderlyingSize = sizes.front();
Value resultUnderlyingDesc = rewriter.create<LLVM::AllocaOp>(
loc, getVoidPtrType(), rewriter.getI8Type(), resultUnderlyingSize);
loc, getPtrType(), rewriter.getI8Type(), resultUnderlyingSize);
result.setMemRefDescPtr(rewriter, loc, resultUnderlyingDesc);

// Copy pointers, performing address space casts.
Expand Down Expand Up @@ -1530,8 +1528,7 @@ struct MemRefReshapeOpLowering
UnrankedMemRefDescriptor::computeSizes(rewriter, loc, *getTypeConverter(),
targetDesc, addressSpace, sizes);
Value underlyingDescPtr = rewriter.create<LLVM::AllocaOp>(
loc, getVoidPtrType(), IntegerType::get(getContext(), 8),
sizes.front());
loc, getPtrType(), IntegerType::get(getContext(), 8), sizes.front());
targetDesc.setMemRefDescPtr(rewriter, loc, underlyingDescPtr);

// Extract pointers and offset from the source memref.
Expand Down
2 changes: 1 addition & 1 deletion mlir/test/lib/Conversion/FuncToLLVM/TestConvertCallOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestTypeProducerOpConverter
LogicalResult
matchAndRewrite(test::TestTypeProducerOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
rewriter.replaceOpWithNewOp<LLVM::ZeroOp>(op, getVoidPtrType());
rewriter.replaceOpWithNewOp<LLVM::ZeroOp>(op, getPtrType());
return success();
}
};
Expand Down