[Mlir-commits] [mlir] [mlir][SPIRV] update SPIRV Atomic Ops to assemblyFormat (PR #76323)
Alex Beloi
llvmlistbot at llvm.org
Thu Jan 4 14:54:15 PST 2024
https://github.com/alexbeloi updated https://github.com/llvm/llvm-project/pull/76323
>From 4b0496098c5e35d05df4b0c61cf8c78ac11e21d0 Mon Sep 17 00:00:00 2001
From: Alex Beloi <alexbeloi at google.com>
Date: Sun, 24 Dec 2023 08:49:01 +0000
Subject: [PATCH 1/5] update SPIRV Atomic Ops to assemblyFormat
Declarative assemblyFormat ODS is more concice and requires less boiler
plate than filling out CPP interfaces.
---
.../mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td | 257 ++++++++++--------
mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp | 216 ---------------
mlir/test/Conversion/MemRefToSPIRV/alloc.mlir | 4 +-
.../test/Conversion/MemRefToSPIRV/atomic.mlir | 14 +-
.../MemRefToSPIRV/bitwidth-emulation.mlir | 28 +-
mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir | 88 +++---
mlir/test/Dialect/SPIRV/IR/availability.mlir | 2 +-
mlir/test/Dialect/SPIRV/IR/target-env.mlir | 2 +-
.../Dialect/SPIRV/Transforms/inlining.mlir | 4 +-
mlir/test/Target/SPIRV/atomic-ops.mlir | 60 ++--
mlir/test/Target/SPIRV/debug.mlir | 2 +-
11 files changed, 246 insertions(+), 431 deletions(-)
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
index f2032e940d080b..3f63571e800c7f 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
@@ -14,37 +14,47 @@
#ifndef MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
#define MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
-class SPIRV_AtomicUpdateOp<string mnemonic, list<Trait> traits = []> :
- SPIRV_Op<mnemonic, traits> {
- let arguments = (ins
- SPIRV_AnyPtr:$pointer,
- SPIRV_ScopeAttr:$memory_scope,
- SPIRV_MemorySemanticsAttr:$semantics
- );
-
- let results = (outs
- SPIRV_Integer:$result
- );
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
+include "mlir/Interfaces/SideEffectInterfaces.td"
+
+class PointeeTypeMatchTrait<string pointer, string name>
+ : TypesMatchWith<"$" # name # " type matches pointee type of " # "$" # pointer, pointer,
+ name, "$_self.cast<PointerType>().getPointeeType()">;
+
+// -----
+
+class SPIRV_AtomicUpdateOp<string mnemonic, list<Trait> traits = []>
+ : SPIRV_Op<mnemonic,
+ !listconcat(traits,
+ [PointeeTypeMatchTrait<"pointer", "result">])> {
+ let arguments = (ins SPIRV_AnyPtr
+ : $pointer, SPIRV_ScopeAttr
+ : $memory_scope, SPIRV_MemorySemanticsAttr
+ : $semantics);
+
+ let results = (outs SPIRV_Integer : $result);
+
+ let assemblyFormat = [{
+ $memory_scope $semantics operands attr-dict `:` type($pointer)
+ }];
}
-class SPIRV_AtomicUpdateWithValueOp<string mnemonic, list<Trait> traits = []> :
- SPIRV_Op<mnemonic, traits> {
- let arguments = (ins
- SPIRV_AnyPtr:$pointer,
- SPIRV_ScopeAttr:$memory_scope,
- SPIRV_MemorySemanticsAttr:$semantics,
- SPIRV_Integer:$value
- );
-
- let results = (outs
- SPIRV_Integer:$result
- );
-
- let builders = [
- OpBuilder<(ins "Value":$pointer, "::mlir::spirv::Scope":$scope,
- "::mlir::spirv::MemorySemantics":$memory, "Value":$value),
- [{build($_builder, $_state, value.getType(), pointer, scope, memory, value);}]>
- ];
+class SPIRV_AtomicUpdateWithValueOp<string mnemonic, list<Trait> traits = []>
+ : SPIRV_Op<mnemonic, !listconcat(traits, [
+ PointeeTypeMatchTrait<"pointer", "value">,
+ PointeeTypeMatchTrait<"pointer", "result">,
+ ])> {
+ let arguments = (ins SPIRV_AnyPtr
+ : $pointer, SPIRV_ScopeAttr
+ : $memory_scope, SPIRV_MemorySemanticsAttr
+ : $semantics, SPIRV_Integer
+ : $value);
+
+ let results = (outs SPIRV_Integer : $result);
+
+ let assemblyFormat = [{
+ $memory_scope $semantics operands attr-dict `:` type($pointer)
+ }];
}
// -----
@@ -52,7 +62,7 @@ class SPIRV_AtomicUpdateWithValueOp<string mnemonic, list<Trait> traits = []> :
def SPIRV_AtomicAndOp : SPIRV_AtomicUpdateWithValueOp<"AtomicAnd", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -74,9 +84,9 @@ def SPIRV_AtomicAndOp : SPIRV_AtomicUpdateWithValueOp<"AtomicAnd", []> {
<!-- End of AutoGen section -->
```
- scope ::= `"CrossDevice"` | `"Device"` | `"Workgroup"` | ...
+ scope ::= `<CrossDevice>` | `<Device>` | `<Workgroup>` | ...
- memory-semantics ::= `"None"` | `"Acquire"` | "Release"` | ...
+ memory-semantics ::= `<None>` | `<Acquire>` | <Release>` | ...
atomic-and-op ::=
`spirv.AtomicAnd` scope memory-semantics
@@ -86,7 +96,7 @@ def SPIRV_AtomicAndOp : SPIRV_AtomicUpdateWithValueOp<"AtomicAnd", []> {
#### Example:
```mlir
- %0 = spirv.AtomicAnd "Device" "None" %pointer, %value :
+ %0 = spirv.AtomicAnd <Device> <None> %pointer, %value :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -94,10 +104,14 @@ def SPIRV_AtomicAndOp : SPIRV_AtomicUpdateWithValueOp<"AtomicAnd", []> {
// -----
-def SPIRV_AtomicCompareExchangeOp : SPIRV_Op<"AtomicCompareExchange", []> {
+def SPIRV_AtomicCompareExchangeOp : SPIRV_Op<"AtomicCompareExchange", [
+ PointeeTypeMatchTrait<"pointer", "result">,
+ PointeeTypeMatchTrait<"pointer", "value">,
+ PointeeTypeMatchTrait<"pointer", "comparator">,
+]> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -139,29 +153,35 @@ def SPIRV_AtomicCompareExchangeOp : SPIRV_Op<"AtomicCompareExchange", []> {
#### Example:
```
- %0 = spirv.AtomicCompareExchange "Workgroup" "Acquire" "None"
+ %0 = spirv.AtomicCompareExchange <Workgroup> <Acquire> <None>
%pointer, %value, %comparator
: !spirv.ptr<i32, WorkGroup>
```
}];
- let arguments = (ins
- SPIRV_AnyPtr:$pointer,
- SPIRV_ScopeAttr:$memory_scope,
- SPIRV_MemorySemanticsAttr:$equal_semantics,
- SPIRV_MemorySemanticsAttr:$unequal_semantics,
- SPIRV_Integer:$value,
- SPIRV_Integer:$comparator
- );
+ let arguments = (ins SPIRV_AnyPtr
+ : $pointer, SPIRV_ScopeAttr
+ : $memory_scope, SPIRV_MemorySemanticsAttr
+ : $equal_semantics, SPIRV_MemorySemanticsAttr
+ : $unequal_semantics, SPIRV_Integer
+ : $value, SPIRV_Integer
+ : $comparator);
+
+ let results = (outs SPIRV_Integer : $result);
- let results = (outs
- SPIRV_Integer:$result
- );
+ let assemblyFormat = [{
+ $memory_scope $equal_semantics $unequal_semantics operands attr-dict `:`
+ type($pointer)
+ }];
}
// -----
-def SPIRV_AtomicCompareExchangeWeakOp : SPIRV_Op<"AtomicCompareExchangeWeak", []> {
+def SPIRV_AtomicCompareExchangeWeakOp : SPIRV_Op<"AtomicCompareExchangeWeak", [
+ PointeeTypeMatchTrait<"pointer", "result">,
+ PointeeTypeMatchTrait<"pointer", "value">,
+ PointeeTypeMatchTrait<"pointer", "comparator">,
+]> {
let summary = "Deprecated (use OpAtomicCompareExchange).";
let description = [{
@@ -181,39 +201,42 @@ def SPIRV_AtomicCompareExchangeWeakOp : SPIRV_Op<"AtomicCompareExchangeWeak", []
#### Example:
```mlir
- %0 = spirv.AtomicCompareExchangeWeak "Workgroup" "Acquire" "None"
+ %0 = spirv.AtomicCompareExchangeWeak <Workgroup> <Acquire> <None>
%pointer, %value, %comparator
: !spirv.ptr<i32, WorkGroup>
```
}];
let availability = [
- MinVersion<SPIRV_V_1_0>,
- MaxVersion<SPIRV_V_1_3>,
- Extension<[]>,
+ MinVersion<SPIRV_V_1_0>, MaxVersion<SPIRV_V_1_3>, Extension<[]>,
Capability<[SPIRV_C_Kernel]>
];
- let arguments = (ins
- SPIRV_AnyPtr:$pointer,
- SPIRV_ScopeAttr:$memory_scope,
- SPIRV_MemorySemanticsAttr:$equal_semantics,
- SPIRV_MemorySemanticsAttr:$unequal_semantics,
- SPIRV_Integer:$value,
- SPIRV_Integer:$comparator
- );
-
- let results = (outs
- SPIRV_Integer:$result
- );
+ let arguments = (ins SPIRV_AnyPtr
+ : $pointer, SPIRV_ScopeAttr
+ : $memory_scope, SPIRV_MemorySemanticsAttr
+ : $equal_semantics, SPIRV_MemorySemanticsAttr
+ : $unequal_semantics, SPIRV_Integer
+ : $value, SPIRV_Integer
+ : $comparator);
+
+ let results = (outs SPIRV_Integer : $result);
+
+ let assemblyFormat = [{
+ $memory_scope $equal_semantics $unequal_semantics operands attr-dict `:`
+ type($pointer)
+ }];
}
// -----
-def SPIRV_AtomicExchangeOp : SPIRV_Op<"AtomicExchange", []> {
+def SPIRV_AtomicExchangeOp : SPIRV_Op<"AtomicExchange", [
+ PointeeTypeMatchTrait<"pointer", "value">,
+ PointeeTypeMatchTrait<"pointer", "result">,
+]> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -243,26 +266,30 @@ def SPIRV_AtomicExchangeOp : SPIRV_Op<"AtomicExchange", []> {
#### Example:
```mlir
- %0 = spirv.AtomicExchange "Workgroup" "Acquire" %pointer, %value,
+ %0 = spirv.AtomicExchange <Workgroup> <Acquire> %pointer, %value,
: !spirv.ptr<i32, WorkGroup>
```
}];
- let arguments = (ins
- SPIRV_AnyPtr:$pointer,
- SPIRV_ScopeAttr:$memory_scope,
- SPIRV_MemorySemanticsAttr:$semantics,
- SPIRV_Numerical:$value
- );
+ let arguments = (ins SPIRV_AnyPtr
+ : $pointer, SPIRV_ScopeAttr
+ : $memory_scope, SPIRV_MemorySemanticsAttr
+ : $semantics, SPIRV_Numerical
+ : $value);
+
+ let results = (outs SPIRV_Numerical : $result);
- let results = (outs
- SPIRV_Numerical:$result
- );
+ let assemblyFormat = [{
+ $memory_scope $semantics operands attr-dict `:` type($pointer)
+ }];
}
// -----
-def SPIRV_EXTAtomicFAddOp : SPIRV_ExtVendorOp<"AtomicFAdd", []> {
+def SPIRV_EXTAtomicFAddOp : SPIRV_ExtVendorOp<"AtomicFAdd", [
+ PointeeTypeMatchTrait<"pointer", "result">,
+ PointeeTypeMatchTrait<"pointer", "value">,
+]> {
let summary = "TBD";
let description = [{
@@ -297,28 +324,30 @@ def SPIRV_EXTAtomicFAddOp : SPIRV_ExtVendorOp<"AtomicFAdd", []> {
#### Example:
```mlir
- %0 = spirv.EXT.AtomicFAdd "Device" "None" %pointer, %value :
+ %0 = spirv.EXT.AtomicFAdd <Device> <None> %pointer, %value :
!spirv.ptr<f32, StorageBuffer>
```
}];
let availability = [
- MinVersion<SPIRV_V_1_0>,
- MaxVersion<SPIRV_V_1_6>,
- Extension<[SPV_EXT_shader_atomic_float_add]>,
- Capability<[SPIRV_C_AtomicFloat16AddEXT, SPIRV_C_AtomicFloat32AddEXT, SPIRV_C_AtomicFloat64AddEXT]>
+ MinVersion<SPIRV_V_1_0>, MaxVersion<SPIRV_V_1_6>,
+ Extension<[SPV_EXT_shader_atomic_float_add]>, Capability<[
+ SPIRV_C_AtomicFloat16AddEXT, SPIRV_C_AtomicFloat32AddEXT,
+ SPIRV_C_AtomicFloat64AddEXT
+ ]>
];
- let arguments = (ins
- SPIRV_AnyPtr:$pointer,
- SPIRV_ScopeAttr:$memory_scope,
- SPIRV_MemorySemanticsAttr:$semantics,
- SPIRV_Float:$value
- );
+ let arguments = (ins SPIRV_AnyPtr
+ : $pointer, SPIRV_ScopeAttr
+ : $memory_scope, SPIRV_MemorySemanticsAttr
+ : $semantics, SPIRV_Float
+ : $value);
+
+ let results = (outs SPIRV_Float : $result);
- let results = (outs
- SPIRV_Float:$result
- );
+ let assemblyFormat = [{
+ $memory_scope $semantics operands attr-dict `:` type($pointer)
+ }];
}
// -----
@@ -326,7 +355,7 @@ def SPIRV_EXTAtomicFAddOp : SPIRV_ExtVendorOp<"AtomicFAdd", []> {
def SPIRV_AtomicIAddOp : SPIRV_AtomicUpdateWithValueOp<"AtomicIAdd", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -356,7 +385,7 @@ def SPIRV_AtomicIAddOp : SPIRV_AtomicUpdateWithValueOp<"AtomicIAdd", []> {
#### Example:
```mlir
- %0 = spirv.AtomicIAdd "Device" "None" %pointer, %value :
+ %0 = spirv.AtomicIAdd <Device> <None> %pointer, %value :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -367,7 +396,7 @@ def SPIRV_AtomicIAddOp : SPIRV_AtomicUpdateWithValueOp<"AtomicIAdd", []> {
def SPIRV_AtomicIDecrementOp : SPIRV_AtomicUpdateOp<"AtomicIDecrement", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -396,7 +425,7 @@ def SPIRV_AtomicIDecrementOp : SPIRV_AtomicUpdateOp<"AtomicIDecrement", []> {
#### Example:
```mlir
- %0 = spirv.AtomicIDecrement "Device" "None" %pointer :
+ %0 = spirv.AtomicIDecrement <Device> <None> %pointer :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -407,7 +436,7 @@ def SPIRV_AtomicIDecrementOp : SPIRV_AtomicUpdateOp<"AtomicIDecrement", []> {
def SPIRV_AtomicIIncrementOp : SPIRV_AtomicUpdateOp<"AtomicIIncrement", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -435,7 +464,7 @@ def SPIRV_AtomicIIncrementOp : SPIRV_AtomicUpdateOp<"AtomicIIncrement", []> {
#### Example:
```mlir
- %0 = spirv.AtomicIncrement "Device" "None" %pointer :
+ %0 = spirv.AtomicIncrement <Device> <None> %pointer :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -446,7 +475,7 @@ def SPIRV_AtomicIIncrementOp : SPIRV_AtomicUpdateOp<"AtomicIIncrement", []> {
def SPIRV_AtomicISubOp : SPIRV_AtomicUpdateWithValueOp<"AtomicISub", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -477,7 +506,7 @@ def SPIRV_AtomicISubOp : SPIRV_AtomicUpdateWithValueOp<"AtomicISub", []> {
#### Example:
```mlir
- %0 = spirv.AtomicISub "Device" "None" %pointer, %value :
+ %0 = spirv.AtomicISub <Device> <None> %pointer, %value :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -488,7 +517,7 @@ def SPIRV_AtomicISubOp : SPIRV_AtomicUpdateWithValueOp<"AtomicISub", []> {
def SPIRV_AtomicOrOp : SPIRV_AtomicUpdateWithValueOp<"AtomicOr", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -518,7 +547,7 @@ def SPIRV_AtomicOrOp : SPIRV_AtomicUpdateWithValueOp<"AtomicOr", []> {
#### Example:
```mlir
- %0 = spirv.AtomicOr "Device" "None" %pointer, %value :
+ %0 = spirv.AtomicOr <Device> <None> %pointer, %value :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -529,7 +558,7 @@ def SPIRV_AtomicOrOp : SPIRV_AtomicUpdateWithValueOp<"AtomicOr", []> {
def SPIRV_AtomicSMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMax", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -560,7 +589,7 @@ def SPIRV_AtomicSMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMax", []> {
#### Example:
```mlir
- %0 = spirv.AtomicSMax "Device" "None" %pointer, %value :
+ %0 = spirv.AtomicSMax <Device> <None> %pointer, %value :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -571,7 +600,7 @@ def SPIRV_AtomicSMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMax", []> {
def SPIRV_AtomicSMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMin", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -602,7 +631,7 @@ def SPIRV_AtomicSMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMin", []> {
#### Example:
```mlir
- %0 = spirv.AtomicSMin "Device" "None" %pointer, %value :
+ %0 = spirv.AtomicSMin <Device> <None> %pointer, %value :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -610,10 +639,11 @@ def SPIRV_AtomicSMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMin", []> {
// -----
-def SPIRV_AtomicUMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMax", [UnsignedOp]> {
+def SPIRV_AtomicUMaxOp
+ : SPIRV_AtomicUpdateWithValueOp<"AtomicUMax", [UnsignedOp]> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -644,7 +674,7 @@ def SPIRV_AtomicUMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMax", [UnsignedOp
#### Example:
```mlir
- %0 = spirv.AtomicUMax "Device" "None" %pointer, %value :
+ %0 = spirv.AtomicUMax <Device> <None> %pointer, %value :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -652,10 +682,11 @@ def SPIRV_AtomicUMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMax", [UnsignedOp
// -----
-def SPIRV_AtomicUMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMin", [UnsignedOp]> {
+def SPIRV_AtomicUMinOp
+ : SPIRV_AtomicUpdateWithValueOp<"AtomicUMin", [UnsignedOp]> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -686,7 +717,7 @@ def SPIRV_AtomicUMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMin", [UnsignedOp
#### Example:
```mlir
- %0 = spirv.AtomicUMin "Device" "None" %pointer, %value :
+ %0 = spirv.AtomicUMin <Device> <None> %pointer, %value :
!spirv.ptr<i32, StorageBuffer>
```
}];
@@ -697,7 +728,7 @@ def SPIRV_AtomicUMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMin", [UnsignedOp
def SPIRV_AtomicXorOp : SPIRV_AtomicUpdateWithValueOp<"AtomicXor", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -728,7 +759,7 @@ def SPIRV_AtomicXorOp : SPIRV_AtomicUpdateWithValueOp<"AtomicXor", []> {
#### Example:
```mlir
- %0 = spirv.AtomicXor "Device" "None" %pointer, %value :
+ %0 = spirv.AtomicXor <Device> <None> %pointer, %value :
!spirv.ptr<i32, StorageBuffer>
```
}];
diff --git a/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp b/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp
index 3efa955e7d8b87..fafa96c8f67680 100644
--- a/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp
@@ -19,49 +19,6 @@ using namespace mlir::spirv::AttrNames;
namespace mlir::spirv {
-// Parses an atomic update op. If the update op does not take a value (like
-// AtomicIIncrement) `hasValue` must be false.
-static ParseResult parseAtomicUpdateOp(OpAsmParser &parser,
- OperationState &state, bool hasValue) {
- spirv::Scope scope;
- spirv::MemorySemantics memoryScope;
- SmallVector<OpAsmParser::UnresolvedOperand, 2> operandInfo;
- OpAsmParser::UnresolvedOperand ptrInfo, valueInfo;
- Type type;
- SMLoc loc;
- if (parseEnumStrAttr<spirv::ScopeAttr>(scope, parser, state,
- kMemoryScopeAttrName) ||
- parseEnumStrAttr<spirv::MemorySemanticsAttr>(memoryScope, parser, state,
- kSemanticsAttrName) ||
- parser.parseOperandList(operandInfo, (hasValue ? 2 : 1)) ||
- parser.getCurrentLocation(&loc) || parser.parseColonType(type))
- return failure();
-
- auto ptrType = llvm::dyn_cast<spirv::PointerType>(type);
- if (!ptrType)
- return parser.emitError(loc, "expected pointer type");
-
- SmallVector<Type, 2> operandTypes;
- operandTypes.push_back(ptrType);
- if (hasValue)
- operandTypes.push_back(ptrType.getPointeeType());
- if (parser.resolveOperands(operandInfo, operandTypes, parser.getNameLoc(),
- state.operands))
- return failure();
- return parser.addTypeToList(ptrType.getPointeeType(), state.types);
-}
-
-// Prints an atomic update op.
-static void printAtomicUpdateOp(Operation *op, OpAsmPrinter &printer) {
- printer << " \"";
- auto scopeAttr = op->getAttrOfType<spirv::ScopeAttr>(kMemoryScopeAttrName);
- printer << spirv::stringifyScope(scopeAttr.getValue()) << "\" \"";
- auto memorySemanticsAttr =
- op->getAttrOfType<spirv::MemorySemanticsAttr>(kSemanticsAttrName);
- printer << spirv::stringifyMemorySemantics(memorySemanticsAttr.getValue())
- << "\" " << op->getOperands() << " : " << op->getOperand(0).getType();
-}
-
template <typename T>
static StringRef stringifyTypeName();
@@ -101,46 +58,6 @@ static LogicalResult verifyAtomicUpdateOp(Operation *op) {
return success();
}
-template <typename T>
-static void printAtomicCompareExchangeImpl(T atomOp, OpAsmPrinter &printer) {
- printer << " \"" << stringifyScope(atomOp.getMemoryScope()) << "\" \""
- << stringifyMemorySemantics(atomOp.getEqualSemantics()) << "\" \""
- << stringifyMemorySemantics(atomOp.getUnequalSemantics()) << "\" "
- << atomOp.getOperands() << " : " << atomOp.getPointer().getType();
-}
-
-static ParseResult parseAtomicCompareExchangeImpl(OpAsmParser &parser,
- OperationState &state) {
- spirv::Scope memoryScope;
- spirv::MemorySemantics equalSemantics, unequalSemantics;
- SmallVector<OpAsmParser::UnresolvedOperand, 3> operandInfo;
- Type type;
- if (parseEnumStrAttr<spirv::ScopeAttr>(memoryScope, parser, state,
- kMemoryScopeAttrName) ||
- parseEnumStrAttr<spirv::MemorySemanticsAttr>(
- equalSemantics, parser, state, kEqualSemanticsAttrName) ||
- parseEnumStrAttr<spirv::MemorySemanticsAttr>(
- unequalSemantics, parser, state, kUnequalSemanticsAttrName) ||
- parser.parseOperandList(operandInfo, 3))
- return failure();
-
- auto loc = parser.getCurrentLocation();
- if (parser.parseColonType(type))
- return failure();
-
- auto ptrType = llvm::dyn_cast<spirv::PointerType>(type);
- if (!ptrType)
- return parser.emitError(loc, "expected pointer type");
-
- if (parser.resolveOperands(
- operandInfo,
- {ptrType, ptrType.getPointeeType(), ptrType.getPointeeType()},
- parser.getNameLoc(), state.operands))
- return failure();
-
- return parser.addTypeToList(ptrType.getPointeeType(), state.types);
-}
-
template <typename T>
static LogicalResult verifyAtomicCompareExchangeImpl(T atomOp) {
// According to the spec:
@@ -181,12 +98,6 @@ LogicalResult AtomicAndOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicAndOp::parse(OpAsmParser &parser, OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void AtomicAndOp::print(OpAsmPrinter &p) { printAtomicUpdateOp(*this, p); }
-
//===----------------------------------------------------------------------===//
// spirv.AtomicCompareExchangeOp
//===----------------------------------------------------------------------===//
@@ -195,15 +106,6 @@ LogicalResult AtomicCompareExchangeOp::verify() {
return verifyAtomicCompareExchangeImpl(*this);
}
-ParseResult AtomicCompareExchangeOp::parse(OpAsmParser &parser,
- OperationState &result) {
- return parseAtomicCompareExchangeImpl(parser, result);
-}
-
-void AtomicCompareExchangeOp::print(OpAsmPrinter &p) {
- printAtomicCompareExchangeImpl(*this, p);
-}
-
//===----------------------------------------------------------------------===//
// spirv.AtomicCompareExchangeWeakOp
//===----------------------------------------------------------------------===//
@@ -212,53 +114,10 @@ LogicalResult AtomicCompareExchangeWeakOp::verify() {
return verifyAtomicCompareExchangeImpl(*this);
}
-ParseResult AtomicCompareExchangeWeakOp::parse(OpAsmParser &parser,
- OperationState &result) {
- return parseAtomicCompareExchangeImpl(parser, result);
-}
-
-void AtomicCompareExchangeWeakOp::print(OpAsmPrinter &p) {
- printAtomicCompareExchangeImpl(*this, p);
-}
-
//===----------------------------------------------------------------------===//
// spirv.AtomicExchange
//===----------------------------------------------------------------------===//
-void AtomicExchangeOp::print(OpAsmPrinter &printer) {
- printer << " \"" << stringifyScope(getMemoryScope()) << "\" \""
- << stringifyMemorySemantics(getSemantics()) << "\" " << getOperands()
- << " : " << getPointer().getType();
-}
-
-ParseResult AtomicExchangeOp::parse(OpAsmParser &parser,
- OperationState &result) {
- spirv::Scope memoryScope;
- spirv::MemorySemantics semantics;
- SmallVector<OpAsmParser::UnresolvedOperand, 2> operandInfo;
- Type type;
- if (parseEnumStrAttr<spirv::ScopeAttr>(memoryScope, parser, result,
- kMemoryScopeAttrName) ||
- parseEnumStrAttr<spirv::MemorySemanticsAttr>(semantics, parser, result,
- kSemanticsAttrName) ||
- parser.parseOperandList(operandInfo, 2))
- return failure();
-
- auto loc = parser.getCurrentLocation();
- if (parser.parseColonType(type))
- return failure();
-
- auto ptrType = llvm::dyn_cast<spirv::PointerType>(type);
- if (!ptrType)
- return parser.emitError(loc, "expected pointer type");
-
- if (parser.resolveOperands(operandInfo, {ptrType, ptrType.getPointeeType()},
- parser.getNameLoc(), result.operands))
- return failure();
-
- return parser.addTypeToList(ptrType.getPointeeType(), result.types);
-}
-
LogicalResult AtomicExchangeOp::verify() {
if (getType() != getValue().getType())
return emitOpError("value operand must have the same type as the op "
@@ -283,12 +142,6 @@ LogicalResult AtomicIAddOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicIAddOp::parse(OpAsmParser &parser, OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void AtomicIAddOp::print(OpAsmPrinter &p) { printAtomicUpdateOp(*this, p); }
-
//===----------------------------------------------------------------------===//
// spirv.EXT.AtomicFAddOp
//===----------------------------------------------------------------------===//
@@ -297,15 +150,6 @@ LogicalResult EXTAtomicFAddOp::verify() {
return verifyAtomicUpdateOp<FloatType>(getOperation());
}
-ParseResult EXTAtomicFAddOp::parse(OpAsmParser &parser,
- OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void spirv::EXTAtomicFAddOp::print(OpAsmPrinter &p) {
- printAtomicUpdateOp(*this, p);
-}
-
//===----------------------------------------------------------------------===//
// spirv.AtomicIDecrementOp
//===----------------------------------------------------------------------===//
@@ -314,15 +158,6 @@ LogicalResult AtomicIDecrementOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicIDecrementOp::parse(OpAsmParser &parser,
- OperationState &result) {
- return parseAtomicUpdateOp(parser, result, false);
-}
-
-void AtomicIDecrementOp::print(OpAsmPrinter &p) {
- printAtomicUpdateOp(*this, p);
-}
-
//===----------------------------------------------------------------------===//
// spirv.AtomicIIncrementOp
//===----------------------------------------------------------------------===//
@@ -331,15 +166,6 @@ LogicalResult AtomicIIncrementOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicIIncrementOp::parse(OpAsmParser &parser,
- OperationState &result) {
- return parseAtomicUpdateOp(parser, result, false);
-}
-
-void AtomicIIncrementOp::print(OpAsmPrinter &p) {
- printAtomicUpdateOp(*this, p);
-}
-
//===----------------------------------------------------------------------===//
// spirv.AtomicISubOp
//===----------------------------------------------------------------------===//
@@ -348,12 +174,6 @@ LogicalResult AtomicISubOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicISubOp::parse(OpAsmParser &parser, OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void AtomicISubOp::print(OpAsmPrinter &p) { printAtomicUpdateOp(*this, p); }
-
//===----------------------------------------------------------------------===//
// spirv.AtomicOrOp
//===----------------------------------------------------------------------===//
@@ -362,12 +182,6 @@ LogicalResult AtomicOrOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicOrOp::parse(OpAsmParser &parser, OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void AtomicOrOp::print(OpAsmPrinter &p) { printAtomicUpdateOp(*this, p); }
-
//===----------------------------------------------------------------------===//
// spirv.AtomicSMaxOp
//===----------------------------------------------------------------------===//
@@ -376,12 +190,6 @@ LogicalResult AtomicSMaxOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicSMaxOp::parse(OpAsmParser &parser, OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void AtomicSMaxOp::print(OpAsmPrinter &p) { printAtomicUpdateOp(*this, p); }
-
//===----------------------------------------------------------------------===//
// spirv.AtomicSMinOp
//===----------------------------------------------------------------------===//
@@ -390,12 +198,6 @@ LogicalResult AtomicSMinOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicSMinOp::parse(OpAsmParser &parser, OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void AtomicSMinOp::print(OpAsmPrinter &p) { printAtomicUpdateOp(*this, p); }
-
//===----------------------------------------------------------------------===//
// spirv.AtomicUMaxOp
//===----------------------------------------------------------------------===//
@@ -404,12 +206,6 @@ LogicalResult AtomicUMaxOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicUMaxOp::parse(OpAsmParser &parser, OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void AtomicUMaxOp::print(OpAsmPrinter &p) { printAtomicUpdateOp(*this, p); }
-
//===----------------------------------------------------------------------===//
// spirv.AtomicUMinOp
//===----------------------------------------------------------------------===//
@@ -418,12 +214,6 @@ LogicalResult AtomicUMinOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicUMinOp::parse(OpAsmParser &parser, OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void AtomicUMinOp::print(OpAsmPrinter &p) { printAtomicUpdateOp(*this, p); }
-
//===----------------------------------------------------------------------===//
// spirv.AtomicXorOp
//===----------------------------------------------------------------------===//
@@ -432,10 +222,4 @@ LogicalResult AtomicXorOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-ParseResult AtomicXorOp::parse(OpAsmParser &parser, OperationState &result) {
- return parseAtomicUpdateOp(parser, result, true);
-}
-
-void AtomicXorOp::print(OpAsmPrinter &p) { printAtomicUpdateOp(*this, p); }
-
} // namespace mlir::spirv
diff --git a/mlir/test/Conversion/MemRefToSPIRV/alloc.mlir b/mlir/test/Conversion/MemRefToSPIRV/alloc.mlir
index 2a5f81544f20a8..f4fbfdf01196a6 100644
--- a/mlir/test/Conversion/MemRefToSPIRV/alloc.mlir
+++ b/mlir/test/Conversion/MemRefToSPIRV/alloc.mlir
@@ -48,8 +48,8 @@ module attributes {
// CHECK: %{{.+}} = spirv.Load "Workgroup" %[[PTR]] : i32
// CHECK: %[[LOC:.+]] = spirv.SDiv
// CHECK: %[[PTR:.+]] = spirv.AccessChain %[[VAR]][%{{.+}}, %[[LOC]]]
-// CHECK: %{{.+}} = spirv.AtomicAnd "Workgroup" "AcquireRelease" %[[PTR]], %{{.+}} : !spirv.ptr<i32, Workgroup>
-// CHECK: %{{.+}} = spirv.AtomicOr "Workgroup" "AcquireRelease" %[[PTR]], %{{.+}} : !spirv.ptr<i32, Workgroup>
+// CHECK: %{{.+}} = spirv.AtomicAnd <Workgroup> <AcquireRelease> %[[PTR]], %{{.+}} : !spirv.ptr<i32, Workgroup>
+// CHECK: %{{.+}} = spirv.AtomicOr <Workgroup> <AcquireRelease> %[[PTR]], %{{.+}} : !spirv.ptr<i32, Workgroup>
// -----
diff --git a/mlir/test/Conversion/MemRefToSPIRV/atomic.mlir b/mlir/test/Conversion/MemRefToSPIRV/atomic.mlir
index f72e12611a97ed..4729cccfb62282 100644
--- a/mlir/test/Conversion/MemRefToSPIRV/atomic.mlir
+++ b/mlir/test/Conversion/MemRefToSPIRV/atomic.mlir
@@ -6,7 +6,7 @@ module attributes {spirv.target_env = #spirv.target_env<#spirv.vce<v1.3, [Shader
// CHECK-SAME: (%[[VAL:.+]]: i32,
func.func @atomic_addi_storage_buffer(%value: i32, %memref: memref<2x3x4xi32, #spirv.storage_class<StorageBuffer>>, %i0: index, %i1: index, %i2: index) -> i32 {
// CHECK: %[[AC:.+]] = spirv.AccessChain
- // CHECK: %[[ATOMIC:.+]] = spirv.AtomicIAdd "Device" "AcquireRelease" %[[AC]], %[[VAL]] : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: %[[ATOMIC:.+]] = spirv.AtomicIAdd <Device> <AcquireRelease> %[[AC]], %[[VAL]] : !spirv.ptr<i32, StorageBuffer>
// CHECK: return %[[ATOMIC]]
%0 = memref.atomic_rmw "addi" %value, %memref[%i0, %i1, %i2] : (i32, memref<2x3x4xi32, #spirv.storage_class<StorageBuffer>>) -> i32
return %0: i32
@@ -16,7 +16,7 @@ func.func @atomic_addi_storage_buffer(%value: i32, %memref: memref<2x3x4xi32, #s
// CHECK-SAME: (%[[VAL:.+]]: i32,
func.func @atomic_maxs_workgroup(%value: i32, %memref: memref<2x3x4xi32, #spirv.storage_class<Workgroup>>, %i0: index, %i1: index, %i2: index) -> i32 {
// CHECK: %[[AC:.+]] = spirv.AccessChain
- // CHECK: %[[ATOMIC:.+]] = spirv.AtomicSMax "Workgroup" "AcquireRelease" %[[AC]], %[[VAL]] : !spirv.ptr<i32, Workgroup>
+ // CHECK: %[[ATOMIC:.+]] = spirv.AtomicSMax <Workgroup> <AcquireRelease> %[[AC]], %[[VAL]] : !spirv.ptr<i32, Workgroup>
// CHECK: return %[[ATOMIC]]
%0 = memref.atomic_rmw "maxs" %value, %memref[%i0, %i1, %i2] : (i32, memref<2x3x4xi32, #spirv.storage_class<Workgroup>>) -> i32
return %0: i32
@@ -26,7 +26,7 @@ func.func @atomic_maxs_workgroup(%value: i32, %memref: memref<2x3x4xi32, #spirv.
// CHECK-SAME: (%[[VAL:.+]]: i32,
func.func @atomic_maxu_storage_buffer(%value: i32, %memref: memref<2x3x4xi32, #spirv.storage_class<StorageBuffer>>, %i0: index, %i1: index, %i2: index) -> i32 {
// CHECK: %[[AC:.+]] = spirv.AccessChain
- // CHECK: %[[ATOMIC:.+]] = spirv.AtomicUMax "Device" "AcquireRelease" %[[AC]], %[[VAL]] : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: %[[ATOMIC:.+]] = spirv.AtomicUMax <Device> <AcquireRelease> %[[AC]], %[[VAL]] : !spirv.ptr<i32, StorageBuffer>
// CHECK: return %[[ATOMIC]]
%0 = memref.atomic_rmw "maxu" %value, %memref[%i0, %i1, %i2] : (i32, memref<2x3x4xi32, #spirv.storage_class<StorageBuffer>>) -> i32
return %0: i32
@@ -36,7 +36,7 @@ func.func @atomic_maxu_storage_buffer(%value: i32, %memref: memref<2x3x4xi32, #s
// CHECK-SAME: (%[[VAL:.+]]: i32,
func.func @atomic_mins_workgroup(%value: i32, %memref: memref<2x3x4xi32, #spirv.storage_class<Workgroup>>, %i0: index, %i1: index, %i2: index) -> i32 {
// CHECK: %[[AC:.+]] = spirv.AccessChain
- // CHECK: %[[ATOMIC:.+]] = spirv.AtomicSMin "Workgroup" "AcquireRelease" %[[AC]], %[[VAL]] : !spirv.ptr<i32, Workgroup>
+ // CHECK: %[[ATOMIC:.+]] = spirv.AtomicSMin <Workgroup> <AcquireRelease> %[[AC]], %[[VAL]] : !spirv.ptr<i32, Workgroup>
// CHECK: return %[[ATOMIC]]
%0 = memref.atomic_rmw "mins" %value, %memref[%i0, %i1, %i2] : (i32, memref<2x3x4xi32, #spirv.storage_class<Workgroup>>) -> i32
return %0: i32
@@ -46,7 +46,7 @@ func.func @atomic_mins_workgroup(%value: i32, %memref: memref<2x3x4xi32, #spirv.
// CHECK-SAME: (%[[VAL:.+]]: i32,
func.func @atomic_minu_storage_buffer(%value: i32, %memref: memref<2x3x4xi32, #spirv.storage_class<StorageBuffer>>, %i0: index, %i1: index, %i2: index) -> i32 {
// CHECK: %[[AC:.+]] = spirv.AccessChain
- // CHECK: %[[ATOMIC:.+]] = spirv.AtomicUMin "Device" "AcquireRelease" %[[AC]], %[[VAL]] : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: %[[ATOMIC:.+]] = spirv.AtomicUMin <Device> <AcquireRelease> %[[AC]], %[[VAL]] : !spirv.ptr<i32, StorageBuffer>
// CHECK: return %[[ATOMIC]]
%0 = memref.atomic_rmw "minu" %value, %memref[%i0, %i1, %i2] : (i32, memref<2x3x4xi32, #spirv.storage_class<StorageBuffer>>) -> i32
return %0: i32
@@ -56,7 +56,7 @@ func.func @atomic_minu_storage_buffer(%value: i32, %memref: memref<2x3x4xi32, #s
// CHECK-SAME: (%[[VAL:.+]]: i32,
func.func @atomic_ori_workgroup(%value: i32, %memref: memref<2x3x4xi32, #spirv.storage_class<Workgroup>>, %i0: index, %i1: index, %i2: index) -> i32 {
// CHECK: %[[AC:.+]] = spirv.AccessChain
- // CHECK: %[[ATOMIC:.+]] = spirv.AtomicOr "Workgroup" "AcquireRelease" %[[AC]], %[[VAL]] : !spirv.ptr<i32, Workgroup>
+ // CHECK: %[[ATOMIC:.+]] = spirv.AtomicOr <Workgroup> <AcquireRelease> %[[AC]], %[[VAL]] : !spirv.ptr<i32, Workgroup>
// CHECK: return %[[ATOMIC]]
%0 = memref.atomic_rmw "ori" %value, %memref[%i0, %i1, %i2] : (i32, memref<2x3x4xi32, #spirv.storage_class<Workgroup>>) -> i32
return %0: i32
@@ -66,7 +66,7 @@ func.func @atomic_ori_workgroup(%value: i32, %memref: memref<2x3x4xi32, #spirv.s
// CHECK-SAME: (%[[VAL:.+]]: i32,
func.func @atomic_andi_storage_buffer(%value: i32, %memref: memref<2x3x4xi32, #spirv.storage_class<StorageBuffer>>, %i0: index, %i1: index, %i2: index) -> i32 {
// CHECK: %[[AC:.+]] = spirv.AccessChain
- // CHECK: %[[ATOMIC:.+]] = spirv.AtomicAnd "Device" "AcquireRelease" %[[AC]], %[[VAL]] : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: %[[ATOMIC:.+]] = spirv.AtomicAnd <Device> <AcquireRelease> %[[AC]], %[[VAL]] : !spirv.ptr<i32, StorageBuffer>
// CHECK: return %[[ATOMIC]]
%0 = memref.atomic_rmw "andi" %value, %memref[%i0, %i1, %i2] : (i32, memref<2x3x4xi32, #spirv.storage_class<StorageBuffer>>) -> i32
return %0: i32
diff --git a/mlir/test/Conversion/MemRefToSPIRV/bitwidth-emulation.mlir b/mlir/test/Conversion/MemRefToSPIRV/bitwidth-emulation.mlir
index 928bd82c2cb2d8..470c8531e2e0fb 100644
--- a/mlir/test/Conversion/MemRefToSPIRV/bitwidth-emulation.mlir
+++ b/mlir/test/Conversion/MemRefToSPIRV/bitwidth-emulation.mlir
@@ -122,8 +122,8 @@ func.func @store_i1(%arg0: memref<i1, #spirv.storage_class<StorageBuffer>>, %val
// CHECK: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CASTED_ARG1]], %[[OFFSET]] : i32, i32
// CHECK: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR]] : i32
// CHECK: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]]
- // CHECK: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]]
- // CHECK: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]]
+ // CHECK: spirv.AtomicAnd <Device> <AcquireRelease> %[[PTR]], %[[MASK]]
+ // CHECK: spirv.AtomicOr <Device> <AcquireRelease> %[[PTR]], %[[STORE_VAL]]
memref.store %value, %arg0[] : memref<i1, #spirv.storage_class<StorageBuffer>>
return
}
@@ -147,8 +147,8 @@ func.func @store_i8(%arg0: memref<i8, #spirv.storage_class<StorageBuffer>>, %val
// CHECK: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32
// CHECK: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR]] : i32
// CHECK: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]]
- // CHECK: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]]
- // CHECK: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]]
+ // CHECK: spirv.AtomicAnd <Device> <AcquireRelease> %[[PTR]], %[[MASK]]
+ // CHECK: spirv.AtomicOr <Device> <AcquireRelease> %[[PTR]], %[[STORE_VAL]]
// INDEX64-DAG: %[[ARG1_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG1]] : i8 to i32
// INDEX64-DAG: %[[ARG0_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG0]]
@@ -164,8 +164,8 @@ func.func @store_i8(%arg0: memref<i8, #spirv.storage_class<StorageBuffer>>, %val
// INDEX64: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i64
// INDEX64: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR]] : i64
// INDEX64: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] : {{.+}}, i64, i64
- // INDEX64: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]]
- // INDEX64: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]]
+ // INDEX64: spirv.AtomicAnd <Device> <AcquireRelease> %[[PTR]], %[[MASK]]
+ // INDEX64: spirv.AtomicOr <Device> <AcquireRelease> %[[PTR]], %[[STORE_VAL]]
memref.store %value, %arg0[] : memref<i8, #spirv.storage_class<StorageBuffer>>
return
}
@@ -191,8 +191,8 @@ func.func @store_i16(%arg0: memref<10xi16, #spirv.storage_class<StorageBuffer>>,
// CHECK: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32
// CHECK: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[FLAT_IDX]], %[[TWO]] : i32
// CHECK: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]]
- // CHECK: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]]
- // CHECK: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]]
+ // CHECK: spirv.AtomicAnd <Device> <AcquireRelease> %[[PTR]], %[[MASK]]
+ // CHECK: spirv.AtomicOr <Device> <AcquireRelease> %[[PTR]], %[[STORE_VAL]]
memref.store %value, %arg0[%index] : memref<10xi16, #spirv.storage_class<StorageBuffer>>
return
}
@@ -262,8 +262,8 @@ func.func @store_i4(%arg0: memref<?xi4, #spirv.storage_class<StorageBuffer>>, %v
// CHECK: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[BITS]] : i32, i32
// CHECK: %[[ACCESS_INDEX:.+]] = spirv.SDiv %[[OFFSET]], %[[EIGHT]] : i32
// CHECK: %[[PTR:.+]] = spirv.AccessChain %{{.+}}[%[[ZERO]], %[[ACCESS_INDEX]]]
- // CHECK: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK2]]
- // CHECK: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]]
+ // CHECK: spirv.AtomicAnd <Device> <AcquireRelease> %[[PTR]], %[[MASK2]]
+ // CHECK: spirv.AtomicOr <Device> <AcquireRelease> %[[PTR]], %[[STORE_VAL]]
memref.store %value, %arg0[%i] : memref<?xi4, #spirv.storage_class<StorageBuffer>>
return
}
@@ -338,8 +338,8 @@ func.func @store_i8(%arg0: memref<i8, #spirv.storage_class<StorageBuffer>>, %val
// CHECK: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i32
// CHECK: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR]] : i32
// CHECK: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]]
- // CHECK: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]]
- // CHECK: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]]
+ // CHECK: spirv.AtomicAnd <Device> <AcquireRelease> %[[PTR]], %[[MASK]]
+ // CHECK: spirv.AtomicOr <Device> <AcquireRelease> %[[PTR]], %[[STORE_VAL]]
// INDEX64-DAG: %[[ARG0_CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG0]]
// INDEX64: %[[ZERO:.+]] = spirv.Constant 0 : i64
@@ -355,8 +355,8 @@ func.func @store_i8(%arg0: memref<i8, #spirv.storage_class<StorageBuffer>>, %val
// INDEX64: %[[STORE_VAL:.+]] = spirv.ShiftLeftLogical %[[CLAMPED_VAL]], %[[OFFSET]] : i32, i64
// INDEX64: %[[ACCESS_IDX:.+]] = spirv.SDiv %[[ZERO]], %[[FOUR]] : i64
// INDEX64: %[[PTR:.+]] = spirv.AccessChain %[[ARG0_CAST]][%[[ZERO]], %[[ACCESS_IDX]]] : {{.+}}, i64, i64
- // INDEX64: spirv.AtomicAnd "Device" "AcquireRelease" %[[PTR]], %[[MASK]]
- // INDEX64: spirv.AtomicOr "Device" "AcquireRelease" %[[PTR]], %[[STORE_VAL]]
+ // INDEX64: spirv.AtomicAnd <Device> <AcquireRelease> %[[PTR]], %[[MASK]]
+ // INDEX64: spirv.AtomicOr <Device> <AcquireRelease> %[[PTR]], %[[STORE_VAL]]
memref.store %value, %arg0[] : memref<i8, #spirv.storage_class<StorageBuffer>>
return
}
diff --git a/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir b/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir
index ed0e19534c1708..e1b4d79eaef955 100644
--- a/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir
+++ b/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir
@@ -5,15 +5,15 @@
//===----------------------------------------------------------------------===//
func.func @atomic_and(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
- // CHECK: spirv.AtomicAnd "Device" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicAnd "Device" "None" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicAnd <Device> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicAnd <Device> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
// -----
func.func @atomic_and(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : i32) -> i32 {
- // expected-error @+1 {{pointer operand must point to an integer value, found 'f32'}}
+ // expected-error @+1 {{'spirv.AtomicAnd' op failed to verify that $value type matches pointee type of $pointer}}
%0 = "spirv.AtomicAnd"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<f32, StorageBuffer>, i32) -> (i32)
return %0 : i32
}
@@ -22,7 +22,7 @@ func.func @atomic_and(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : i32) -> i3
// -----
func.func @atomic_and(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i64) -> i64 {
- // expected-error @+1 {{expected value to have the same type as the pointer operand's pointee type 'i32', but found 'i64'}}
+ // expected-error @+1 {{'spirv.AtomicAnd' op failed to verify that $value type matches pointee type of $pointer}}
%0 = "spirv.AtomicAnd"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, StorageBuffer>, i64) -> (i64)
return %0 : i64
}
@@ -31,7 +31,7 @@ func.func @atomic_and(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i64) -> i6
func.func @atomic_and(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
// expected-error @+1 {{expected at most one of these four memory constraints to be set: `Acquire`, `Release`,`AcquireRelease` or `SequentiallyConsistent`}}
- %0 = spirv.AtomicAnd "Device" "Acquire|Release" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicAnd <Device> <Acquire|Release> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -42,15 +42,15 @@ func.func @atomic_and(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i3
//===----------------------------------------------------------------------===//
func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32, %comparator: i32) -> i32 {
- // CHECK: spirv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %0 = spirv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicCompareExchange <Workgroup> <Release> <Acquire> %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %0 = spirv.AtomicCompareExchange <Workgroup> <Release> <Acquire> %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
return %0: i32
}
// -----
func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64, %comparator: i32) -> i32 {
- // expected-error @+1 {{value operand must have the same type as the op result, but found 'i64' vs 'i32'}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchange' op failed to verify that $value type matches pointee type of $pointer}}
%0 = "spirv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i64, i32) -> (i32)
return %0: i32
}
@@ -58,7 +58,7 @@ func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64
// -----
func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32, %comparator: i16) -> i32 {
- // expected-error @+1 {{comparator operand must have the same type as the op result, but found 'i16' vs 'i32'}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchange' op failed to verify that $comparator type matches pointee type of $pointer}}
%0 = "spirv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i32, i16) -> (i32)
return %0: i32
}
@@ -66,7 +66,7 @@ func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32
// -----
func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i64, Workgroup>, %value: i32, %comparator: i32) -> i32 {
- // expected-error @+1 {{pointer operand's pointee type must have the same as the op result type, but found 'i64' vs 'i32'}}
+ // expected-error @+1 {{spirv.AtomicCompareExchange' op failed to verify that $result type matches pointee type of $pointer}}
%0 = "spirv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i64, Workgroup>, i32, i32) -> (i32)
return %0: i32
}
@@ -78,15 +78,15 @@ func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i64, Workgroup>, %value: i32
//===----------------------------------------------------------------------===//
func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32, %comparator: i32) -> i32 {
- // CHECK: spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %0 = spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicCompareExchangeWeak <Workgroup> <Release> <Acquire> %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %0 = spirv.AtomicCompareExchangeWeak <Workgroup> <Release> <Acquire> %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
return %0: i32
}
// -----
func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64, %comparator: i32) -> i32 {
- // expected-error @+1 {{value operand must have the same type as the op result, but found 'i64' vs 'i32'}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchangeWeak' op failed to verify that $value type matches pointee type of $pointer}}
%0 = "spirv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i64, i32) -> (i32)
return %0: i32
}
@@ -94,7 +94,7 @@ func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value
// -----
func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32, %comparator: i16) -> i32 {
- // expected-error @+1 {{comparator operand must have the same type as the op result, but found 'i16' vs 'i32'}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchangeWeak' op failed to verify that $comparator type matches pointee type of $pointer}}
%0 = "spirv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i32, i16) -> (i32)
return %0: i32
}
@@ -102,7 +102,7 @@ func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value
// -----
func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i64, Workgroup>, %value: i32, %comparator: i32) -> i32 {
- // expected-error @+1 {{pointer operand's pointee type must have the same as the op result type, but found 'i64' vs 'i32'}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchangeWeak' op failed to verify that $result type matches pointee type of $pointer}}
%0 = "spirv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i64, Workgroup>, i32, i32) -> (i32)
return %0: i32
}
@@ -114,15 +114,15 @@ func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i64, Workgroup>, %value
//===----------------------------------------------------------------------===//
func.func @atomic_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32) -> i32 {
- // CHECK: spirv.AtomicExchange "Workgroup" "Release" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %0 = spirv.AtomicExchange "Workgroup" "Release" %ptr, %value: !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicExchange <Workgroup> <Release> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %0 = spirv.AtomicExchange <Workgroup> <Release> %ptr, %value: !spirv.ptr<i32, Workgroup>
return %0: i32
}
// -----
func.func @atomic_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64) -> i32 {
- // expected-error @+1 {{value operand must have the same type as the op result, but found 'i64' vs 'i32'}}
+ // expected-error @+1 {{'spirv.AtomicExchange' op failed to verify that $value type matches pointee type of $pointer}}
%0 = "spirv.AtomicExchange"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i64) -> (i32)
return %0: i32
}
@@ -130,7 +130,7 @@ func.func @atomic_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64) -> i32
// -----
func.func @atomic_exchange(%ptr: !spirv.ptr<i64, Workgroup>, %value: i32) -> i32 {
- // expected-error @+1 {{pointer operand's pointee type must have the same as the op result type, but found 'i64' vs 'i32'}}
+ // expected-error @+1 {{'spirv.AtomicExchange' op failed to verify that $value type matches pointee type of $pointer}}
%0 = "spirv.AtomicExchange"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i64, Workgroup>, i32) -> (i32)
return %0: i32
}
@@ -142,8 +142,8 @@ func.func @atomic_exchange(%ptr: !spirv.ptr<i64, Workgroup>, %value: i32) -> i32
//===----------------------------------------------------------------------===//
func.func @atomic_iadd(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
- // CHECK: spirv.AtomicIAdd "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicIAdd "Workgroup" "None" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicIAdd <Workgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicIAdd <Workgroup> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -152,8 +152,8 @@ func.func @atomic_iadd(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i
//===----------------------------------------------------------------------===//
func.func @atomic_idecrement(%ptr : !spirv.ptr<i32, StorageBuffer>) -> i32 {
- // CHECK: spirv.AtomicIDecrement "Workgroup" "None" %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicIDecrement "Workgroup" "None" %ptr : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicIDecrement <Workgroup> <None> %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicIDecrement <Workgroup> <None> %ptr : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -162,8 +162,8 @@ func.func @atomic_idecrement(%ptr : !spirv.ptr<i32, StorageBuffer>) -> i32 {
//===----------------------------------------------------------------------===//
func.func @atomic_iincrement(%ptr : !spirv.ptr<i32, StorageBuffer>) -> i32 {
- // CHECK: spirv.AtomicIIncrement "Workgroup" "None" %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicIIncrement "Workgroup" "None" %ptr : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicIIncrement <Workgroup> <None> %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicIIncrement <Workgroup> <None> %ptr : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -172,8 +172,8 @@ func.func @atomic_iincrement(%ptr : !spirv.ptr<i32, StorageBuffer>) -> i32 {
//===----------------------------------------------------------------------===//
func.func @atomic_isub(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
- // CHECK: spirv.AtomicISub "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicISub "Workgroup" "None" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicISub <Workgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicISub <Workgroup> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -182,8 +182,8 @@ func.func @atomic_isub(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i
//===----------------------------------------------------------------------===//
func.func @atomic_or(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
- // CHECK: spirv.AtomicOr "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicOr "Workgroup" "None" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicOr <Workgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicOr <Workgroup> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -192,8 +192,8 @@ func.func @atomic_or(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32
//===----------------------------------------------------------------------===//
func.func @atomic_smax(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
- // CHECK: spirv.AtomicSMax "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicSMax "Workgroup" "None" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicSMax <Workgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicSMax <Workgroup> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -202,8 +202,8 @@ func.func @atomic_smax(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i
//===----------------------------------------------------------------------===//
func.func @atomic_smin(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
- // CHECK: spirv.AtomicSMin "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicSMin "Workgroup" "None" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicSMin <Workgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicSMin <Workgroup> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -212,8 +212,8 @@ func.func @atomic_smin(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i
//===----------------------------------------------------------------------===//
func.func @atomic_umax(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
- // CHECK: spirv.AtomicUMax "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicUMax "Workgroup" "None" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicUMax <Workgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicUMax <Workgroup> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -222,8 +222,8 @@ func.func @atomic_umax(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i
//===----------------------------------------------------------------------===//
func.func @atomic_umin(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
- // CHECK: spirv.AtomicUMin "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicUMin "Workgroup" "None" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicUMin <Workgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicUMin <Workgroup> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -232,8 +232,8 @@ func.func @atomic_umin(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i
//===----------------------------------------------------------------------===//
func.func @atomic_xor(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i32 {
- // CHECK: spirv.AtomicXor "Workgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
- %0 = spirv.AtomicXor "Workgroup" "None" %ptr, %value : !spirv.ptr<i32, StorageBuffer>
+ // CHECK: spirv.AtomicXor <Workgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicXor <Workgroup> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer>
return %0 : i32
}
@@ -244,15 +244,15 @@ func.func @atomic_xor(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i3
//===----------------------------------------------------------------------===//
func.func @atomic_fadd(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : f32) -> f32 {
- // CHECK: spirv.EXT.AtomicFAdd "Device" "None" %{{.*}}, %{{.*}} : !spirv.ptr<f32, StorageBuffer>
- %0 = spirv.EXT.AtomicFAdd "Device" "None" %ptr, %value : !spirv.ptr<f32, StorageBuffer>
+ // CHECK: spirv.EXT.AtomicFAdd <Device> <None> %{{.*}}, %{{.*}} : !spirv.ptr<f32, StorageBuffer>
+ %0 = spirv.EXT.AtomicFAdd <Device> <None> %ptr, %value : !spirv.ptr<f32, StorageBuffer>
return %0 : f32
}
// -----
func.func @atomic_fadd(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : f32) -> f32 {
- // expected-error @+1 {{pointer operand must point to an float value, found 'i32'}}
+ // expected-error @+1 {{'spirv.EXT.AtomicFAdd' op failed to verify that $result type matches pointee type of $pointer}}
%0 = "spirv.EXT.AtomicFAdd"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, StorageBuffer>, f32) -> (f32)
return %0 : f32
}
@@ -260,7 +260,7 @@ func.func @atomic_fadd(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : f32) -> f
// -----
func.func @atomic_fadd(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : f64) -> f64 {
- // expected-error @+1 {{expected value to have the same type as the pointer operand's pointee type 'f32', but found 'f64'}}
+ // expected-error @+1 {{'spirv.EXT.AtomicFAdd' op failed to verify that $result type matches pointee type of $pointer}}
%0 = "spirv.EXT.AtomicFAdd"(%ptr, %value) {memory_scope = #spirv.scope<Device>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<f32, StorageBuffer>, f64) -> (f64)
return %0 : f64
}
@@ -269,6 +269,6 @@ func.func @atomic_fadd(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : f64) -> f
func.func @atomic_fadd(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : f32) -> f32 {
// expected-error @+1 {{expected at most one of these four memory constraints to be set: `Acquire`, `Release`,`AcquireRelease` or `SequentiallyConsistent`}}
- %0 = spirv.EXT.AtomicFAdd "Device" "Acquire|Release" %ptr, %value : !spirv.ptr<f32, StorageBuffer>
+ %0 = spirv.EXT.AtomicFAdd <Device> <Acquire|Release> %ptr, %value : !spirv.ptr<f32, StorageBuffer>
return %0 : f32
}
diff --git a/mlir/test/Dialect/SPIRV/IR/availability.mlir b/mlir/test/Dialect/SPIRV/IR/availability.mlir
index fb95a0c567b974..c583a48eba2704 100644
--- a/mlir/test/Dialect/SPIRV/IR/availability.mlir
+++ b/mlir/test/Dialect/SPIRV/IR/availability.mlir
@@ -16,7 +16,7 @@ func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value
// CHECK: max version: v1.3
// CHECK: extensions: [ ]
// CHECK: capabilities: [ [Kernel] ]
- %0 = spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
+ %0 = spirv.AtomicCompareExchangeWeak <Workgroup> <Release> <Acquire> %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
return %0: i32
}
diff --git a/mlir/test/Dialect/SPIRV/IR/target-env.mlir b/mlir/test/Dialect/SPIRV/IR/target-env.mlir
index 5f3292dd6814e4..273aa33e15eae2 100644
--- a/mlir/test/Dialect/SPIRV/IR/target-env.mlir
+++ b/mlir/test/Dialect/SPIRV/IR/target-env.mlir
@@ -49,7 +49,7 @@ func.func @main() {
func.func @cmp_exchange_weak_suitable_version_capabilities(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32, %comparator: i32) -> i32 attributes {
spirv.target_env = #spirv.target_env<#spirv.vce<v1.1, [Kernel, AtomicStorage], []>, #spirv.resource_limits<>>
} {
- // CHECK: spirv.AtomicCompareExchangeWeak "Workgroup" "AcquireRelease|AtomicCounterMemory" "Acquire"
+ // CHECK: spirv.AtomicCompareExchangeWeak <Workgroup> <AcquireRelease|AtomicCounterMemory> <Acquire>
%0 = "test.convert_to_atomic_compare_exchange_weak_op"(%ptr, %value, %comparator): (!spirv.ptr<i32, Workgroup>, i32, i32) -> (i32)
return %0: i32
}
diff --git a/mlir/test/Dialect/SPIRV/Transforms/inlining.mlir b/mlir/test/Dialect/SPIRV/Transforms/inlining.mlir
index d1937c44262f21..8d663b4edc4527 100644
--- a/mlir/test/Dialect/SPIRV/Transforms/inlining.mlir
+++ b/mlir/test/Dialect/SPIRV/Transforms/inlining.mlir
@@ -206,7 +206,7 @@ spirv.module Logical GLSL450 {
// CHECK: [[STOREPTR:%.*]] = spirv.AccessChain [[ADDRESS_ARG1]]
%7 = spirv.AccessChain %3[%1] : !spirv.ptr<!spirv.struct<(i32 [0])>, StorageBuffer>, i32
// CHECK-NOT: spirv.FunctionCall
- // CHECK: spirv.AtomicIAdd "Device" "AcquireRelease" [[STOREPTR]], [[VAL]]
+ // CHECK: spirv.AtomicIAdd <Device> <AcquireRelease> [[STOREPTR]], [[VAL]]
// CHECK: spirv.Branch
spirv.FunctionCall @atomic_add(%5, %7) : (i32, !spirv.ptr<i32, StorageBuffer>) -> ()
spirv.Branch ^bb2
@@ -217,7 +217,7 @@ spirv.module Logical GLSL450 {
spirv.Return
}
spirv.func @atomic_add(%arg0: i32, %arg1: !spirv.ptr<i32, StorageBuffer>) "None" {
- %0 = spirv.AtomicIAdd "Device" "AcquireRelease" %arg1, %arg0 : !spirv.ptr<i32, StorageBuffer>
+ %0 = spirv.AtomicIAdd <Device> <AcquireRelease> %arg1, %arg0 : !spirv.ptr<i32, StorageBuffer>
spirv.Return
}
spirv.EntryPoint "GLCompute" @inline_into_selection_region
diff --git a/mlir/test/Target/SPIRV/atomic-ops.mlir b/mlir/test/Target/SPIRV/atomic-ops.mlir
index 594c6faef9236e..cb7d9626e6c620 100644
--- a/mlir/test/Target/SPIRV/atomic-ops.mlir
+++ b/mlir/test/Target/SPIRV/atomic-ops.mlir
@@ -3,41 +3,41 @@
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
// CHECK-LABEL: @test_int_atomics
spirv.func @test_int_atomics(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32, %comparator: i32) -> i32 "None" {
- // CHECK: spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %0 = spirv.AtomicCompareExchangeWeak "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicAnd "Device" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %1 = spirv.AtomicAnd "Device" "None" %ptr, %value : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicIAdd "Workgroup" "Acquire" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %2 = spirv.AtomicIAdd "Workgroup" "Acquire" %ptr, %value : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicIDecrement "Workgroup" "Acquire" %{{.*}} : !spirv.ptr<i32, Workgroup>
- %3 = spirv.AtomicIDecrement "Workgroup" "Acquire" %ptr : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicIIncrement "Device" "Release" %{{.*}} : !spirv.ptr<i32, Workgroup>
- %4 = spirv.AtomicIIncrement "Device" "Release" %ptr : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicISub "Workgroup" "Acquire" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %5 = spirv.AtomicISub "Workgroup" "Acquire" %ptr, %value : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicOr "Workgroup" "AcquireRelease" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %6 = spirv.AtomicOr "Workgroup" "AcquireRelease" %ptr, %value : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicSMax "Subgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %7 = spirv.AtomicSMax "Subgroup" "None" %ptr, %value : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicSMin "Device" "Release" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %8 = spirv.AtomicSMin "Device" "Release" %ptr, %value : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicUMax "Subgroup" "None" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %9 = spirv.AtomicUMax "Subgroup" "None" %ptr, %value : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicUMin "Device" "Release" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %10 = spirv.AtomicUMin "Device" "Release" %ptr, %value : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicXor "Workgroup" "AcquireRelease" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %11 = spirv.AtomicXor "Workgroup" "AcquireRelease" %ptr, %value : !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %12 = spirv.AtomicCompareExchange "Workgroup" "Release" "Acquire" %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
- // CHECK: spirv.AtomicExchange "Workgroup" "Release" %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
- %13 = spirv.AtomicExchange "Workgroup" "Release" %ptr, %value: !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicCompareExchangeWeak <Workgroup> <Release> <Acquire> %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %0 = spirv.AtomicCompareExchangeWeak <Workgroup> <Release> <Acquire> %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicAnd <Device> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %1 = spirv.AtomicAnd <Device> <None> %ptr, %value : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicIAdd <Workgroup> <Acquire> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %2 = spirv.AtomicIAdd <Workgroup> <Acquire> %ptr, %value : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicIDecrement <Workgroup> <Acquire> %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %3 = spirv.AtomicIDecrement <Workgroup> <Acquire> %ptr : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicIIncrement <Device> <Release> %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %4 = spirv.AtomicIIncrement <Device> <Release> %ptr : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicISub <Workgroup> <Acquire> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %5 = spirv.AtomicISub <Workgroup> <Acquire> %ptr, %value : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicOr <Workgroup> <AcquireRelease> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %6 = spirv.AtomicOr <Workgroup> <AcquireRelease> %ptr, %value : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicSMax <Subgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %7 = spirv.AtomicSMax <Subgroup> <None> %ptr, %value : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicSMin <Device> <Release> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %8 = spirv.AtomicSMin <Device> <Release> %ptr, %value : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicUMax <Subgroup> <None> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %9 = spirv.AtomicUMax <Subgroup> <None> %ptr, %value : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicUMin <Device> <Release> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %10 = spirv.AtomicUMin <Device> <Release> %ptr, %value : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicXor <Workgroup> <AcquireRelease> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %11 = spirv.AtomicXor <Workgroup> <AcquireRelease> %ptr, %value : !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicCompareExchange <Workgroup> <Release> <Acquire> %{{.*}}, %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %12 = spirv.AtomicCompareExchange <Workgroup> <Release> <Acquire> %ptr, %value, %comparator: !spirv.ptr<i32, Workgroup>
+ // CHECK: spirv.AtomicExchange <Workgroup> <Release> %{{.*}}, %{{.*}} : !spirv.ptr<i32, Workgroup>
+ %13 = spirv.AtomicExchange <Workgroup> <Release> %ptr, %value: !spirv.ptr<i32, Workgroup>
spirv.ReturnValue %0: i32
}
// CHECK-LABEL: @test_float_atomics
spirv.func @test_float_atomics(%ptr: !spirv.ptr<f32, Workgroup>, %value: f32) -> f32 "None" {
- // CHECK: spirv.EXT.AtomicFAdd "Workgroup" "Acquire" %{{.*}}, %{{.*}} : !spirv.ptr<f32, Workgroup>
- %0 = spirv.EXT.AtomicFAdd "Workgroup" "Acquire" %ptr, %value : !spirv.ptr<f32, Workgroup>
+ // CHECK: spirv.EXT.AtomicFAdd <Workgroup> <Acquire> %{{.*}}, %{{.*}} : !spirv.ptr<f32, Workgroup>
+ %0 = spirv.EXT.AtomicFAdd <Workgroup> <Acquire> %ptr, %value : !spirv.ptr<f32, Workgroup>
spirv.ReturnValue %0: f32
}
}
diff --git a/mlir/test/Target/SPIRV/debug.mlir b/mlir/test/Target/SPIRV/debug.mlir
index 21f90309cde3c2..50c83d876bef38 100644
--- a/mlir/test/Target/SPIRV/debug.mlir
+++ b/mlir/test/Target/SPIRV/debug.mlir
@@ -13,7 +13,7 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
spirv.func @atomic(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32, %comparator: i32) "None" {
// CHECK: loc({{".*debug.mlir"}}:16:10)
- %1 = spirv.AtomicAnd "Device" "None" %ptr, %value : !spirv.ptr<i32, Workgroup>
+ %1 = spirv.AtomicAnd <Device> <None> %ptr, %value : !spirv.ptr<i32, Workgroup>
spirv.Return
}
>From b5472ca3fc4a7ced2f43cf779e3c1e92196773c2 Mon Sep 17 00:00:00 2001
From: Alex Beloi <alexbeloi at google.com>
Date: Sun, 24 Dec 2023 08:49:01 +0000
Subject: [PATCH 2/5] revert formatting changes and remove redundant type
verification
---
.../mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td | 150 ++++++++++--------
mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp | 55 -------
2 files changed, 84 insertions(+), 121 deletions(-)
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
index 3f63571e800c7f..5659fa76add4a3 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
@@ -18,8 +18,9 @@ include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class PointeeTypeMatchTrait<string pointer, string name>
- : TypesMatchWith<"$" # name # " type matches pointee type of " # "$" # pointer, pointer,
- name, "$_self.cast<PointerType>().getPointeeType()">;
+ : TypesMatchWith<
+ "$" # name # " type matches pointee type of " # "$" # pointer, pointer,
+ name, "llvm::cast<PointerType>($_self).getPointeeType()">;
// -----
@@ -27,12 +28,15 @@ class SPIRV_AtomicUpdateOp<string mnemonic, list<Trait> traits = []>
: SPIRV_Op<mnemonic,
!listconcat(traits,
[PointeeTypeMatchTrait<"pointer", "result">])> {
- let arguments = (ins SPIRV_AnyPtr
- : $pointer, SPIRV_ScopeAttr
- : $memory_scope, SPIRV_MemorySemanticsAttr
- : $semantics);
+ let arguments = (ins
+ SPIRV_AnyPtr:$pointer,
+ SPIRV_ScopeAttr:$memory_scope,
+ SPIRV_MemorySemanticsAttr:$semantics
+ );
- let results = (outs SPIRV_Integer : $result);
+ let results = (outs
+ SPIRV_Integer:$result
+ );
let assemblyFormat = [{
$memory_scope $semantics operands attr-dict `:` type($pointer)
@@ -44,13 +48,16 @@ class SPIRV_AtomicUpdateWithValueOp<string mnemonic, list<Trait> traits = []>
PointeeTypeMatchTrait<"pointer", "value">,
PointeeTypeMatchTrait<"pointer", "result">,
])> {
- let arguments = (ins SPIRV_AnyPtr
- : $pointer, SPIRV_ScopeAttr
- : $memory_scope, SPIRV_MemorySemanticsAttr
- : $semantics, SPIRV_Integer
- : $value);
+ let arguments = (ins
+ SPIRV_AnyPtr:$pointer,
+ SPIRV_ScopeAttr:$memory_scope,
+ SPIRV_MemorySemanticsAttr:$semantics,
+ SPIRV_Integer:$value
+ );
- let results = (outs SPIRV_Integer : $result);
+ let results = (outs
+ SPIRV_Integer:$result
+ );
let assemblyFormat = [{
$memory_scope $semantics operands attr-dict `:` type($pointer)
@@ -62,7 +69,7 @@ class SPIRV_AtomicUpdateWithValueOp<string mnemonic, list<Trait> traits = []>
def SPIRV_AtomicAndOp : SPIRV_AtomicUpdateWithValueOp<"AtomicAnd", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -111,7 +118,7 @@ def SPIRV_AtomicCompareExchangeOp : SPIRV_Op<"AtomicCompareExchange", [
]> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -159,19 +166,22 @@ def SPIRV_AtomicCompareExchangeOp : SPIRV_Op<"AtomicCompareExchange", [
```
}];
- let arguments = (ins SPIRV_AnyPtr
- : $pointer, SPIRV_ScopeAttr
- : $memory_scope, SPIRV_MemorySemanticsAttr
- : $equal_semantics, SPIRV_MemorySemanticsAttr
- : $unequal_semantics, SPIRV_Integer
- : $value, SPIRV_Integer
- : $comparator);
+ let arguments = (ins
+ SPIRV_AnyPtr:$pointer,
+ SPIRV_ScopeAttr:$memory_scope,
+ SPIRV_MemorySemanticsAttr:$equal_semantics,
+ SPIRV_MemorySemanticsAttr:$unequal_semantics,
+ SPIRV_Integer:$value,
+ SPIRV_Integer:$comparator
+ );
- let results = (outs SPIRV_Integer : $result);
+ let results = (outs
+ SPIRV_Integer:$result
+ );
let assemblyFormat = [{
$memory_scope $equal_semantics $unequal_semantics operands attr-dict `:`
- type($pointer)
+ type($pointer)
}];
}
@@ -208,23 +218,28 @@ def SPIRV_AtomicCompareExchangeWeakOp : SPIRV_Op<"AtomicCompareExchangeWeak", [
}];
let availability = [
- MinVersion<SPIRV_V_1_0>, MaxVersion<SPIRV_V_1_3>, Extension<[]>,
+ MinVersion<SPIRV_V_1_0>,
+ MaxVersion<SPIRV_V_1_3>,
+ Extension<[]>,
Capability<[SPIRV_C_Kernel]>
];
- let arguments = (ins SPIRV_AnyPtr
- : $pointer, SPIRV_ScopeAttr
- : $memory_scope, SPIRV_MemorySemanticsAttr
- : $equal_semantics, SPIRV_MemorySemanticsAttr
- : $unequal_semantics, SPIRV_Integer
- : $value, SPIRV_Integer
- : $comparator);
+ let arguments = (ins
+ SPIRV_AnyPtr:$pointer,
+ SPIRV_ScopeAttr:$memory_scope,
+ SPIRV_MemorySemanticsAttr:$equal_semantics,
+ SPIRV_MemorySemanticsAttr:$unequal_semantics,
+ SPIRV_Integer:$value,
+ SPIRV_Integer:$comparator
+ );
- let results = (outs SPIRV_Integer : $result);
+ let results = (outs
+ SPIRV_Integer:$result
+ );
let assemblyFormat = [{
$memory_scope $equal_semantics $unequal_semantics operands attr-dict `:`
- type($pointer)
+ type($pointer)
}];
}
@@ -236,7 +251,7 @@ def SPIRV_AtomicExchangeOp : SPIRV_Op<"AtomicExchange", [
]> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -271,13 +286,16 @@ def SPIRV_AtomicExchangeOp : SPIRV_Op<"AtomicExchange", [
```
}];
- let arguments = (ins SPIRV_AnyPtr
- : $pointer, SPIRV_ScopeAttr
- : $memory_scope, SPIRV_MemorySemanticsAttr
- : $semantics, SPIRV_Numerical
- : $value);
+ let arguments = (ins
+ SPIRV_AnyPtr:$pointer,
+ SPIRV_ScopeAttr:$memory_scope,
+ SPIRV_MemorySemanticsAttr:$semantics,
+ SPIRV_Numerical:$value
+ );
- let results = (outs SPIRV_Numerical : $result);
+ let results = (outs
+ SPIRV_Numerical:$result
+ );
let assemblyFormat = [{
$memory_scope $semantics operands attr-dict `:` type($pointer)
@@ -330,20 +348,22 @@ def SPIRV_EXTAtomicFAddOp : SPIRV_ExtVendorOp<"AtomicFAdd", [
}];
let availability = [
- MinVersion<SPIRV_V_1_0>, MaxVersion<SPIRV_V_1_6>,
- Extension<[SPV_EXT_shader_atomic_float_add]>, Capability<[
- SPIRV_C_AtomicFloat16AddEXT, SPIRV_C_AtomicFloat32AddEXT,
- SPIRV_C_AtomicFloat64AddEXT
- ]>
+ MinVersion<SPIRV_V_1_0>,
+ MaxVersion<SPIRV_V_1_6>,
+ Extension<[SPV_EXT_shader_atomic_float_add]>,
+ Capability<[SPIRV_C_AtomicFloat16AddEXT, SPIRV_C_AtomicFloat32AddEXT, SPIRV_C_AtomicFloat64AddEXT]>
];
- let arguments = (ins SPIRV_AnyPtr
- : $pointer, SPIRV_ScopeAttr
- : $memory_scope, SPIRV_MemorySemanticsAttr
- : $semantics, SPIRV_Float
- : $value);
+ let arguments = (ins
+ SPIRV_AnyPtr:$pointer,
+ SPIRV_ScopeAttr:$memory_scope,
+ SPIRV_MemorySemanticsAttr:$semantics,
+ SPIRV_Float:$value
+ );
- let results = (outs SPIRV_Float : $result);
+ let results = (outs
+ SPIRV_Float:$result
+ );
let assemblyFormat = [{
$memory_scope $semantics operands attr-dict `:` type($pointer)
@@ -355,7 +375,7 @@ def SPIRV_EXTAtomicFAddOp : SPIRV_ExtVendorOp<"AtomicFAdd", [
def SPIRV_AtomicIAddOp : SPIRV_AtomicUpdateWithValueOp<"AtomicIAdd", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -396,7 +416,7 @@ def SPIRV_AtomicIAddOp : SPIRV_AtomicUpdateWithValueOp<"AtomicIAdd", []> {
def SPIRV_AtomicIDecrementOp : SPIRV_AtomicUpdateOp<"AtomicIDecrement", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -436,7 +456,7 @@ def SPIRV_AtomicIDecrementOp : SPIRV_AtomicUpdateOp<"AtomicIDecrement", []> {
def SPIRV_AtomicIIncrementOp : SPIRV_AtomicUpdateOp<"AtomicIIncrement", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -475,7 +495,7 @@ def SPIRV_AtomicIIncrementOp : SPIRV_AtomicUpdateOp<"AtomicIIncrement", []> {
def SPIRV_AtomicISubOp : SPIRV_AtomicUpdateWithValueOp<"AtomicISub", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -517,7 +537,7 @@ def SPIRV_AtomicISubOp : SPIRV_AtomicUpdateWithValueOp<"AtomicISub", []> {
def SPIRV_AtomicOrOp : SPIRV_AtomicUpdateWithValueOp<"AtomicOr", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -558,7 +578,7 @@ def SPIRV_AtomicOrOp : SPIRV_AtomicUpdateWithValueOp<"AtomicOr", []> {
def SPIRV_AtomicSMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMax", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -600,7 +620,7 @@ def SPIRV_AtomicSMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMax", []> {
def SPIRV_AtomicSMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMin", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -639,11 +659,10 @@ def SPIRV_AtomicSMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMin", []> {
// -----
-def SPIRV_AtomicUMaxOp
- : SPIRV_AtomicUpdateWithValueOp<"AtomicUMax", [UnsignedOp]> {
+def SPIRV_AtomicUMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMax", [UnsignedOp]> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -682,11 +701,10 @@ def SPIRV_AtomicUMaxOp
// -----
-def SPIRV_AtomicUMinOp
- : SPIRV_AtomicUpdateWithValueOp<"AtomicUMin", [UnsignedOp]> {
+def SPIRV_AtomicUMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMin", [UnsignedOp]> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
@@ -728,7 +746,7 @@ def SPIRV_AtomicUMinOp
def SPIRV_AtomicXorOp : SPIRV_AtomicUpdateWithValueOp<"AtomicXor", []> {
let summary = [{
Perform the following steps atomically with respect to any other atomic
- accesses within Scope to the same location:
+ accesses within Scope to the same location:
}];
let description = [{
diff --git a/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp b/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp
index fafa96c8f67680..37851f9e3f202f 100644
--- a/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp
@@ -42,13 +42,6 @@ static LogicalResult verifyAtomicUpdateOp(Operation *op) {
<< stringifyTypeName<ExpectedElementType>()
<< " value, found " << elementType;
- if (op->getNumOperands() > 1) {
- auto valueType = op->getOperand(1).getType();
- if (valueType != elementType)
- return op->emitOpError("expected value to have the same type as the "
- "pointer operand's pointee type ")
- << elementType << ", but found " << valueType;
- }
auto memorySemantics =
op->getAttrOfType<spirv::MemorySemanticsAttr>(kSemanticsAttrName)
.getValue();
@@ -58,38 +51,6 @@ static LogicalResult verifyAtomicUpdateOp(Operation *op) {
return success();
}
-template <typename T>
-static LogicalResult verifyAtomicCompareExchangeImpl(T atomOp) {
- // According to the spec:
- // "The type of Value must be the same as Result Type. The type of the value
- // pointed to by Pointer must be the same as Result Type. This type must also
- // match the type of Comparator."
- if (atomOp.getType() != atomOp.getValue().getType())
- return atomOp.emitOpError("value operand must have the same type as the op "
- "result, but found ")
- << atomOp.getValue().getType() << " vs " << atomOp.getType();
-
- if (atomOp.getType() != atomOp.getComparator().getType())
- return atomOp.emitOpError(
- "comparator operand must have the same type as the op "
- "result, but found ")
- << atomOp.getComparator().getType() << " vs " << atomOp.getType();
-
- Type pointeeType =
- llvm::cast<spirv::PointerType>(atomOp.getPointer().getType())
- .getPointeeType();
- if (atomOp.getType() != pointeeType)
- return atomOp.emitOpError(
- "pointer operand's pointee type must have the same "
- "as the op result type, but found ")
- << pointeeType << " vs " << atomOp.getType();
-
- // TODO: Unequal cannot be set to Release or Acquire and Release.
- // In addition, Unequal cannot be set to a stronger memory-order then Equal.
-
- return success();
-}
-
//===----------------------------------------------------------------------===//
// spirv.AtomicAndOp
//===----------------------------------------------------------------------===//
@@ -98,22 +59,6 @@ LogicalResult AtomicAndOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-//===----------------------------------------------------------------------===//
-// spirv.AtomicCompareExchangeOp
-//===----------------------------------------------------------------------===//
-
-LogicalResult AtomicCompareExchangeOp::verify() {
- return verifyAtomicCompareExchangeImpl(*this);
-}
-
-//===----------------------------------------------------------------------===//
-// spirv.AtomicCompareExchangeWeakOp
-//===----------------------------------------------------------------------===//
-
-LogicalResult AtomicCompareExchangeWeakOp::verify() {
- return verifyAtomicCompareExchangeImpl(*this);
-}
-
//===----------------------------------------------------------------------===//
// spirv.AtomicExchange
//===----------------------------------------------------------------------===//
>From 04b830772c5ead8e921962cfb1bc477d5b349a3e Mon Sep 17 00:00:00 2001
From: Alex Beloi <alexbeloi at google.com>
Date: Thu, 4 Jan 2024 01:56:17 +0000
Subject: [PATCH 3/5] set correct `hasVerifier` and `hasCustomAssemblyFormat`
on Atomic ops
---
.../mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td | 13 ++++++++++++
mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp | 20 -------------------
2 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
index 5659fa76add4a3..1a52ef4b339b79 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
@@ -41,6 +41,8 @@ class SPIRV_AtomicUpdateOp<string mnemonic, list<Trait> traits = []>
let assemblyFormat = [{
$memory_scope $semantics operands attr-dict `:` type($pointer)
}];
+
+ let hasCustomAssemblyFormat = 0;
}
class SPIRV_AtomicUpdateWithValueOp<string mnemonic, list<Trait> traits = []>
@@ -62,6 +64,8 @@ class SPIRV_AtomicUpdateWithValueOp<string mnemonic, list<Trait> traits = []>
let assemblyFormat = [{
$memory_scope $semantics operands attr-dict `:` type($pointer)
}];
+
+ let hasCustomAssemblyFormat = 0;
}
// -----
@@ -183,6 +187,9 @@ def SPIRV_AtomicCompareExchangeOp : SPIRV_Op<"AtomicCompareExchange", [
$memory_scope $equal_semantics $unequal_semantics operands attr-dict `:`
type($pointer)
}];
+
+ let hasCustomAssemblyFormat = 0;
+ let hasVerifier = 0;
}
// -----
@@ -241,6 +248,9 @@ def SPIRV_AtomicCompareExchangeWeakOp : SPIRV_Op<"AtomicCompareExchangeWeak", [
$memory_scope $equal_semantics $unequal_semantics operands attr-dict `:`
type($pointer)
}];
+
+ let hasCustomAssemblyFormat = 0;
+ let hasVerifier = 0;
}
// -----
@@ -300,6 +310,9 @@ def SPIRV_AtomicExchangeOp : SPIRV_Op<"AtomicExchange", [
let assemblyFormat = [{
$memory_scope $semantics operands attr-dict `:` type($pointer)
}];
+
+ let hasCustomAssemblyFormat = 0;
+ let hasVerifier = 0;
}
// -----
diff --git a/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp b/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp
index 37851f9e3f202f..7e33e91414e0bf 100644
--- a/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/AtomicOps.cpp
@@ -59,26 +59,6 @@ LogicalResult AtomicAndOp::verify() {
return verifyAtomicUpdateOp<IntegerType>(getOperation());
}
-//===----------------------------------------------------------------------===//
-// spirv.AtomicExchange
-//===----------------------------------------------------------------------===//
-
-LogicalResult AtomicExchangeOp::verify() {
- if (getType() != getValue().getType())
- return emitOpError("value operand must have the same type as the op "
- "result, but found ")
- << getValue().getType() << " vs " << getType();
-
- Type pointeeType =
- llvm::cast<spirv::PointerType>(getPointer().getType()).getPointeeType();
- if (getType() != pointeeType)
- return emitOpError("pointer operand's pointee type must have the same "
- "as the op result type, but found ")
- << pointeeType << " vs " << getType();
-
- return success();
-}
-
//===----------------------------------------------------------------------===//
// spirv.AtomicIAddOp
//===----------------------------------------------------------------------===//
>From 753f4307cc0592250c04ed0535f148aa85fac0d9 Mon Sep 17 00:00:00 2001
From: Alex Beloi <alexbeloi at google.com>
Date: Thu, 4 Jan 2024 22:39:07 +0000
Subject: [PATCH 4/5] update summary and tests on `PointeeTypeMatchTrait` to
remove `$`
---
.../mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td | 6 ++---
mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir | 24 +++++++++----------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
index 1a52ef4b339b79..fb707727569fb8 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
@@ -19,8 +19,8 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
class PointeeTypeMatchTrait<string pointer, string name>
: TypesMatchWith<
- "$" # name # " type matches pointee type of " # "$" # pointer, pointer,
- name, "llvm::cast<PointerType>($_self).getPointeeType()">;
+ "`" # name # "` type matches pointee type of " # "`" # pointer # "`",
+ pointer, name, "llvm::cast<PointerType>($_self).getPointeeType()">;
// -----
@@ -95,7 +95,7 @@ def SPIRV_AtomicAndOp : SPIRV_AtomicUpdateWithValueOp<"AtomicAnd", []> {
<!-- End of AutoGen section -->
```
- scope ::= `<CrossDevice>` | `<Device>` | `<Workgroup>` | ...
+ scopae ::= `<CrossDevice>` | `<Device>` | `<Workgroup>` | ...
memory-semantics ::= `<None>` | `<Acquire>` | <Release>` | ...
diff --git a/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir b/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir
index e1b4d79eaef955..cc0abd3a42dcba 100644
--- a/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir
+++ b/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir
@@ -13,7 +13,7 @@ func.func @atomic_and(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i32) -> i3
// -----
func.func @atomic_and(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : i32) -> i32 {
- // expected-error @+1 {{'spirv.AtomicAnd' op failed to verify that $value type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.AtomicAnd' op failed to verify that `value` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicAnd"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<f32, StorageBuffer>, i32) -> (i32)
return %0 : i32
}
@@ -22,7 +22,7 @@ func.func @atomic_and(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : i32) -> i3
// -----
func.func @atomic_and(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : i64) -> i64 {
- // expected-error @+1 {{'spirv.AtomicAnd' op failed to verify that $value type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.AtomicAnd' op failed to verify that `value` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicAnd"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, StorageBuffer>, i64) -> (i64)
return %0 : i64
}
@@ -50,7 +50,7 @@ func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32
// -----
func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64, %comparator: i32) -> i32 {
- // expected-error @+1 {{'spirv.AtomicCompareExchange' op failed to verify that $value type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchange' op failed to verify that `value` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i64, i32) -> (i32)
return %0: i32
}
@@ -58,7 +58,7 @@ func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64
// -----
func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32, %comparator: i16) -> i32 {
- // expected-error @+1 {{'spirv.AtomicCompareExchange' op failed to verify that $comparator type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchange' op failed to verify that `comparator` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i32, i16) -> (i32)
return %0: i32
}
@@ -66,7 +66,7 @@ func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32
// -----
func.func @atomic_compare_exchange(%ptr: !spirv.ptr<i64, Workgroup>, %value: i32, %comparator: i32) -> i32 {
- // expected-error @+1 {{spirv.AtomicCompareExchange' op failed to verify that $result type matches pointee type of $pointer}}
+ // expected-error @+1 {{spirv.AtomicCompareExchange' op failed to verify that `result` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicCompareExchange"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i64, Workgroup>, i32, i32) -> (i32)
return %0: i32
}
@@ -86,7 +86,7 @@ func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value
// -----
func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64, %comparator: i32) -> i32 {
- // expected-error @+1 {{'spirv.AtomicCompareExchangeWeak' op failed to verify that $value type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchangeWeak' op failed to verify that `value` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i64, i32) -> (i32)
return %0: i32
}
@@ -94,7 +94,7 @@ func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value
// -----
func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32, %comparator: i16) -> i32 {
- // expected-error @+1 {{'spirv.AtomicCompareExchangeWeak' op failed to verify that $comparator type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchangeWeak' op failed to verify that `comparator` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i32, i16) -> (i32)
return %0: i32
}
@@ -102,7 +102,7 @@ func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i32, Workgroup>, %value
// -----
func.func @atomic_compare_exchange_weak(%ptr: !spirv.ptr<i64, Workgroup>, %value: i32, %comparator: i32) -> i32 {
- // expected-error @+1 {{'spirv.AtomicCompareExchangeWeak' op failed to verify that $result type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.AtomicCompareExchangeWeak' op failed to verify that `result` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicCompareExchangeWeak"(%ptr, %value, %comparator) {memory_scope = #spirv.scope<Workgroup>, equal_semantics = #spirv.memory_semantics<AcquireRelease>, unequal_semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i64, Workgroup>, i32, i32) -> (i32)
return %0: i32
}
@@ -122,7 +122,7 @@ func.func @atomic_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i32) -> i32
// -----
func.func @atomic_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64) -> i32 {
- // expected-error @+1 {{'spirv.AtomicExchange' op failed to verify that $value type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.AtomicExchange' op failed to verify that `value` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicExchange"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, Workgroup>, i64) -> (i32)
return %0: i32
}
@@ -130,7 +130,7 @@ func.func @atomic_exchange(%ptr: !spirv.ptr<i32, Workgroup>, %value: i64) -> i32
// -----
func.func @atomic_exchange(%ptr: !spirv.ptr<i64, Workgroup>, %value: i32) -> i32 {
- // expected-error @+1 {{'spirv.AtomicExchange' op failed to verify that $value type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.AtomicExchange' op failed to verify that `value` type matches pointee type of `pointer`}}
%0 = "spirv.AtomicExchange"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i64, Workgroup>, i32) -> (i32)
return %0: i32
}
@@ -252,7 +252,7 @@ func.func @atomic_fadd(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : f32) -> f
// -----
func.func @atomic_fadd(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : f32) -> f32 {
- // expected-error @+1 {{'spirv.EXT.AtomicFAdd' op failed to verify that $result type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.EXT.AtomicFAdd' op failed to verify that `result` type matches pointee type of `pointer`}}
%0 = "spirv.EXT.AtomicFAdd"(%ptr, %value) {memory_scope = #spirv.scope<Workgroup>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<i32, StorageBuffer>, f32) -> (f32)
return %0 : f32
}
@@ -260,7 +260,7 @@ func.func @atomic_fadd(%ptr : !spirv.ptr<i32, StorageBuffer>, %value : f32) -> f
// -----
func.func @atomic_fadd(%ptr : !spirv.ptr<f32, StorageBuffer>, %value : f64) -> f64 {
- // expected-error @+1 {{'spirv.EXT.AtomicFAdd' op failed to verify that $result type matches pointee type of $pointer}}
+ // expected-error @+1 {{'spirv.EXT.AtomicFAdd' op failed to verify that `result` type matches pointee type of `pointer`}}
%0 = "spirv.EXT.AtomicFAdd"(%ptr, %value) {memory_scope = #spirv.scope<Device>, semantics = #spirv.memory_semantics<AcquireRelease>} : (!spirv.ptr<f32, StorageBuffer>, f64) -> (f64)
return %0 : f64
}
>From 0956e7f6dc701b2d3c9c168c9332136d934ba993 Mon Sep 17 00:00:00 2001
From: Alex Beloi <alexbeloi at google.com>
Date: Thu, 4 Jan 2024 22:53:31 +0000
Subject: [PATCH 5/5] remote redundant syntax in description for atomic ops
---
.../mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td | 96 -------------------
1 file changed, 96 deletions(-)
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
index fb707727569fb8..88f902110b8619 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
@@ -94,16 +94,6 @@ def SPIRV_AtomicAndOp : SPIRV_AtomicUpdateWithValueOp<"AtomicAnd", []> {
<!-- End of AutoGen section -->
- ```
- scopae ::= `<CrossDevice>` | `<Device>` | `<Workgroup>` | ...
-
- memory-semantics ::= `<None>` | `<Acquire>` | <Release>` | ...
-
- atomic-and-op ::=
- `spirv.AtomicAnd` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -154,13 +144,6 @@ def SPIRV_AtomicCompareExchangeOp : SPIRV_Op<"AtomicCompareExchange", [
<!-- End of AutoGen section -->
- ```
- atomic-compare-exchange-op ::=
- `spirv.AtomicCompareExchange` scope memory-semantics memory-semantics
- ssa-use `,` ssa-use `,` ssa-use
- `:` spv-pointer-type
- ```
-
#### Example:
```
@@ -208,13 +191,6 @@ def SPIRV_AtomicCompareExchangeWeakOp : SPIRV_Op<"AtomicCompareExchangeWeak", [
<!-- End of AutoGen section -->
- ```
- atomic-compare-exchange-weak-op ::=
- `spirv.AtomicCompareExchangeWeak` scope memory-semantics memory-semantics
- ssa-use `,` ssa-use `,` ssa-use
- `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -282,12 +258,6 @@ def SPIRV_AtomicExchangeOp : SPIRV_Op<"AtomicExchange", [
<!-- End of AutoGen section -->
- ```
- atomic-exchange-op ::=
- `spirv.AtomicCompareExchange` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -346,12 +316,6 @@ def SPIRV_EXTAtomicFAddOp : SPIRV_ExtVendorOp<"AtomicFAdd", [
Memory must be a valid memory Scope.
- ```
- atomic-fadd-op ::=
- `spirv.EXT.AtomicFAdd` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -409,12 +373,6 @@ def SPIRV_AtomicIAddOp : SPIRV_AtomicUpdateWithValueOp<"AtomicIAdd", []> {
<!-- End of AutoGen section -->
- ```
- atomic-iadd-op ::=
- `spirv.AtomicIAdd` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -449,12 +407,6 @@ def SPIRV_AtomicIDecrementOp : SPIRV_AtomicUpdateOp<"AtomicIDecrement", []> {
<!-- End of AutoGen section -->
- ```
- atomic-idecrement-op ::=
- `spirv.AtomicIDecrement` scope memory-semantics ssa-use
- `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -488,12 +440,6 @@ def SPIRV_AtomicIIncrementOp : SPIRV_AtomicUpdateOp<"AtomicIIncrement", []> {
<!-- End of AutoGen section -->
- ```
- atomic-iincrement-op ::=
- `spirv.AtomicIIncrement` scope memory-semantics ssa-use
- `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -530,12 +476,6 @@ def SPIRV_AtomicISubOp : SPIRV_AtomicUpdateWithValueOp<"AtomicISub", []> {
<!-- End of AutoGen section -->
- ```
- atomic-isub-op ::=
- `spirv.AtomicISub` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -571,12 +511,6 @@ def SPIRV_AtomicOrOp : SPIRV_AtomicUpdateWithValueOp<"AtomicOr", []> {
<!-- End of AutoGen section -->
- ```
- atomic-or-op ::=
- `spirv.AtomicOr` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -613,12 +547,6 @@ def SPIRV_AtomicSMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMax", []> {
<!-- End of AutoGen section -->
- ```
- atomic-smax-op ::=
- `spirv.AtomicSMax` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -655,12 +583,6 @@ def SPIRV_AtomicSMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicSMin", []> {
<!-- End of AutoGen section -->
- ```
- atomic-smin-op ::=
- `spirv.AtomicSMin` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -697,12 +619,6 @@ def SPIRV_AtomicUMaxOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMax", [UnsignedOp
<!-- End of AutoGen section -->
- ```
- atomic-umax-op ::=
- `spirv.AtomicUMax` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -739,12 +655,6 @@ def SPIRV_AtomicUMinOp : SPIRV_AtomicUpdateWithValueOp<"AtomicUMin", [UnsignedOp
<!-- End of AutoGen section -->
- ```
- atomic-umin-op ::=
- `spirv.AtomicUMin` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
@@ -781,12 +691,6 @@ def SPIRV_AtomicXorOp : SPIRV_AtomicUpdateWithValueOp<"AtomicXor", []> {
<!-- End of AutoGen section -->
- ```
- atomic-xor-op ::=
- `spirv.AtomicXor` scope memory-semantics
- ssa-use `,` ssa-use `:` spv-pointer-type
- ```
-
#### Example:
```mlir
More information about the Mlir-commits
mailing list