[clang] [CIR] Add binary operators (PR #132420)
Morris Hafner via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 24 06:28:18 PDT 2025
================
@@ -826,6 +826,129 @@ def ForOp : CIR_Op<"for", [LoopOpInterface, NoRegionArguments]> {
}];
}
+//===----------------------------------------------------------------------===//
+// BinOp
+//===----------------------------------------------------------------------===//
+
+// FIXME: represent Commutative, Idempotent traits for appropriate binops
+def BinOpKind_Mul : I32EnumAttrCase<"Mul", 1, "mul">;
+def BinOpKind_Div : I32EnumAttrCase<"Div", 2, "div">;
+def BinOpKind_Rem : I32EnumAttrCase<"Rem", 3, "rem">;
+def BinOpKind_Add : I32EnumAttrCase<"Add", 4, "add">;
+def BinOpKind_Sub : I32EnumAttrCase<"Sub", 5, "sub">;
+def BinOpKind_And : I32EnumAttrCase<"And", 8, "and">;
+def BinOpKind_Xor : I32EnumAttrCase<"Xor", 9, "xor">;
+def BinOpKind_Or : I32EnumAttrCase<"Or", 10, "or">;
+// TODO(cir): Do we need a min binop?
+def BinOpKind_Max : I32EnumAttrCase<"Max", 11, "max">;
----------------
mmha wrote:
This is to support `__builtin_elementwise_max` and at least one corresponding SIMD intrinsic function (see https://github.com/llvm/clangir/pull/1201).
I can't find that `TODO` in the git history of the incubator for some reason. But since there is a `__builtin_elementwise_min` I assume there needs to be a min as well.
Both builtins are still NYI though so I could remove them for the time being.
https://github.com/llvm/llvm-project/pull/132420
More information about the cfe-commits
mailing list