[clang] [CIR] Upstream initial support for unary op (PR #131369)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 14 11:19:22 PDT 2025


================
@@ -468,6 +468,55 @@ def BrOp : CIR_Op<"br",
   }];
 }
 
+//===----------------------------------------------------------------------===//
+// UnaryOp
+//===----------------------------------------------------------------------===//
+
+def UnaryOpKind_Inc   : I32EnumAttrCase<"Inc",   1, "inc">;
+def UnaryOpKind_Dec   : I32EnumAttrCase<"Dec",   2, "dec">;
+def UnaryOpKind_Plus  : I32EnumAttrCase<"Plus",  3, "plus">;
+def UnaryOpKind_Minus : I32EnumAttrCase<"Minus", 4, "minus">;
+def UnaryOpKind_Not   : I32EnumAttrCase<"Not",   5, "not">;
+
+def UnaryOpKind : I32EnumAttr<
+    "UnaryOpKind",
+    "unary operation kind",
+    [UnaryOpKind_Inc,
+     UnaryOpKind_Dec,
+     UnaryOpKind_Plus,
+     UnaryOpKind_Minus,
+     UnaryOpKind_Not,
+     ]> {
+  let cppNamespace = "::cir";
+}
+
+// FIXME: Pure won't work when we add overloading.
----------------
erichkeane wrote:

Does this mean operator overloading?  If so, why would we model that as unary operator?  In the CFE those get modeled as function calls, so do we intended to flatten that?

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


More information about the cfe-commits mailing list