LLVM API Documentation
00001 //===- llvm/Analysis/ValueTracking.h - Walk computations --------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains routines that help analyze properties that chains of 00011 // computations have. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_ANALYSIS_VALUETRACKING_H 00016 #define LLVM_ANALYSIS_VALUETRACKING_H 00017 00018 #include "llvm/Support/DataTypes.h" 00019 #include <string> 00020 00021 namespace llvm { 00022 class Value; 00023 class Instruction; 00024 class APInt; 00025 class TargetData; 00026 00027 /// ComputeMaskedBits - Determine which of the bits specified in Mask are 00028 /// known to be either zero or one and return them in the KnownZero/KnownOne 00029 /// bit sets. This code only analyzes bits in Mask, in order to short-circuit 00030 /// processing. 00031 void ComputeMaskedBits(Value *V, const APInt &Mask, APInt &KnownZero, 00032 APInt &KnownOne, TargetData *TD = 0, 00033 unsigned Depth = 0); 00034 00035 /// MaskedValueIsZero - Return true if 'V & Mask' is known to be zero. We use 00036 /// this predicate to simplify operations downstream. Mask is known to be 00037 /// zero for bits that V cannot have. 00038 bool MaskedValueIsZero(Value *V, const APInt &Mask, 00039 TargetData *TD = 0, unsigned Depth = 0); 00040 00041 00042 /// ComputeNumSignBits - Return the number of times the sign bit of the 00043 /// register is replicated into the other bits. We know that at least 1 bit 00044 /// is always equal to the sign bit (itself), but other cases can give us 00045 /// information. For example, immediately after an "ashr X, 2", we know that 00046 /// the top 3 bits are all equal to each other, so we return 3. 00047 /// 00048 /// 'Op' must have a scalar integer type. 00049 /// 00050 unsigned ComputeNumSignBits(Value *Op, TargetData *TD = 0, 00051 unsigned Depth = 0); 00052 00053 /// CannotBeNegativeZero - Return true if we can prove that the specified FP 00054 /// value is never equal to -0.0. 00055 /// 00056 bool CannotBeNegativeZero(const Value *V, unsigned Depth = 0); 00057 00058 /// FindScalarValue - Given an aggregrate and an sequence of indices, see if 00059 /// the scalar value indexed is already around as a register, for example if 00060 /// it were inserted directly into the aggregrate. 00061 /// 00062 /// If InsertBefore is not null, this function will duplicate (modified) 00063 /// insertvalues when a part of a nested struct is extracted. 00064 Value *FindInsertedValue(Value *V, 00065 const unsigned *idx_begin, 00066 const unsigned *idx_end, 00067 Instruction *InsertBefore = 0); 00068 00069 /// This is a convenience wrapper for finding values indexed by a single index 00070 /// only. 00071 inline Value *FindInsertedValue(Value *V, const unsigned Idx, 00072 Instruction *InsertBefore = 0) { 00073 const unsigned Idxs[1] = { Idx }; 00074 return FindInsertedValue(V, &Idxs[0], &Idxs[1], InsertBefore); 00075 } 00076 00077 /// GetConstantStringInfo - This function computes the length of a 00078 /// null-terminated C string pointed to by V. If successful, it returns true 00079 /// and returns the string in Str. If unsuccessful, it returns false. If 00080 /// StopAtNul is set to true (the default), the returned string is truncated 00081 /// by a nul character in the global. If StopAtNul is false, the nul 00082 /// character is included in the result string. 00083 bool GetConstantStringInfo(Value *V, std::string &Str, uint64_t Offset = 0, 00084 bool StopAtNul = true); 00085 } // end namespace llvm 00086 00087 #endif