[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


================
@@ -568,6 +568,128 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite(
   return mlir::success();
 }
 
+mlir::LogicalResult CIRToLLVMUnaryOpLowering::matchAndRewrite(
+    cir::UnaryOp op, OpAdaptor adaptor,
+    mlir::ConversionPatternRewriter &rewriter) const {
+  assert(op.getType() == op.getInput().getType() &&
+         "Unary operation's operand type and result type are different");
+  mlir::Type type = op.getType();
+  mlir::Type elementType = type;
+  bool isVector = false;
+  assert(!cir::MissingFeatures::vectorType());
+  mlir::Type llvmType = getTypeConverter()->convertType(type);
+  mlir::Location loc = op.getLoc();
+
+  auto createIntConstant = [&](int64_t value) -> mlir::Value {
----------------
erichkeane wrote:

Morris just added a `create dummy op` that i wonder if should/could be combined here.

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


More information about the cfe-commits mailing list