Debian Codegraph @

suite/synctools/tablegen/include/llvm/IR/Assumptions.h

raw symbols SCIP
1 //===--- Assumptions.h - Assumption handling and organization ---*- 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 //
9 // String assumptions that are known to optimization passes should be placed in
10 // the KnownAssumptionStrings set. This can be done in various ways, i.a.,
11 // via a static KnownAssumptionString object.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_IR_ASSUMPTIONS_H
16 #define LLVM_IR_ASSUMPTIONS_H
17
18 #include "llvm/ADT/DenseSet.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/ADT/StringSet.h"
21
22 namespace llvm {
23
24 class Function;
25 class CallBase;
26
27 /// The key we use for assumption attributes.
28 constexpr StringRef AssumptionAttrKey = "llvm.assume";
29
30 /// A set of known assumption strings that are accepted without warning and
31 /// which can be recommended as typo correction.
32 extern StringSet<> KnownAssumptionStrings;
33
34 /// Helper that allows to insert a new assumption string in the known assumption
35 /// set by creating a (static) object.
36 struct KnownAssumptionString {
37 KnownAssumptionString(StringRef AssumptionStr)
38 : AssumptionStr(AssumptionStr) {
39 KnownAssumptionStrings.insert(AssumptionStr);
40 }
41 operator StringRef() const { return AssumptionStr; }
42
43 private:
44 StringRef AssumptionStr;
45 };
46
47 /// Return true if \p F has the assumption \p AssumptionStr attached.
48 bool hasAssumption(const Function &F,
49 const KnownAssumptionString &AssumptionStr);
50
51 /// Return true if \p CB or the callee has the assumption \p AssumptionStr
52 /// attached.
53 bool hasAssumption(const CallBase &CB,
54 const KnownAssumptionString &AssumptionStr);
55
56 /// Return the set of all assumptions for the function \p F.
57 DenseSet<StringRef> getAssumptions(const Function &F);
58
59 /// Return the set of all assumptions for the call \p CB.
60 DenseSet<StringRef> getAssumptions(const CallBase &CB);
61
62 /// Appends the set of assumptions \p Assumptions to \F.
63 bool addAssumptions(Function &F, const DenseSet<StringRef> &Assumptions);
64
65 /// Appends the set of assumptions \p Assumptions to \CB.
66 bool addAssumptions(CallBase &CB, const DenseSet<StringRef> &Assumptions);
67
68 } // namespace llvm
69
70 #endif