LLVM  14.0.0git
ReplaceConstant.h
Go to the documentation of this file.
1 //===- ReplaceConstant.h - Replacing LLVM constant expressions --*- 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 // This file declares the utility function for replacing LLVM constant
10 // expressions by instructions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_IR_REPLACECONSTANT_H
15 #define LLVM_IR_REPLACECONSTANT_H
16 
17 #include "llvm/IR/Constants.h"
18 #include "llvm/IR/Instruction.h"
19 #include <map>
20 #include <vector>
21 
22 namespace llvm {
23 
24 /// The given instruction \p I contains given constant expression \p CE as one
25 /// of its operands, possibly nested within constant expression trees. Convert
26 /// all reachable paths from contant expression operands of \p I to \p CE into
27 /// corresponding instructions, insert them before \p I, update operands of \p I
28 /// accordingly, and if required, return all such converted instructions at
29 /// \p Insts.
31  Instruction *I, ConstantExpr *CE,
32  SmallPtrSetImpl<Instruction *> *Insts = nullptr);
33 
34 /// The given instruction \p I contains constant expression CE within the
35 /// constant expression trees of it`s constant expression operands, and
36 /// \p CEPaths holds all the reachable paths (to CE) from such constant
37 /// expression trees of \p I. Convert constant expressions within these paths
38 /// into corresponding instructions, insert them before \p I, update operands of
39 /// \p I accordingly, and if required, return all such converted instructions at
40 /// \p Insts.
42  Instruction *I,
43  std::map<Use *, std::vector<std::vector<ConstantExpr *>>> &CEPaths,
44  SmallPtrSetImpl<Instruction *> *Insts = nullptr);
45 
46 /// Given an instruction \p I which uses given constant expression \p CE as
47 /// operand, either directly or nested within other constant expressions, return
48 /// all reachable paths from the constant expression operands of \p I to \p CE,
49 /// and return collected paths at \p CEPaths.
51  Instruction *I, ConstantExpr *CE,
52  std::map<Use *, std::vector<std::vector<ConstantExpr *>>> &CEPaths);
53 
54 } // end namespace llvm
55 
56 #endif // LLVM_IR_REPLACECONSTANT_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
Instruction.h
Constants.h
llvm::convertConstantExprsToInstructions
void convertConstantExprsToInstructions(Instruction *I, ConstantExpr *CE, SmallPtrSetImpl< Instruction * > *Insts=nullptr)
The given instruction I contains given constant expression CE as one of its operands,...
Definition: ReplaceConstant.cpp:22
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::collectConstantExprPaths
void collectConstantExprPaths(Instruction *I, ConstantExpr *CE, std::map< Use *, std::vector< std::vector< ConstantExpr * >>> &CEPaths)
Given an instruction I which uses given constant expression CE as operand, either directly or nested ...
Definition: ReplaceConstant.cpp:96