1f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//===-- InstructionSimplify.h - Fold instrs into simpler forms --*- C++ -*-===// 2f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 3f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// The LLVM Compiler Infrastructure 4f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 5f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// This file is distributed under the University of Illinois Open Source 6f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// License. See LICENSE.TXT for details. 7f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 8f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//===----------------------------------------------------------------------===// 9f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 10f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// This file declares routines for folding instructions into simpler forms 11f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// that do not require creating new instructions. This does constant folding 12f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// ("add i32 1, 1" -> "2") but can also handle non-constant operands, either 13f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// returning a constant ("and i32 %x, 0" -> "0") or an already existing value 14f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// ("and i32 %x, %x" -> "%x"). If the simplification is also an instruction 15f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// then it dominates the original instruction. 16f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 17f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// These routines implicitly resolve undef uses. The easiest way to be safe when 18f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// using these routines to obtain simplified values for existing instructions is 19f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// to always replace all uses of the instructions with the resulting simplified 20f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// values. This will prevent other code from seeing the same undef uses and 21f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// resolving them to different values. 22f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 23f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// These routines are designed to tolerate moderately incomplete IR, such as 24f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// instructions that are not connected to basic blocks yet. However, they do 25f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// require that all the IR that they encounter be valid. In particular, they 26f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// require that all non-constant values be defined in the same function, and the 27f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// same call context of that function (and not split between caller and callee 28f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// contexts of a directly recursive call, for example). 29f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// 30f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//===----------------------------------------------------------------------===// 31f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 32f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#ifndef LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H 33f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#define LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H 34f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 35f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#include "llvm/IR/User.h" 36f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 37f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotnamespace llvm { 38f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Function; 39f3014761c955345d6e05491608e73228d014afbandroid-build-team Robottemplate <typename T, typename... TArgs> class AnalysisManager; 40f3014761c955345d6e05491608e73228d014afbandroid-build-team Robottemplate <class T> class ArrayRef; 41f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass AssumptionCache; 42f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass DominatorTree; 43f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Instruction; 44f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass ImmutableCallSite; 45f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass DataLayout; 46f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass FastMathFlags; 47f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotstruct LoopStandardAnalysisResults; 48f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass OptimizationRemarkEmitter; 49f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Pass; 50f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass TargetLibraryInfo; 51f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Type; 52f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotclass Value; 53f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 54f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotstruct SimplifyQuery { 55f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const DataLayout &DL; 56f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const TargetLibraryInfo *TLI = nullptr; 57f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const DominatorTree *DT = nullptr; 58f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot AssumptionCache *AC = nullptr; 59f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const Instruction *CxtI = nullptr; 60f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 61f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SimplifyQuery(const DataLayout &DL, const Instruction *CXTI = nullptr) 62f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot : DL(DL), CxtI(CXTI) {} 63f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 64f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SimplifyQuery(const DataLayout &DL, const TargetLibraryInfo *TLI, 65f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const DominatorTree *DT = nullptr, 66f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot AssumptionCache *AC = nullptr, 67f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const Instruction *CXTI = nullptr) 68f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot : DL(DL), TLI(TLI), DT(DT), AC(AC), CxtI(CXTI) {} 69f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SimplifyQuery getWithInstruction(Instruction *I) const { 70f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot SimplifyQuery Copy(*this); 71f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot Copy.CxtI = I; 72f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot return Copy; 73f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot } 74f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot}; 75f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 76f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// NOTE: the explicit multiple argument versions of these functions are 77f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// deprecated. 78f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// Please use the SimplifyQuery versions in new code. 79f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 80f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an Add, fold the result or return null. 81f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyAddInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, 82f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 83f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 84f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a Sub, fold the result or return null. 85f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifySubInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, 86f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 87f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 88f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an FAdd, fold the result or return null. 89f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyFAddInst(Value *LHS, Value *RHS, FastMathFlags FMF, 90f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 91f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 92f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an FSub, fold the result or return null. 93f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyFSubInst(Value *LHS, Value *RHS, FastMathFlags FMF, 94f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 95f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 96f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an FMul, fold the result or return null. 97f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyFMulInst(Value *LHS, Value *RHS, FastMathFlags FMF, 98f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 99f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 100f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a Mul, fold the result or return null. 101f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyMulInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); 102f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 103f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an SDiv, fold the result or return null. 104f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifySDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); 105f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 106f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a UDiv, fold the result or return null. 107f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyUDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); 108f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 109f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an FDiv, fold the result or return null. 110f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyFDivInst(Value *LHS, Value *RHS, FastMathFlags FMF, 111f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 112f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 113f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an SRem, fold the result or return null. 114f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifySRemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); 115f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 116f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a URem, fold the result or return null. 117f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyURemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); 118f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 119f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an FRem, fold the result or return null. 120f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyFRemInst(Value *LHS, Value *RHS, FastMathFlags FMF, 121f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 122f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 123f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a Shl, fold the result or return null. 124f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, 125f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 126f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 127f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a LShr, fold the result or return null. 128f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyLShrInst(Value *Op0, Value *Op1, bool isExact, 129f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 130f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 131f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a AShr, fold the result or return nulll. 132f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyAShrInst(Value *Op0, Value *Op1, bool isExact, 133f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 134f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 135f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an And, fold the result or return null. 136f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyAndInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); 137f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 138f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an Or, fold the result or return null. 139f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyOrInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); 140f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 141f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an Xor, fold the result or return null. 142f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyXorInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); 143f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 144f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an ICmpInst, fold the result or return null. 145f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, 146f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 147f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 148f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an FCmpInst, fold the result or return null. 149f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, 150f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot FastMathFlags FMF, const SimplifyQuery &Q); 151f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 152f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a SelectInst, fold the result or return null. 153f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, 154f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 155f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 156f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a GetElementPtrInst, fold the result or return null. 157f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyGEPInst(Type *SrcTy, ArrayRef<Value *> Ops, 158f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 159f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 160f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an InsertValueInst, fold the result or return null. 161f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyInsertValueInst(Value *Agg, Value *Val, ArrayRef<unsigned> Idxs, 162f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 163f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 164f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an ExtractValueInst, fold the result or return null. 165f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs, 166f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 167f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 168f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an ExtractElementInst, fold the result or return null. 169f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyExtractElementInst(Value *Vec, Value *Idx, 170f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 171f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 172f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a CastInst, fold the result or return null. 173f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, 174f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 175f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 176f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a ShuffleVectorInst, fold the result or return null. 177f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyShuffleVectorInst(Value *Op0, Value *Op1, Constant *Mask, 178f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot Type *RetTy, const SimplifyQuery &Q); 179f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 180f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot//=== Helper functions for higher up the class hierarchy. 181f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 182f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a CmpInst, fold the result or return null. 183f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, 184f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 185f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 186f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for a BinaryOperator, fold the result or return null. 187f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, 188f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 189f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 190f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given operands for an FP BinaryOperator, fold the result or return null. 191f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// In contrast to SimplifyBinOp, try to use FastMathFlag when folding the 192f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// result. In case we don't need FastMathFlags, simply fall to SimplifyBinOp. 193f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyFPBinOp(unsigned Opcode, Value *LHS, Value *RHS, 194f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot FastMathFlags FMF, const SimplifyQuery &Q); 195f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 196f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given a function and iterators over arguments, fold the result or return 197f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// null. 198f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyCall(ImmutableCallSite CS, Value *V, User::op_iterator ArgBegin, 199f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot User::op_iterator ArgEnd, const SimplifyQuery &Q); 200f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 201f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Given a function and set of arguments, fold the result or return null. 202f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyCall(ImmutableCallSite CS, Value *V, ArrayRef<Value *> Args, 203f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const SimplifyQuery &Q); 204f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 205f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// See if we can compute a simplified version of this instruction. If not, 206f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// return null. 207f3014761c955345d6e05491608e73228d014afbandroid-build-team RobotValue *SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, 208f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot OptimizationRemarkEmitter *ORE = nullptr); 209f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 210f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Replace all uses of 'I' with 'SimpleV' and simplify the uses recursively. 211f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// 212f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// This first performs a normal RAUW of I with SimpleV. It then recursively 213f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// attempts to simplify those users updated by the operation. The 'I' 214f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// instruction must not be equal to the simplified value 'SimpleV'. 215f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// 216f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// The function returns true if any simplifications were performed. 217f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotbool replaceAndRecursivelySimplify(Instruction *I, Value *SimpleV, 218f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const TargetLibraryInfo *TLI = nullptr, 219f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const DominatorTree *DT = nullptr, 220f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot AssumptionCache *AC = nullptr); 221f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 222f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// Recursively attempt to simplify an instruction. 223f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// 224f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// This routine uses SimplifyInstruction to simplify 'I', and if successful 225f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// replaces uses of 'I' with the simplified value. It then recurses on each 226f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// of the users impacted. It returns true if any simplifications were 227f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot/// performed. 228f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotbool recursivelySimplifyInstruction(Instruction *I, 229f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const TargetLibraryInfo *TLI = nullptr, 230f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const DominatorTree *DT = nullptr, 231f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot AssumptionCache *AC = nullptr); 232f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 233f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// These helper functions return a SimplifyQuery structure that contains as 234f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// many of the optional analysis we use as are currently valid. This is the 235f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot// strongly preferred way of constructing SimplifyQuery in passes. 236f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotconst SimplifyQuery getBestSimplifyQuery(Pass &, Function &); 237f3014761c955345d6e05491608e73228d014afbandroid-build-team Robottemplate <class T, class... TArgs> 238f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotconst SimplifyQuery getBestSimplifyQuery(AnalysisManager<T, TArgs...> &, 239f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot Function &); 240f3014761c955345d6e05491608e73228d014afbandroid-build-team Robotconst SimplifyQuery getBestSimplifyQuery(LoopStandardAnalysisResults &, 241f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot const DataLayout &); 242f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot} // end namespace llvm 243f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 244f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot#endif 245f3014761c955345d6e05491608e73228d014afbandroid-build-team Robot 246