@@ -31,6 +31,14 @@ include "mlir/IR/RegionKindInterface.td"
31
31
class EmitC_Op<string mnemonic, list<Trait> traits = []>
32
32
: Op<EmitC_Dialect, mnemonic, traits>;
33
33
34
+ // Base class for unary operations.
35
+ class EmitC_UnaryOp<string mnemonic, list<Trait> traits = []> :
36
+ EmitC_Op<mnemonic, traits> {
37
+ let arguments = (ins AnyType);
38
+ let results = (outs AnyType);
39
+ let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
40
+ }
41
+
34
42
// Base class for binary operations.
35
43
class EmitC_BinaryOp<string mnemonic, list<Trait> traits = []> :
36
44
EmitC_Op<mnemonic, traits> {
@@ -131,7 +139,7 @@ def EmitC_BitwiseLeftShiftOp : EmitC_BinaryOp<"bitwise_left_shift", []> {
131
139
}];
132
140
}
133
141
134
- def EmitC_BitwiseNotOp : EmitC_Op <"bitwise_not", []> {
142
+ def EmitC_BitwiseNotOp : EmitC_UnaryOp <"bitwise_not", []> {
135
143
let summary = "Bitwise not operation";
136
144
let description = [{
137
145
With the `bitwise_not` operation the bitwise operator ~ (not) can
@@ -147,10 +155,6 @@ def EmitC_BitwiseNotOp : EmitC_Op<"bitwise_not", []> {
147
155
int32_t v2 = ~v1;
148
156
```
149
157
}];
150
-
151
- let arguments = (ins AnyType);
152
- let results = (outs AnyType);
153
- let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
154
158
}
155
159
156
160
def EmitC_BitwiseOrOp : EmitC_BinaryOp<"bitwise_or", []> {
@@ -791,7 +795,7 @@ def EmitC_LogicalAndOp : EmitC_BinaryOp<"logical_and", []> {
791
795
let assemblyFormat = "operands attr-dict `:` type(operands)";
792
796
}
793
797
794
- def EmitC_LogicalNotOp : EmitC_Op <"logical_not", []> {
798
+ def EmitC_LogicalNotOp : EmitC_UnaryOp <"logical_not", []> {
795
799
let summary = "Logical not operation";
796
800
let description = [{
797
801
With the `logical_not` operation the logical operator ! (negation) can
@@ -808,7 +812,6 @@ def EmitC_LogicalNotOp : EmitC_Op<"logical_not", []> {
808
812
```
809
813
}];
810
814
811
- let arguments = (ins AnyType);
812
815
let results = (outs I1);
813
816
let assemblyFormat = "operands attr-dict `:` type(operands)";
814
817
}
0 commit comments