GuardUtils.h revision 360784
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 15namespace llvm { 16 17class BasicBlock; 18class Use; 19class User; 20class Value; 21 22/// Returns true iff \p U has semantics of a guard expressed in a form of call 23/// of llvm.experimental.guard intrinsic. 24bool isGuard(const User *U); 25 26/// Returns true iff \p U is a widenable branch (that is, parseWidenableBranch 27/// returns true). 28bool isWidenableBranch(const User *U); 29 30/// Returns true iff \p U has semantics of a guard expressed in a form of a 31/// widenable conditional branch to deopt block. 32bool isGuardAsWidenableBranch(const User *U); 33 34/// If U is widenable branch looking like: 35/// %cond = ... 36/// %wc = call i1 @llvm.experimental.widenable.condition() 37/// %branch_cond = and i1 %cond, %wc 38/// br i1 %branch_cond, label %if_true_bb, label %if_false_bb ; <--- U 39/// The function returns true, and the values %cond and %wc and blocks 40/// %if_true_bb, if_false_bb are returned in 41/// the parameters (Condition, WidenableCondition, IfTrueBB and IfFalseFF) 42/// respectively. If \p U does not match this pattern, return false. 43bool parseWidenableBranch(const User *U, Value *&Condition, 44 Value *&WidenableCondition, BasicBlock *&IfTrueBB, 45 BasicBlock *&IfFalseBB); 46 47/// Analgous to the above, but return the Uses so that that they can be 48/// modified. Unlike previous version, Condition is optional and may be null. 49bool parseWidenableBranch(User *U, Use *&Cond, Use *&WC, BasicBlock *&IfTrueBB, 50 BasicBlock *&IfFalseBB); 51 52} // llvm 53 54#endif // LLVM_ANALYSIS_GUARDUTILS_H 55