clang 23.0.0git
CIRTransformUtils.h
Go to the documentation of this file.
1//===- CIRTransformUtils.h - Shared helpers for CIR transforms -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef CIR_DIALECT_TRANSFORMS_CIRTRANSFORMUTILS_H
10#define CIR_DIALECT_TRANSFORMS_CIRTRANSFORMUTILS_H
11
12#include "mlir/IR/Location.h"
13#include "mlir/IR/PatternMatch.h"
15
16namespace cir {
17
18/// Replace a `cir::CallOp` with a `cir::TryCallOp` whose unwind destination
19/// is \p unwindDest. The call's parent block is split immediately after the
20/// call; the resulting suffix block becomes the try_call's normal
21/// destination and is returned to the caller.
22///
23/// All attributes of the original call other than the callee and operand
24/// segment sizes (which `TryCallOp::create` sets itself) are copied onto
25/// the new try_call. Uses of the original call's result, if any, are
26/// redirected to the try_call's result, and the original call is erased.
27///
28/// The call must not already be marked nothrow.
29mlir::Block *replaceCallWithTryCall(cir::CallOp callOp, mlir::Block *unwindDest,
30 mlir::Location loc,
31 mlir::RewriterBase &rewriter);
32
33} // namespace cir
34
35#endif // CIR_DIALECT_TRANSFORMS_CIRTRANSFORMUTILS_H
mlir::Block * replaceCallWithTryCall(cir::CallOp callOp, mlir::Block *unwindDest, mlir::Location loc, mlir::RewriterBase &rewriter)
Replace a cir::CallOp with a cir::TryCallOp whose unwind destination is unwindDest.