|
| 1 | +//===- DXSAAtomicOps.td - DXSA atomic 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 | +// Atomic instructions of the DXSA dialect. |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +#ifndef MLIR_DIALECT_DXSA_IR_DXSAATOMICOPS |
| 14 | +#define MLIR_DIALECT_DXSA_IR_DXSAATOMICOPS |
| 15 | + |
| 16 | +include "mlir/Dialect/DXSA/IR/DXSAOpBase.td" |
| 17 | + |
| 18 | +//===----------------------------------------------------------------------===// |
| 19 | +// DXSA shared base for immediate atomic ops returning the prior value |
| 20 | +//===----------------------------------------------------------------------===// |
| 21 | + |
| 22 | +class DXSA_ImmAtomicBinaryOp<string mnemonic> : DXSA_Op<mnemonic> { |
| 23 | + let arguments = (ins |
| 24 | + DXSA_DstOperandAttr:$dst0, |
| 25 | + DXSA_DstOperandAttr:$dst1, |
| 26 | + DXSA_SrcOperandAttr:$dst_address, |
| 27 | + DXSA_SrcOperandAttr:$src0); |
| 28 | + let results = (outs); |
| 29 | + let assemblyFormat = |
| 30 | + "$dst0 `,` $dst1 `,` $dst_address `,` $src0 attr-dict"; |
| 31 | +} |
| 32 | + |
| 33 | +//===----------------------------------------------------------------------===// |
| 34 | +// dxsa.imm_atomic_iadd |
| 35 | +//===----------------------------------------------------------------------===// |
| 36 | + |
| 37 | +def DXSA_ImmAtomicIAdd : DXSA_ImmAtomicBinaryOp<"imm_atomic_iadd"> { |
| 38 | + let summary = "atomic integer add to memory, returning the prior value"; |
| 39 | + let description = [{ |
| 40 | + The `dxsa.imm_atomic_iadd` operation atomically adds `$src0` to the single |
| 41 | + 32-bit value in `$dst1` memory at the per-component address `$dst_address` |
| 42 | + and returns the value held there before the add into `$dst0`. The add is |
| 43 | + insensitive to sign. |
| 44 | + |
| 45 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 46 | + memory. The number of components taken from `$dst_address` is |
| 47 | + determined by the dimensionality of `$dst1`. |
| 48 | + |
| 49 | + Example: |
| 50 | + |
| 51 | + ```mlir |
| 52 | + dxsa.imm_atomic_iadd r<0, <x>>, u<0>, r<1>, r<2> |
| 53 | + ``` |
| 54 | + }]; |
| 55 | +} |
| 56 | + |
| 57 | +//===----------------------------------------------------------------------===// |
| 58 | +// dxsa.imm_atomic_and |
| 59 | +//===----------------------------------------------------------------------===// |
| 60 | + |
| 61 | +def DXSA_ImmAtomicAnd : DXSA_ImmAtomicBinaryOp<"imm_atomic_and"> { |
| 62 | + let summary = "atomic bitwise AND to memory, returning the prior value"; |
| 63 | + let description = [{ |
| 64 | + The `dxsa.imm_atomic_and` operation atomically computes the bitwise AND of |
| 65 | + `$src0` with the single 32-bit value in `$dst1` memory at the per-component |
| 66 | + address `$dst_address` and returns the value held there before the AND into |
| 67 | + `$dst0`. |
| 68 | + |
| 69 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 70 | + memory. The number of components taken from `$dst_address` is |
| 71 | + determined by the dimensionality of `$dst1`. |
| 72 | + |
| 73 | + Example: |
| 74 | + |
| 75 | + ```mlir |
| 76 | + dxsa.imm_atomic_and r<0, <x>>, u<0>, r<1>, r<2> |
| 77 | + ``` |
| 78 | + }]; |
| 79 | +} |
| 80 | + |
| 81 | +//===----------------------------------------------------------------------===// |
| 82 | +// dxsa.imm_atomic_or |
| 83 | +//===----------------------------------------------------------------------===// |
| 84 | + |
| 85 | +def DXSA_ImmAtomicOr : DXSA_ImmAtomicBinaryOp<"imm_atomic_or"> { |
| 86 | + let summary = "atomic bitwise OR to memory, returning the prior value"; |
| 87 | + let description = [{ |
| 88 | + The `dxsa.imm_atomic_or` operation atomically computes the bitwise OR of |
| 89 | + `$src0` with the single 32-bit value in `$dst1` memory at the per-component |
| 90 | + address `$dst_address` and returns the value held there before the OR into |
| 91 | + `$dst0`. |
| 92 | + |
| 93 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 94 | + memory. The number of components taken from `$dst_address` is |
| 95 | + determined by the dimensionality of `$dst1`. |
| 96 | + |
| 97 | + Example: |
| 98 | + |
| 99 | + ```mlir |
| 100 | + dxsa.imm_atomic_or r<0, <x>>, u<0>, r<1>, r<2> |
| 101 | + ``` |
| 102 | + }]; |
| 103 | +} |
| 104 | + |
| 105 | +//===----------------------------------------------------------------------===// |
| 106 | +// dxsa.imm_atomic_xor |
| 107 | +//===----------------------------------------------------------------------===// |
| 108 | + |
| 109 | +def DXSA_ImmAtomicXor : DXSA_ImmAtomicBinaryOp<"imm_atomic_xor"> { |
| 110 | + let summary = "atomic bitwise XOR to memory, returning the prior value"; |
| 111 | + let description = [{ |
| 112 | + The `dxsa.imm_atomic_xor` operation atomically computes the bitwise XOR of |
| 113 | + `$src0` with the single 32-bit value in `$dst1` memory at the per-component |
| 114 | + address `$dst_address` and returns the value held there before the XOR into |
| 115 | + `$dst0`. |
| 116 | + |
| 117 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 118 | + memory. The number of components taken from `$dst_address` is |
| 119 | + determined by the dimensionality of `$dst1`. |
| 120 | + |
| 121 | + Example: |
| 122 | + |
| 123 | + ```mlir |
| 124 | + dxsa.imm_atomic_xor r<0, <x>>, u<0>, r<1>, r<2> |
| 125 | + ``` |
| 126 | + }]; |
| 127 | +} |
| 128 | + |
| 129 | +//===----------------------------------------------------------------------===// |
| 130 | +// dxsa.imm_atomic_imax |
| 131 | +//===----------------------------------------------------------------------===// |
| 132 | + |
| 133 | +def DXSA_ImmAtomicIMax : DXSA_ImmAtomicBinaryOp<"imm_atomic_imax"> { |
| 134 | + let summary = "atomic signed integer max to memory, returning the prior value"; |
| 135 | + let description = [{ |
| 136 | + The `dxsa.imm_atomic_imax` operation atomically computes the signed integer |
| 137 | + maximum of `$src0` and the single 32-bit value in `$dst1` memory at the |
| 138 | + per-component address `$dst_address` and returns the value held there before |
| 139 | + the operation into `$dst0`. |
| 140 | + |
| 141 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 142 | + memory. The number of components taken from `$dst_address` is |
| 143 | + determined by the dimensionality of `$dst1`. |
| 144 | + |
| 145 | + Example: |
| 146 | + |
| 147 | + ```mlir |
| 148 | + dxsa.imm_atomic_imax r<0, <x>>, u<0>, r<1>, r<2> |
| 149 | + ``` |
| 150 | + }]; |
| 151 | +} |
| 152 | + |
| 153 | +//===----------------------------------------------------------------------===// |
| 154 | +// dxsa.imm_atomic_imin |
| 155 | +//===----------------------------------------------------------------------===// |
| 156 | + |
| 157 | +def DXSA_ImmAtomicIMin : DXSA_ImmAtomicBinaryOp<"imm_atomic_imin"> { |
| 158 | + let summary = "atomic signed integer min to memory, returning the prior value"; |
| 159 | + let description = [{ |
| 160 | + The `dxsa.imm_atomic_imin` operation atomically computes the signed integer |
| 161 | + minimum of `$src0` and the single 32-bit value in `$dst1` memory at the |
| 162 | + per-component address `$dst_address` and returns the value held there before |
| 163 | + the operation into `$dst0`. |
| 164 | + |
| 165 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 166 | + memory. The number of components taken from `$dst_address` is |
| 167 | + determined by the dimensionality of `$dst1`. |
| 168 | + |
| 169 | + Example: |
| 170 | + |
| 171 | + ```mlir |
| 172 | + dxsa.imm_atomic_imin r<0, <x>>, u<0>, r<1>, r<2> |
| 173 | + ``` |
| 174 | + }]; |
| 175 | +} |
| 176 | + |
| 177 | +//===----------------------------------------------------------------------===// |
| 178 | +// dxsa.imm_atomic_umax |
| 179 | +//===----------------------------------------------------------------------===// |
| 180 | + |
| 181 | +def DXSA_ImmAtomicUMax : DXSA_ImmAtomicBinaryOp<"imm_atomic_umax"> { |
| 182 | + let summary = |
| 183 | + "atomic unsigned integer max to memory, returning the prior value"; |
| 184 | + let description = [{ |
| 185 | + The `dxsa.imm_atomic_umax` operation atomically computes the unsigned |
| 186 | + integer maximum of `$src0` and the single 32-bit value in `$dst1` memory at |
| 187 | + the per-component address `$dst_address` and returns the value held there |
| 188 | + before the operation into `$dst0`. |
| 189 | + |
| 190 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 191 | + memory. The number of components taken from `$dst_address` is |
| 192 | + determined by the dimensionality of `$dst1`. |
| 193 | + |
| 194 | + Example: |
| 195 | + |
| 196 | + ```mlir |
| 197 | + dxsa.imm_atomic_umax r<0, <x>>, u<0>, r<1>, r<2> |
| 198 | + ``` |
| 199 | + }]; |
| 200 | +} |
| 201 | + |
| 202 | +//===----------------------------------------------------------------------===// |
| 203 | +// dxsa.imm_atomic_umin |
| 204 | +//===----------------------------------------------------------------------===// |
| 205 | + |
| 206 | +def DXSA_ImmAtomicUMin : DXSA_ImmAtomicBinaryOp<"imm_atomic_umin"> { |
| 207 | + let summary = |
| 208 | + "atomic unsigned integer min to memory, returning the prior value"; |
| 209 | + let description = [{ |
| 210 | + The `dxsa.imm_atomic_umin` operation atomically computes the unsigned |
| 211 | + integer minimum of `$src0` and the single 32-bit value in `$dst1` memory at |
| 212 | + the per-component address `$dst_address` and returns the value held there |
| 213 | + before the operation into `$dst0`. |
| 214 | + |
| 215 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 216 | + memory. The number of components taken from `$dst_address` is |
| 217 | + determined by the dimensionality of `$dst1`. |
| 218 | + |
| 219 | + Example: |
| 220 | + |
| 221 | + ```mlir |
| 222 | + dxsa.imm_atomic_umin r<0, <x>>, u<0>, r<1>, r<2> |
| 223 | + ``` |
| 224 | + }]; |
| 225 | +} |
| 226 | + |
| 227 | +//===----------------------------------------------------------------------===// |
| 228 | +// dxsa.atomic_cmp_store |
| 229 | +//===----------------------------------------------------------------------===// |
| 230 | + |
| 231 | +def DXSA_AtomicCmpStore : DXSA_Op<"atomic_cmp_store"> { |
| 232 | + let summary = "atomic compare and conditional write to memory"; |
| 233 | + let description = [{ |
| 234 | + The `dxsa.atomic_cmp_store` operation atomically compares `$src0` with the |
| 235 | + single 32-bit value in `$dst` memory at the per-component address |
| 236 | + `$dst_address`. If the values are equal, `$src1` is written to that |
| 237 | + location, otherwise the location is left unchanged. Nothing is returned to |
| 238 | + the shader. |
| 239 | + |
| 240 | + `$dst` must be a UAV, or in a Compute Shader thread group shared |
| 241 | + memory. The number of components taken from `$dst_address` is |
| 242 | + determined by the dimensionality of `$dst`. |
| 243 | + |
| 244 | + Example: |
| 245 | + |
| 246 | + ```mlir |
| 247 | + dxsa.atomic_cmp_store u<0>, r<1>, r<2>, r<3> |
| 248 | + ``` |
| 249 | + }]; |
| 250 | + let arguments = (ins |
| 251 | + DXSA_DstOperandAttr:$dst, |
| 252 | + DXSA_SrcOperandAttr:$dst_address, |
| 253 | + DXSA_SrcOperandAttr:$src0, |
| 254 | + DXSA_SrcOperandAttr:$src1); |
| 255 | + let results = (outs); |
| 256 | + let assemblyFormat = |
| 257 | + "$dst `,` $dst_address `,` $src0 `,` $src1 attr-dict"; |
| 258 | +} |
| 259 | + |
| 260 | +//===----------------------------------------------------------------------===// |
| 261 | +// dxsa.imm_atomic_exch |
| 262 | +//===----------------------------------------------------------------------===// |
| 263 | + |
| 264 | +def DXSA_ImmAtomicExch : DXSA_ImmAtomicBinaryOp<"imm_atomic_exch"> { |
| 265 | + let summary = "atomic exchange to memory, returning the prior value"; |
| 266 | + let description = [{ |
| 267 | + The `dxsa.imm_atomic_exch` operation atomically writes `$src0` to the single |
| 268 | + 32-bit value in `$dst1` memory at the per-component address `$dst_address` |
| 269 | + and returns the value held there before the write into `$dst0`. |
| 270 | + |
| 271 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 272 | + memory. The number of components taken from `$dst_address` is |
| 273 | + determined by the dimensionality of `$dst1`. |
| 274 | + |
| 275 | + Example: |
| 276 | + |
| 277 | + ```mlir |
| 278 | + dxsa.imm_atomic_exch r<0, <x>>, u<0>, r<1>, r<2> |
| 279 | + ``` |
| 280 | + }]; |
| 281 | +} |
| 282 | + |
| 283 | +//===----------------------------------------------------------------------===// |
| 284 | +// dxsa.imm_atomic_cmp_exch |
| 285 | +//===----------------------------------------------------------------------===// |
| 286 | + |
| 287 | +def DXSA_ImmAtomicCmpExch : DXSA_Op<"imm_atomic_cmp_exch"> { |
| 288 | + let summary = |
| 289 | + "atomic compare and exchange to memory, returning the prior value"; |
| 290 | + let description = [{ |
| 291 | + The `dxsa.imm_atomic_cmp_exch` operation atomically compares `$src0` with |
| 292 | + the single 32-bit value in `$dst1` memory at the per-component address |
| 293 | + `$dst_address`. If the values are equal, `$src1` is written to that |
| 294 | + location, otherwise the location is left unchanged. The value held there |
| 295 | + before the operation is always returned into `$dst0`. |
| 296 | + |
| 297 | + `$dst1` must be a UAV, or in a Compute Shader thread group shared |
| 298 | + memory. The number of components taken from `$dst_address` is |
| 299 | + determined by the dimensionality of `$dst1`. |
| 300 | + |
| 301 | + Example: |
| 302 | + |
| 303 | + ```mlir |
| 304 | + dxsa.imm_atomic_cmp_exch r<0, <x>>, u<0>, r<1>, r<2>, r<3> |
| 305 | + ``` |
| 306 | + }]; |
| 307 | + let arguments = (ins |
| 308 | + DXSA_DstOperandAttr:$dst0, |
| 309 | + DXSA_DstOperandAttr:$dst1, |
| 310 | + DXSA_SrcOperandAttr:$dst_address, |
| 311 | + DXSA_SrcOperandAttr:$src0, |
| 312 | + DXSA_SrcOperandAttr:$src1); |
| 313 | + let results = (outs); |
| 314 | + let assemblyFormat = |
| 315 | + "$dst0 `,` $dst1 `,` $dst_address `,` $src0 `,` $src1 attr-dict"; |
| 316 | +} |
| 317 | + |
| 318 | +#endif // MLIR_DIALECT_DXSA_IR_DXSAATOMICOPS |
0 commit comments