MLIR 24.0.0git
AtomicOps.cpp
Go to the documentation of this file.
1//===- AtomicOps.cpp - MLIR SPIR-V Atomic Ops ----------------------------===//
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// Defines the atomic operations in the SPIR-V dialect.
10//
11//===----------------------------------------------------------------------===//
12
14
15#include "SPIRVOpUtils.h"
16#include "SPIRVParsingUtils.h"
17
18using namespace mlir::spirv::AttrNames;
19
20namespace mlir::spirv {
21
22template <typename T>
23static StringRef stringifyTypeName();
24
25template <>
27 return "integer";
28}
29
30template <>
32 return "float";
33}
34
35// Verifies an atomic update op.
36template <typename AtomicOpTy, typename ExpectedElementType>
37static LogicalResult verifyAtomicUpdateOp(Operation *op) {
38 auto ptrType = cast<spirv::PointerType>(op->getOperand(0).getType());
39 auto elementType = ptrType.getPointeeType();
40 if (!isa<ExpectedElementType>(elementType))
41 return op->emitOpError() << "pointer operand must point to an "
43 << " value, found " << elementType;
44
45 spirv::MemorySemantics memorySemantics = cast<AtomicOpTy>(op).getSemantics();
46 if (failed(verifyMemorySemantics(op, memorySemantics))) {
47 return failure();
48 }
49 return success();
50}
51
52//===----------------------------------------------------------------------===//
53// spirv.AtomicAndOp
54//===----------------------------------------------------------------------===//
55
56LogicalResult AtomicAndOp::verify() {
58}
59
60//===----------------------------------------------------------------------===//
61// spirv.AtomicIAddOp
62//===----------------------------------------------------------------------===//
63
64LogicalResult AtomicIAddOp::verify() {
66}
67
68//===----------------------------------------------------------------------===//
69// spirv.EXT.AtomicFAddOp
70//===----------------------------------------------------------------------===//
71
72LogicalResult EXTAtomicFAddOp::verify() {
74}
75
76//===----------------------------------------------------------------------===//
77// spirv.AtomicIDecrementOp
78//===----------------------------------------------------------------------===//
79
80LogicalResult AtomicIDecrementOp::verify() {
82}
83
84//===----------------------------------------------------------------------===//
85// spirv.AtomicIIncrementOp
86//===----------------------------------------------------------------------===//
87
88LogicalResult AtomicIIncrementOp::verify() {
90}
91
92//===----------------------------------------------------------------------===//
93// spirv.AtomicISubOp
94//===----------------------------------------------------------------------===//
95
96LogicalResult AtomicISubOp::verify() {
98}
99
100//===----------------------------------------------------------------------===//
101// spirv.AtomicOrOp
102//===----------------------------------------------------------------------===//
103
104LogicalResult AtomicOrOp::verify() {
106}
107
108//===----------------------------------------------------------------------===//
109// spirv.AtomicSMaxOp
110//===----------------------------------------------------------------------===//
111
112LogicalResult AtomicSMaxOp::verify() {
114}
115
116//===----------------------------------------------------------------------===//
117// spirv.AtomicSMinOp
118//===----------------------------------------------------------------------===//
119
120LogicalResult AtomicSMinOp::verify() {
122}
123
124//===----------------------------------------------------------------------===//
125// spirv.AtomicUMaxOp
126//===----------------------------------------------------------------------===//
127
128LogicalResult AtomicUMaxOp::verify() {
130}
131
132//===----------------------------------------------------------------------===//
133// spirv.AtomicUMinOp
134//===----------------------------------------------------------------------===//
135
136LogicalResult AtomicUMinOp::verify() {
138}
139
140//===----------------------------------------------------------------------===//
141// spirv.AtomicXorOp
142//===----------------------------------------------------------------------===//
143
144LogicalResult AtomicXorOp::verify() {
146}
147
148} // namespace mlir::spirv
return success()
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
Value getOperand(unsigned idx)
Definition Operation.h:375
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
Type getType() const
Return the type of this value.
Definition Value.h:105
static StringRef stringifyTypeName()
LogicalResult verifyMemorySemantics(Operation *op, spirv::MemorySemantics memorySemantics)
Definition SPIRVOps.cpp:69
StringRef stringifyTypeName< FloatType >()
Definition AtomicOps.cpp:31
StringRef stringifyTypeName< IntegerType >()
Definition AtomicOps.cpp:26
static LogicalResult verifyAtomicUpdateOp(Operation *op)
Definition AtomicOps.cpp:37