xref: /freebsd/contrib/llvm-project/llvm/include/llvm/IR/ReplaceConstant.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1e8d8bef9SDimitry Andric //===- ReplaceConstant.h - Replacing LLVM constant expressions --*- C++ -*-===//
2e8d8bef9SDimitry Andric //
3e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e8d8bef9SDimitry Andric //
7e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
8e8d8bef9SDimitry Andric //
9e8d8bef9SDimitry Andric // This file declares the utility function for replacing LLVM constant
10e8d8bef9SDimitry Andric // expressions by instructions.
11e8d8bef9SDimitry Andric //
12e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
13e8d8bef9SDimitry Andric 
14e8d8bef9SDimitry Andric #ifndef LLVM_IR_REPLACECONSTANT_H
15e8d8bef9SDimitry Andric #define LLVM_IR_REPLACECONSTANT_H
16e8d8bef9SDimitry Andric 
17e8d8bef9SDimitry Andric namespace llvm {
18e8d8bef9SDimitry Andric 
1906c3fb27SDimitry Andric template <typename T> class ArrayRef;
2006c3fb27SDimitry Andric class Constant;
21*0fca6ea1SDimitry Andric class Function;
221fd87a68SDimitry Andric 
2306c3fb27SDimitry Andric /// Replace constant expressions users of the given constants with
2406c3fb27SDimitry Andric /// instructions. Return whether anything was changed.
25*0fca6ea1SDimitry Andric ///
26*0fca6ea1SDimitry Andric /// Passing RestrictToFunc will restrict the constant replacement
27*0fca6ea1SDimitry Andric /// to the passed in functions scope, as opposed to the replacements
28*0fca6ea1SDimitry Andric /// occurring at module scope.
29*0fca6ea1SDimitry Andric ///
30*0fca6ea1SDimitry Andric /// RemoveDeadConstants by default will remove all dead constants as
31*0fca6ea1SDimitry Andric /// the final step of the function after replacement, when passed
32*0fca6ea1SDimitry Andric /// false it will skip this final step.
33*0fca6ea1SDimitry Andric ///
34*0fca6ea1SDimitry Andric /// If \p IncludeSelf is enabled, also convert the passed constants themselves
35*0fca6ea1SDimitry Andric /// to instructions, rather than only their users.
36*0fca6ea1SDimitry Andric bool convertUsersOfConstantsToInstructions(ArrayRef<Constant *> Consts,
37*0fca6ea1SDimitry Andric                                            Function *RestrictToFunc = nullptr,
38*0fca6ea1SDimitry Andric                                            bool RemoveDeadConstants = true,
39*0fca6ea1SDimitry Andric                                            bool IncludeSelf = false);
40fe6060f1SDimitry Andric 
41e8d8bef9SDimitry Andric } // end namespace llvm
42e8d8bef9SDimitry Andric 
43e8d8bef9SDimitry Andric #endif // LLVM_IR_REPLACECONSTANT_H
44