[Mlir-commits] [mlir] [mlir][EmitC] Add `unary_{minus, plus}` operators (PR #84329)

Simon Camphausen llvmlistbot at llvm.org
Thu Mar 7 07:01:10 PST 2024


================
@@ -908,6 +908,42 @@ def EmitC_SubOp : EmitC_BinaryOp<"sub", [CExpression]> {
   let hasVerifier = 1;
 }
 
+def EmitC_UnaryMinusOp : EmitC_UnaryOp<"unary_minus", []> {
+  let summary = "Unary minus operation";
+  let description = [{
+    With the `unary_minus` operation the unary operator - (minus) can be
+    applied.
+
+    Example:
+
+    ```mlir
+    %0 = emitc.unary_plus %arg0 : (i32) -> i32
+    ```
+    ```c++
+    // Code emitted for the operation above.
+    int32_t v2 = -v1;
+    ```
+  }];
+}
+
+def EmitC_UnaryPlusOp : EmitC_UnaryOp<"unary_plus", []> {
----------------
simon-camp wrote:

```suggestion
def EmitC_UnaryPlusOp : EmitC_UnaryOp<"unary_plus", [CExpression]> {
```

https://github.com/llvm/llvm-project/pull/84329


More information about the Mlir-commits mailing list