Skip to content

Commit 2f7ec77

Browse files
committed
[mlir][spirv] NFC: place ops in the proper file for their categories
This commit moves dangling ops in the main ops.td file to the proper file matching their categories. This makes ops.td as purely including all category files. Differential Revision: https://reviews.llvm.org/D94413
1 parent 24faa87 commit 2f7ec77

File tree

15 files changed

+1908
-1847
lines changed

15 files changed

+1908
-1847
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
//===-- SPIRVBarrierOps.td - MLIR SPIR-V Barrier Ops -------*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file contains barrier ops for the SPIR-V dialect. It corresponds
10+
// to "3.32.20. Barrrier Instructions" of the SPIR-V spec.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef MLIR_DIALECT_SPIRV_IR_BARRIER_OPS
15+
#define MLIR_DIALECT_SPIRV_IR_BARRIER_OPS
16+
17+
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
18+
19+
// -----
20+
21+
def SPV_ControlBarrierOp : SPV_Op<"ControlBarrier", []> {
22+
let summary = [{
23+
Wait for other invocations of this module to reach the current point of
24+
execution.
25+
}];
26+
27+
let description = [{
28+
All invocations of this module within Execution scope must reach this
29+
point of execution before any invocation will proceed beyond it.
30+
31+
When Execution is Workgroup or larger, behavior is undefined if this
32+
instruction is used in control flow that is non-uniform within
33+
Execution. When Execution is Subgroup or Invocation, the behavior of
34+
this instruction in non-uniform control flow is defined by the client
35+
API.
36+
37+
If Semantics is not None, this instruction also serves as an
38+
OpMemoryBarrier instruction, and must also perform and adhere to the
39+
description and semantics of an OpMemoryBarrier instruction with the
40+
same Memory and Semantics operands. This allows atomically specifying
41+
both a control barrier and a memory barrier (that is, without needing
42+
two instructions). If Semantics is None, Memory is ignored.
43+
44+
Before version 1.3, it is only valid to use this instruction with
45+
TessellationControl, GLCompute, or Kernel execution models. There is no
46+
such restriction starting with version 1.3.
47+
48+
When used with the TessellationControl execution model, it also
49+
implicitly synchronizes the Output Storage Class: Writes to Output
50+
variables performed by any invocation executed prior to a
51+
OpControlBarrier will be visible to any other invocation after return
52+
from that OpControlBarrier.
53+
54+
<!-- End of AutoGen section -->
55+
56+
```
57+
scope ::= `"CrossDevice"` | `"Device"` | `"Workgroup"` | ...
58+
59+
memory-semantics ::= `"None"` | `"Acquire"` | "Release"` | ...
60+
61+
control-barrier-op ::= `spv.ControlBarrier` scope, scope, memory-semantics
62+
```
63+
64+
#### Example:
65+
66+
```mlir
67+
spv.ControlBarrier "Workgroup", "Device", "Acquire|UniformMemory"
68+
69+
```
70+
}];
71+
72+
let arguments = (ins
73+
SPV_ScopeAttr:$execution_scope,
74+
SPV_ScopeAttr:$memory_scope,
75+
SPV_MemorySemanticsAttr:$memory_semantics
76+
);
77+
78+
let results = (outs);
79+
80+
let verifier = [{ return verifyMemorySemantics(*this); }];
81+
82+
let autogenSerialization = 0;
83+
84+
let assemblyFormat = [{
85+
$execution_scope `,` $memory_scope `,` $memory_semantics attr-dict
86+
}];
87+
}
88+
89+
// -----
90+
91+
def SPV_MemoryBarrierOp : SPV_Op<"MemoryBarrier", []> {
92+
let summary = "Control the order that memory accesses are observed.";
93+
94+
let description = [{
95+
Ensures that memory accesses issued before this instruction will be
96+
observed before memory accesses issued after this instruction. This
97+
control is ensured only for memory accesses issued by this invocation
98+
and observed by another invocation executing within Memory scope. If the
99+
Vulkan memory model is declared, this ordering only applies to memory
100+
accesses that use the NonPrivatePointer memory operand or
101+
NonPrivateTexel image operand.
102+
103+
Semantics declares what kind of memory is being controlled and what kind
104+
of control to apply.
105+
106+
To execute both a memory barrier and a control barrier, see
107+
OpControlBarrier.
108+
109+
<!-- End of AutoGen section -->
110+
111+
```
112+
scope ::= `"CrossDevice"` | `"Device"` | `"Workgroup"` | ...
113+
114+
memory-semantics ::= `"None"` | `"Acquire"` | `"Release"` | ...
115+
116+
memory-barrier-op ::= `spv.MemoryBarrier` scope, memory-semantics
117+
```
118+
119+
#### Example:
120+
121+
```mlir
122+
spv.MemoryBarrier "Device", "Acquire|UniformMemory"
123+
124+
```
125+
}];
126+
127+
let arguments = (ins
128+
SPV_ScopeAttr:$memory_scope,
129+
SPV_MemorySemanticsAttr:$memory_semantics
130+
);
131+
132+
let results = (outs);
133+
134+
let verifier = [{ return verifyMemorySemantics(*this); }];
135+
136+
let autogenSerialization = 0;
137+
138+
let assemblyFormat = "$memory_scope `,` $memory_semantics attr-dict";
139+
}
140+
141+
#endif // MLIR_DIALECT_SPIRV_IR_BARRIER_OPS

0 commit comments

Comments
 (0)