[clang] [CIR] Upstream initial support for unary op (PR #131369)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 14 11:53:41 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">;
----------------
andykaylor wrote:
Right. Address of is represented in various ways, usually with either `cir.get_global` or just using the `cir.alloca` address.
Logical not is handled by converting to bool and then passing that to the unary not. That is, cir.unary(not) is essentially always a bitwise not, but for bool types that is effectively a logical not.
co_await is handled in the incubator, but that might be something we want to revisit. It looks like it's just using the LLVM coro intrinsics. I'm not sure if there's been discussion of expressing coroutine abstractions in CIR or if this was just a "get it done" implementation.
https://github.com/llvm/llvm-project/pull/131369
More information about the cfe-commits
mailing list