-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[MLIR][SPIR-V] Drop commas from split barrier operations ASM format #116673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add conversion to LLVM for `SPV_INTEL_split_barrier` operations via conversion to SPIR-V built-ins. Signed-off-by: Victor Perez <victor.perez@codeplay.com>
Drop commas from split barrier operations assembly format. Signed-off-by: Victor Perez <victor.perez@codeplay.com>
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-spirv Author: Victor Perez (victor-eds) ChangesDrop commas from split barrier operations assembly format. Signed-off-by: Victor Perez <victor.perez@codeplay.com> Depends on #116648, review ec8d354 only. Full diff: https://github.com/llvm/llvm-project/pull/116673.diff 5 Files Affected:
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVIntelExtOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVIntelExtOps.td
index 8ff7d0d63469fd..82d26e365fb243 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVIntelExtOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVIntelExtOps.td
@@ -131,7 +131,7 @@ class SPIRV_IntelSplitBarrierOp<string mnemonic>
let results = (outs);
let assemblyFormat = [{
- $execution_scope `,` $memory_scope `,` $memory_semantics attr-dict
+ $execution_scope $memory_scope $memory_semantics attr-dict
}];
let hasVerifier = 0;
@@ -160,7 +160,7 @@ def SPIRV_INTELControlBarrierArriveOp
#### Example:
```mlir
- spirv.ControlBarrierArrive <Workgroup>, <Device>, <Acquire|UniformMemory>
+ spirv.ControlBarrierArrive <Workgroup> <Device> <Acquire|UniformMemory>
```
}];
}
@@ -194,7 +194,7 @@ def SPIRV_INTELControlBarrierWaitOp
#### Example:
```mlir
- spirv.ControlBarrierWait <Workgroup>, <Device>, <Acquire|UniformMemory>
+ spirv.ControlBarrierWait <Workgroup> <Device> <Acquire|UniformMemory>
```
}];
}
diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
index ef0508e7ef5f0e..b11511f21d03d4 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
@@ -1057,17 +1057,21 @@ static LLVM::CallOp createSPIRVBuiltinCall(Location loc, OpBuilder &builder,
return call;
}
-class ControlBarrierPattern
- : public SPIRVToLLVMConversion<spirv::ControlBarrierOp> {
+template <typename BarrierOpTy>
+class ControlBarrierPattern : public SPIRVToLLVMConversion<BarrierOpTy> {
public:
- using SPIRVToLLVMConversion<spirv::ControlBarrierOp>::SPIRVToLLVMConversion;
+ using OpAdaptor = typename SPIRVToLLVMConversion<BarrierOpTy>::OpAdaptor;
+
+ using SPIRVToLLVMConversion<BarrierOpTy>::SPIRVToLLVMConversion;
+
+ static constexpr StringRef getFuncName();
LogicalResult
- matchAndRewrite(spirv::ControlBarrierOp controlBarrierOp, OpAdaptor adaptor,
+ matchAndRewrite(BarrierOpTy controlBarrierOp, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
- constexpr StringLiteral funcName = "_Z22__spirv_ControlBarrieriii";
+ constexpr StringRef funcName = getFuncName();
Operation *symbolTable =
- controlBarrierOp->getParentWithTrait<OpTrait::SymbolTable>();
+ controlBarrierOp->template getParentWithTrait<OpTrait::SymbolTable>();
Type i32 = rewriter.getI32Type();
@@ -1266,6 +1270,24 @@ class GroupReducePattern : public SPIRVToLLVMConversion<ReduceOp> {
}
};
+template <>
+constexpr StringRef
+ControlBarrierPattern<spirv::ControlBarrierOp>::getFuncName() {
+ return "_Z22__spirv_ControlBarrieriii";
+}
+
+template <>
+constexpr StringRef
+ControlBarrierPattern<spirv::INTELControlBarrierArriveOp>::getFuncName() {
+ return "_Z33__spirv_ControlBarrierArriveINTELiii";
+}
+
+template <>
+constexpr StringRef
+ControlBarrierPattern<spirv::INTELControlBarrierWaitOp>::getFuncName() {
+ return "_Z31__spirv_ControlBarrierWaitINTELiii";
+}
+
/// Converts `spirv.mlir.loop` to LLVM dialect. All blocks within selection
/// should be reachable for conversion to succeed. The structure of the loop in
/// LLVM dialect will be the following:
@@ -1899,7 +1921,9 @@ void mlir::populateSPIRVToLLVMConversionPatterns(
ReturnPattern, ReturnValuePattern,
// Barrier ops
- ControlBarrierPattern,
+ ControlBarrierPattern<spirv::ControlBarrierOp>,
+ ControlBarrierPattern<spirv::INTELControlBarrierArriveOp>,
|
I'll merge this when CI passes as it has no functional effects other than dropping a comma from ASM representation to adhere to convention. |
Drop commas from split barrier operations assembly format.
Signed-off-by: Victor Perez victor.perez@codeplay.com
Depends on #116648, review ec8d354 only.