Skip to content

Commit ceb4dc4

Browse files
authored
[MLIR][VectorToLLVM] Remove typed pointer support (#71075)
This commit removes the support for lowering Vector to LLVM dialect with typed pointers. Typed pointers have been deprecated for a while now and it's planned to soon remove them from the LLVM dialect. Related PSA: https://discourse.llvm.org/t/psa-removal-of-typed-pointers-from-the-llvm-dialect/74502
1 parent 2b1948c commit ceb4dc4

File tree

8 files changed

+9
-208
lines changed

8 files changed

+9
-208
lines changed

mlir/include/mlir/Conversion/Passes.td

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,10 +1270,7 @@ def ConvertVectorToLLVMPass : Pass<"convert-vector-to-llvm"> {
12701270
Option<"x86Vector", "enable-x86vector",
12711271
"bool", /*default=*/"false",
12721272
"Enables the use of X86Vector dialect while lowering the vector "
1273-
"dialect.">,
1274-
Option<"useOpaquePointers", "use-opaque-pointers", "bool",
1275-
/*default=*/"true", "Generate LLVM IR using opaque pointers "
1276-
"instead of typed pointers">
1273+
"dialect.">
12771274
];
12781275
}
12791276

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,6 @@ static Value getIndexedPtrs(ConversionPatternRewriter &rewriter, Location loc,
112112
base, index);
113113
}
114114

115-
// Casts a strided element pointer to a vector pointer. The vector pointer
116-
// will be in the same address space as the incoming memref type.
117-
static Value castDataPtr(ConversionPatternRewriter &rewriter, Location loc,
118-
Value ptr, MemRefType memRefType, Type vt,
119-
const LLVMTypeConverter &converter) {
120-
if (converter.useOpaquePointers())
121-
return ptr;
122-
123-
unsigned addressSpace = *converter.getMemRefAddressSpace(memRefType);
124-
auto pType = LLVM::LLVMPointerType::get(vt, addressSpace);
125-
return rewriter.create<LLVM::BitcastOp>(loc, pType, ptr);
126-
}
127-
128115
/// Convert `foldResult` into a Value. Integer attribute is converted to
129116
/// an LLVM constant op.
130117
static Value getAsLLVMValue(OpBuilder &builder, Location loc,
@@ -261,10 +248,8 @@ class VectorLoadStoreConversion : public ConvertOpToLLVMPattern<LoadOrStoreOp> {
261248
this->typeConverter->convertType(loadOrStoreOp.getVectorType()));
262249
Value dataPtr = this->getStridedElementPtr(loc, memRefTy, adaptor.getBase(),
263250
adaptor.getIndices(), rewriter);
264-
Value ptr = castDataPtr(rewriter, loc, dataPtr, memRefTy, vtype,
265-
*this->getTypeConverter());
266-
267-
replaceLoadOrStoreOp(loadOrStoreOp, adaptor, vtype, ptr, align, rewriter);
251+
replaceLoadOrStoreOp(loadOrStoreOp, adaptor, vtype, dataPtr, align,
252+
rewriter);
268253
return success();
269254
}
270255
};
@@ -1440,19 +1425,12 @@ class VectorTypeCastOpConversion
14401425

14411426
// Create descriptor.
14421427
auto desc = MemRefDescriptor::undef(rewriter, loc, llvmTargetDescriptorTy);
1443-
Type llvmTargetElementTy = desc.getElementPtrType();
14441428
// Set allocated ptr.
14451429
Value allocated = sourceMemRef.allocatedPtr(rewriter, loc);
1446-
if (!getTypeConverter()->useOpaquePointers())
1447-
allocated =
1448-
rewriter.create<LLVM::BitcastOp>(loc, llvmTargetElementTy, allocated);
14491430
desc.setAllocatedPtr(rewriter, loc, allocated);
14501431

