[clang] [CIR] Upstream StackSave and StackRestoreOp (PR #136426)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 21 01:06:22 PDT 2025


================
@@ -1512,6 +1514,22 @@ mlir::LogicalResult CIRToLLVMTrapOpLowering::matchAndRewrite(
   return mlir::success();
 }
 
+mlir::LogicalResult CIRToLLVMStackSaveOpLowering::matchAndRewrite(
+    cir::StackSaveOp op, OpAdaptor adaptor,
+    mlir::ConversionPatternRewriter &rewriter) const {
+  const mlir::Type ptrTy = getTypeConverter()->convertType(op.getType());
+  rewriter.replaceOpWithNewOp<mlir::LLVM::StackSaveOp>(op, ptrTy);
+  return mlir::success();
+}
+
+mlir::LogicalResult CIRToLLVMStackRestoreOpLowering::matchAndRewrite(
+    cir::StackRestoreOp op, OpAdaptor adaptor,
+    mlir::ConversionPatternRewriter &rewriter) const {
+  rewriter.replaceOpWithNewOp<mlir::LLVM::StackRestoreOp>(
+      op, adaptor.getOperands().front());
----------------
xlauko wrote:

```suggestion
      op, adaptor.getPtr());
```

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


More information about the cfe-commits mailing list