Skip to content

Commit 0d5b08c

Browse files
committed
Introduce an EmitC UnaryOp class
1 parent c1e7594 commit 0d5b08c

File tree

1 file changed

+10
-7
lines changed
  • mlir/include/mlir/Dialect/EmitC/IR

1 file changed

+10
-7
lines changed

mlir/include/mlir/Dialect/EmitC/IR/EmitC.td

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ include "mlir/IR/RegionKindInterface.td"
3131
class EmitC_Op<string mnemonic, list<Trait> traits = []>
3232
: Op<EmitC_Dialect, mnemonic, traits>;
3333

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+
3442
// Base class for binary operations.
3543
class EmitC_BinaryOp<string mnemonic, list<Trait> traits = []> :
3644
EmitC_Op<mnemonic, traits> {
@@ -131,7 +139,7 @@ def EmitC_BitwiseLeftShiftOp : EmitC_BinaryOp<"bitwise_left_shift", []> {
131139
}];
132140
}
133141

134-
def EmitC_BitwiseNotOp : EmitC_Op<"bitwise_not", []> {
142+
def EmitC_BitwiseNotOp : EmitC_UnaryOp<"bitwise_not", []> {
135143
let summary = "Bitwise not operation";
136144
let description = [{
137145
With the `bitwise_not` operation the bitwise operator ~ (not) can
@@ -147,10 +155,6 @@ def EmitC_BitwiseNotOp : EmitC_Op<"bitwise_not", []> {
147155
int32_t v2 = ~v1;
148156
```
149157
}];
150-
151-
let arguments = (ins AnyType);
152-
let results = (outs AnyType);
153-
let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
154158
}
155159

156160
def EmitC_BitwiseOrOp : EmitC_BinaryOp<"bitwise_or", []> {
@@ -791,7 +795,7 @@ def EmitC_LogicalAndOp : EmitC_BinaryOp<"logical_and", []> {
791795
let assemblyFormat = "operands attr-dict `:` type(operands)";
792796
}
793797

794-
def EmitC_LogicalNotOp : EmitC_Op<"logical_not", []> {
798+
def EmitC_LogicalNotOp : EmitC_UnaryOp<"logical_not", []> {
795799
let summary = "Logical not operation";
796800
let description = [{
797801
With the `logical_not` operation the logical operator ! (negation) can
@@ -808,7 +812,6 @@ def EmitC_LogicalNotOp : EmitC_Op<"logical_not", []> {
808812
```
809813
}];
810814

811-
let arguments = (ins AnyType);
812815
let results = (outs I1);
813816
let assemblyFormat = "operands attr-dict `:` type(operands)";
814817
}

0 commit comments

Comments
 (0)