LLVM 23.0.0git
GuardUtils.h
Go to the documentation of this file.
1//===-- GuardUtils.h - Utils for work with guards ---------------*- 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// Utils that are used to perform analyzes related to guards and their
9// conditions.
10//===----------------------------------------------------------------------===//
11
12#ifndef LLVM_ANALYSIS_GUARDUTILS_H
13#define LLVM_ANALYSIS_GUARDUTILS_H
14
16
17namespace llvm {
18
19class BasicBlock;
20class Use;
21class User;
22class Value;
23template <typename T> class SmallVectorImpl;
24
25/// Returns true iff \p U has semantics of a guard expressed in a form of call
26/// of llvm.experimental.guard intrinsic.
27LLVM_ABI bool isGuard(const User *U);
28
29/// Returns true iff \p V has semantics of llvm.experimental.widenable.condition
30/// call
32
33/// Returns true iff \p U is a widenable branch (that is,
34/// extractWidenableCondition returns widenable condition).
35LLVM_ABI bool isWidenableBranch(const User *U);
36
37/// Returns true iff \p U has semantics of a guard expressed in a form of a
38/// widenable conditional branch to deopt block.
40
41/// If U is widenable branch looking like:
42/// %cond = ...
43/// %wc = call i1 @llvm.experimental.widenable.condition()
44/// %branch_cond = and i1 %cond, %wc
45/// br i1 %branch_cond, label %if_true_bb, label %if_false_bb ; <--- U
46/// The function returns true, and the values %cond and %wc and blocks
47/// %if_true_bb, if_false_bb are returned in
48/// the parameters (Condition, WidenableCondition, IfTrueBB and IfFalseFF)
49/// respectively. If \p U does not match this pattern, return false.
50LLVM_ABI bool parseWidenableBranch(const User *U, Value *&Condition,
51 Value *&WidenableCondition,
52 BasicBlock *&IfTrueBB,
53 BasicBlock *&IfFalseBB);
54
55/// Analogous to the above, but return the Uses so that they can be
56/// modified. Unlike previous version, Condition is optional and may be null.
58 BasicBlock *&IfTrueBB,
59 BasicBlock *&IfFalseBB);
60
61// The guard condition is expected to be in form of:
62// cond1 && cond2 && cond3 ...
63// or in case of widenable branch:
64// cond1 && cond2 && cond3 && widenable_contidion ...
65// Method collects the list of checks, but skips widenable_condition.
68
69// Returns widenable_condition if it exists in the expression tree rooting from
70// \p U and has only one use.
72} // llvm
73
74#endif // LLVM_ANALYSIS_GUARDUTILS_H
#define LLVM_ABI
Definition Compiler.h:213
const SmallVectorImpl< MachineOperand > & Cond
LLVM Basic Block Representation.
Definition BasicBlock.h:62
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
LLVM Value Representation.
Definition Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI Value * extractWidenableCondition(const User *U)
LLVM_ABI void parseWidenableGuard(const User *U, llvm::SmallVectorImpl< Value * > &Checks)
LLVM_ABI bool isGuard(const User *U)
Returns true iff U has semantics of a guard expressed in a form of call of llvm.experimental....
LLVM_ABI bool isWidenableCondition(const Value *V)
Returns true iff V has semantics of llvm.experimental.widenable.condition call.
LLVM_ABI bool parseWidenableBranch(const User *U, Value *&Condition, Value *&WidenableCondition, BasicBlock *&IfTrueBB, BasicBlock *&IfFalseBB)
If U is widenable branch looking like: cond = ... wc = call i1 @llvm.experimental....
LLVM_ABI bool isWidenableBranch(const User *U)
Returns true iff U is a widenable branch (that is, extractWidenableCondition returns widenable condit...
LLVM_ABI bool isGuardAsWidenableBranch(const User *U)
Returns true iff U has semantics of a guard expressed in a form of a widenable conditional branch to ...