GuardUtils.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- GuardUtils.h - Utils for work with guards ---------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. // Utils that are used to perform analyzes related to guards and their
  14. // conditions.
  15. //===----------------------------------------------------------------------===//
  16. #ifndef LLVM_ANALYSIS_GUARDUTILS_H
  17. #define LLVM_ANALYSIS_GUARDUTILS_H
  18. namespace llvm {
  19. class BasicBlock;
  20. class Use;
  21. class User;
  22. class Value;
  23. /// Returns true iff \p U has semantics of a guard expressed in a form of call
  24. /// of llvm.experimental.guard intrinsic.
  25. bool isGuard(const User *U);
  26. /// Returns true iff \p U is a widenable branch (that is, parseWidenableBranch
  27. /// returns true).
  28. bool isWidenableBranch(const User *U);
  29. /// Returns true iff \p U has semantics of a guard expressed in a form of a
  30. /// widenable conditional branch to deopt block.
  31. bool isGuardAsWidenableBranch(const User *U);
  32. /// If U is widenable branch looking like:
  33. /// %cond = ...
  34. /// %wc = call i1 @llvm.experimental.widenable.condition()
  35. /// %branch_cond = and i1 %cond, %wc
  36. /// br i1 %branch_cond, label %if_true_bb, label %if_false_bb ; <--- U
  37. /// The function returns true, and the values %cond and %wc and blocks
  38. /// %if_true_bb, if_false_bb are returned in
  39. /// the parameters (Condition, WidenableCondition, IfTrueBB and IfFalseFF)
  40. /// respectively. If \p U does not match this pattern, return false.
  41. bool parseWidenableBranch(const User *U, Value *&Condition,
  42. Value *&WidenableCondition, BasicBlock *&IfTrueBB,
  43. BasicBlock *&IfFalseBB);
  44. /// Analgous to the above, but return the Uses so that that they can be
  45. /// modified. Unlike previous version, Condition is optional and may be null.
  46. bool parseWidenableBranch(User *U, Use *&Cond, Use *&WC, BasicBlock *&IfTrueBB,
  47. BasicBlock *&IfFalseBB);
  48. } // llvm
  49. #endif // LLVM_ANALYSIS_GUARDUTILS_H
  50. #ifdef __GNUC__
  51. #pragma GCC diagnostic pop
  52. #endif