Skip to content

Commit 8182568

Browse files
authored
[MLIR][GPUToLLVMSPV] Update ConvertGpuOpsToLLVMSPVOps's option (#118818)
## Description This PR updates the `ConvertGpuOpsToLLVMSPVOps`'s option by replacing the `index-bitwidth` with a boolean option `use-64bit-index` (similar to the `ConvertGPUToSPIRV` option). The reason for this modification is because the `ConvertGpuOpsToLLVMSPVOps`: > Generate LLVM operations to be ingested by a SPIR-V backend for gpu operations In the context of SPIR-V specifications only two physical addressing models are allowed: `Physical32` and `Physical64`. This change guarantees output sanity by preventing invalid or unsupported index bitwidths from being specified.
1 parent 0cbdad4 commit 8182568

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

mlir/include/mlir/Conversion/Passes.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,9 @@ def ConvertGpuOpsToLLVMSPVOps : Pass<"convert-gpu-to-llvm-spv", "gpu::GPUModuleO
553553
"Generate LLVM operations to be ingested by a SPIR-V backend for gpu operations";
554554
let dependentDialects = ["LLVM::LLVMDialect"];
555555
let options = [
556-
Option<"indexBitwidth", "index-bitwidth", "unsigned",
557-
/*default=kDeriveIndexBitwidthFromDataLayout*/"0",
558-
"Bitwidth of the index type, 0 to use size of machine word">,
556+
Option<"use64bitIndex", "use-64bit-index",
557+
"bool", /*default=*/"false",
558+
"Use 64-bit integers to convert index types">,
559559
];
560560
}
561561

mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,7 @@ struct GPUToLLVMSPVConversionPass final
409409
RewritePatternSet patterns(context);
410410

411411
LowerToLLVMOptions options(context);
412-
if (indexBitwidth != kDeriveIndexBitwidthFromDataLayout)
413-
options.overrideIndexBitwidth(indexBitwidth);
414-
412+
options.overrideIndexBitwidth(this->use64bitIndex ? 64 : 32);
415413
LLVMTypeConverter converter(context, options);
416414
LLVMConversionTarget target(*context);
417415

mlir/test/Conversion/GPUToLLVMSPV/gpu-to-llvm-spv.mlir

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv))" -split-input-file -verify-diagnostics %s \
1+
// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv{use-64bit-index=true}))" -split-input-file -verify-diagnostics %s \
22
// RUN: | FileCheck --check-prefixes=CHECK-64,CHECK %s
3-
// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv{index-bitwidth=32}))" -split-input-file -verify-diagnostics %s \
3+
// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv))" -split-input-file -verify-diagnostics %s \
4+
// RUN: | FileCheck --check-prefixes=CHECK-32,CHECK %s
5+
// RUN: mlir-opt -pass-pipeline="builtin.module(gpu.module(convert-gpu-to-llvm-spv{use-64bit-index=false}))" -split-input-file -verify-diagnostics %s \
46
// RUN: | FileCheck --check-prefixes=CHECK-32,CHECK %s
57

68
gpu.module @builtins {

0 commit comments

Comments
 (0)