diff options
author | Christian Ulmann <christian.ulmann@nextsilicon.com> | 2023-10-17 07:55:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-17 07:55:00 +0200 |
commit | fbde19a664e5fd7196080fb4ff0aeaa31dce8508 (patch) | |
tree | 8a760c84abbaae8ef2eec731e6327b533b4057be /mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp | |
parent | 8ddca6b2c19c826244f58081c591a8baba2040ef (diff) | |
download | llvm-fbde19a664e5fd7196080fb4ff0aeaa31dce8508.zip llvm-fbde19a664e5fd7196080fb4ff0aeaa31dce8508.tar.gz llvm-fbde19a664e5fd7196080fb4ff0aeaa31dce8508.tar.bz2 |
[MLIR][LLVM] Change addressof builders to use opaque pointers (#69215)
This commit changes the builders of the `llvm.mlir.addressof` operations
to no longer produce typed pointers.
As a consequence, a GPU to NVVM pattern and the toy example LLVM lowerings had to be updated, as they still relied on typed pointers.
Diffstat (limited to 'mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp')
-rw-r--r-- | mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp index 96d8fce..59823c6 100644 --- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp +++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp @@ -441,7 +441,7 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite( Location loc = gpuPrintfOp->getLoc(); mlir::Type llvmI8 = typeConverter->convertType(rewriter.getIntegerType(8)); - mlir::Type i8Ptr = LLVM::LLVMPointerType::get(llvmI8); + mlir::Type ptrType = LLVM::LLVMPointerType::get(rewriter.getContext()); // Note: this is the GPUModule op, not the ModuleOp that surrounds it // This ensures that global constants and declarations are placed within @@ -449,7 +449,7 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite( auto moduleOp = gpuPrintfOp->getParentOfType<gpu::GPUModuleOp>(); auto vprintfType = - LLVM::LLVMFunctionType::get(rewriter.getI32Type(), {i8Ptr, i8Ptr}); + LLVM::LLVMFunctionType::get(rewriter.getI32Type(), {ptrType, ptrType}); LLVM::LLVMFuncOp vprintfDecl = getOrDefineFunction(moduleOp, loc, rewriter, "vprintf", vprintfType); @@ -473,7 +473,7 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite( // Get a pointer to the format string's first element Value globalPtr = rewriter.create<LLVM::AddressOfOp>(loc, global); Value stringStart = rewriter.create<LLVM::GEPOp>( - loc, i8Ptr, globalPtr, ArrayRef<LLVM::GEPArg>{0, 0}); + loc, ptrType, ptrType, globalPtr, ArrayRef<LLVM::GEPArg>{0, 0}); SmallVector<Type> types; SmallVector<Value> args; // Promote and pack the arguments into a stack allocation. @@ -490,18 +490,17 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite( } Type structType = LLVM::LLVMStructType::getLiteral(gpuPrintfOp.getContext(), types); - Type structPtrType = LLVM::LLVMPointerType::get(structType); Value one = rewriter.create<LLVM::ConstantOp>(loc, rewriter.getI64Type(), rewriter.getIndexAttr(1)); - Value tempAlloc = rewriter.create<LLVM::AllocaOp>(loc, structPtrType, one, - /*alignment=*/0); + Value tempAlloc = + rewriter.create<LLVM::AllocaOp>(loc, ptrType, structType, one, + /*alignment=*/0); for (auto [index, arg] : llvm::enumerate(args)) { - Value ptr = rewriter.create<LLVM::GEPOp>( - loc, LLVM::LLVMPointerType::get(arg.getType()), tempAlloc, - ArrayRef<LLVM::GEPArg>{0, index}); + Value ptr = + rewriter.create<LLVM::GEPOp>(loc, ptrType, arg.getType(), tempAlloc, + ArrayRef<LLVM::GEPArg>{0, index}); rewriter.create<LLVM::StoreOp>(loc, arg, ptr); } - tempAlloc = rewriter.create<LLVM::BitcastOp>(loc, i8Ptr, tempAlloc); std::array<Value, 2> printfArgs = {stringStart, tempAlloc}; rewriter.create<LLVM::CallOp>(loc, vprintfDecl, printfArgs); |