Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 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 | |||
| 15 | namespace llvm { |
||
| 16 | |||
| 17 | class BasicBlock; |
||
| 18 | class Use; |
||
| 19 | class User; |
||
| 20 | class 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. |
||
| 24 | bool isGuard(const User *U); |
||
| 25 | |||
| 26 | /// Returns true iff \p U is a widenable branch (that is, parseWidenableBranch |
||
| 27 | /// returns true). |
||
| 28 | bool 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. |
||
| 32 | bool 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. |
||
| 43 | bool 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. |
||
| 49 | bool parseWidenableBranch(User *U, Use *&Cond, Use *&WC, BasicBlock *&IfTrueBB, |
||
| 50 | BasicBlock *&IfFalseBB); |
||
| 51 | |||
| 52 | } // llvm |
||
| 53 | |||
| 54 | #endif // LLVM_ANALYSIS_GUARDUTILS_H |