14511432
// Set aligned ptr.
14521433
Value ptr = sourceMemRef.alignedPtr(rewriter, loc);
1453-
if (!getTypeConverter()->useOpaquePointers())
1454-
ptr = rewriter.create<LLVM::BitcastOp>(loc, llvmTargetElementTy, ptr);
1455-
14561434
desc.setAlignedPtr(rewriter, loc, ptr);
14571435
// Fill offset 0.
14581436
auto attr = rewriter.getIntegerAttr(rewriter.getIndexType(), 0);

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ void LowerVectorToLLVMPass::runOnOperation() {
8282

8383
// Convert to the LLVM IR dialect.
8484
LowerToLLVMOptions options(&getContext());
85-
options.useOpaquePointers = useOpaquePointers;
8685
LLVMTypeConverter converter(&getContext(), options);
8786
RewritePatternSet patterns(&getContext());
8887
populateVectorMaskMaterializationPatterns(patterns, force32BitVectorIndices);

mlir/test/Conversion/VectorToLLVM/typed-pointers.mlir

Lines changed: 0 additions & 172 deletions
This file was deleted.

mlir/test/Conversion/VectorToLLVM/vector-mask-to-llvm.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: mlir-opt %s --convert-vector-to-llvm='force-32bit-vector-indices=1 use-opaque-pointers=1' | FileCheck %s --check-prefix=CMP32
2-
// RUN: mlir-opt %s --convert-vector-to-llvm='force-32bit-vector-indices=0 use-opaque-pointers=1' | FileCheck %s --check-prefix=CMP64
1+
// RUN: mlir-opt %s --convert-vector-to-llvm='force-32bit-vector-indices=1' | FileCheck %s --check-prefix=CMP32
2+
// RUN: mlir-opt %s --convert-vector-to-llvm='force-32bit-vector-indices=0' | FileCheck %s --check-prefix=CMP64
33

44
// CMP32-LABEL: @genbool_var_1d(
55
// CMP32-SAME: %[[ARG:.*]]: index)

mlir/test/Conversion/VectorToLLVM/vector-reduction-to-llvm.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: mlir-opt %s -convert-vector-to-llvm='use-opaque-pointers=1' -split-input-file | FileCheck %s
2-
// RUN: mlir-opt %s -convert-vector-to-llvm='reassociate-fp-reductions use-opaque-pointers=1' -split-input-file | FileCheck %s --check-prefix=REASSOC
1+
// RUN: mlir-opt %s -convert-vector-to-llvm -split-input-file | FileCheck %s
2+
// RUN: mlir-opt %s -convert-vector-to-llvm='reassociate-fp-reductions' -split-input-file | FileCheck %s --check-prefix=REASSOC
33

44
// CHECK-LABEL: @reduce_add_f32(
55
// CHECK-SAME: %[[A:.*]]: vector<16xf32>)

mlir/test/Conversion/VectorToLLVM/vector-scalable-memcpy.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt %s -convert-vector-to-llvm='use-opaque-pointers=1' | mlir-opt | FileCheck %s
1+
// RUN: mlir-opt %s -convert-vector-to-llvm | mlir-opt | FileCheck %s
22

33
// CHECK: vector_scalable_memcopy([[SRC:%arg[0-9]+]]: memref<?xf32>, [[DST:%arg[0-9]+]]
44
func.func @vector_scalable_memcopy(%src : memref<?xf32>, %dst : memref<?xf32>, %size : index) {

mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// RUN: mlir-opt %s -convert-vector-to-llvm='use-opaque-pointers=1' -split-input-file | FileCheck %s
2-
1+
// RUN: mlir-opt %s -convert-vector-to-llvm -split-input-file | FileCheck %s
32

43
func.func @bitcast_f32_to_i32_vector_0d(%input: vector<f32>) -> vector<i32> {
54
%0 = vector.bitcast %input : vector<f32> to vector<i32>

0 commit comments

Comments
 (0)