blob: 41e7b7c06c7501b17d4fd2ca0d2b3165dbae6da3 [file] [log] [blame]
Andrew Scull0372a572018-11-16 15:47:06 +00001//===-- GuardUtils.h - Utils for work with guards ---------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull0372a572018-11-16 15:47:06 +00006//
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
15namespace llvm {
16
Andrew Walbran16937d02019-10-22 13:54:20 +010017class BasicBlock;
Andrew Scull0372a572018-11-16 15:47:06 +000018class User;
Andrew Walbran16937d02019-10-22 13:54:20 +010019class Value;
Andrew Scull0372a572018-11-16 15:47:06 +000020
Andrew Walbran16937d02019-10-22 13:54:20 +010021/// Returns true iff \p U has semantics of a guard expressed in a form of call
22/// of llvm.experimental.guard intrinsic.
Andrew Scull0372a572018-11-16 15:47:06 +000023bool isGuard(const User *U);
24
Andrew Walbran16937d02019-10-22 13:54:20 +010025/// Returns true iff \p U has semantics of a guard expressed in a form of a
26/// widenable conditional branch to deopt block.
27bool isGuardAsWidenableBranch(const User *U);
28
29/// If U is widenable branch looking like:
30/// %cond = ...
31/// %wc = call i1 @llvm.experimental.widenable.condition()
32/// %branch_cond = and i1 %cond, %wc
33/// br i1 %branch_cond, label %if_true_bb, label %if_false_bb ; <--- U
34/// The function returns true, and the values %cond and %wc and blocks
35/// %if_true_bb, if_false_bb are returned in
36/// the parameters (Condition, WidenableCondition, IfTrueBB and IfFalseFF)
37/// respectively. If \p U does not match this pattern, return false.
38bool parseWidenableBranch(const User *U, Value *&Condition,
39 Value *&WidenableCondition, BasicBlock *&IfTrueBB,
40 BasicBlock *&IfFalseBB);
41
Andrew Scull0372a572018-11-16 15:47:06 +000042} // llvm
43
44#endif // LLVM_ANALYSIS_GUARDUTILS_H