LLVM 19.0.0git
Macros | Functions | Variables
Constants.cpp File Reference
#include "llvm/IR/Constants.h"
#include "LLVMContextImpl.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/ConstantFold.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalIFunc.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include "llvm/IR/Value.def"

Go to the source code of this file.

Macros

#define HANDLE_CONSTANT(Name)
 
#define HANDLE_CONSTANT(Name)
 

Functions

static bool containsUndefinedElement (const Constant *C, function_ref< bool(const Constant *)> HasFn)
 
static bool ConstHasGlobalValuePredicate (const Constant *C, bool(*Predicate)(const GlobalValue *))
 Check if C contains a GlobalValue for which Predicate is true.
 
static bool constantIsDead (const Constant *C, bool RemoveDeadUsers)
 Return true if the specified constantexpr is dead.
 
template<typename ItTy , typename EltTy >
static bool rangeOnlyContains (ItTy Start, ItTy End, EltTy Elt)
 
template<typename SequentialTy , typename ElementTy >
static ConstantgetIntSequenceIfElementsMatch (ArrayRef< Constant * > V)
 
template<typename SequentialTy , typename ElementTy >
static ConstantgetFPSequenceIfElementsMatch (ArrayRef< Constant * > V)
 
template<typename SequenceTy >
static ConstantgetSequenceIfElementsMatch (Constant *C, ArrayRef< Constant * > V)
 
static ConstantgetFoldedCast (Instruction::CastOps opc, Constant *C, Type *Ty, bool OnlyIfReduced=false)
 This is a utility function to handle folding of casts and lookup of the cast in the ExprConstants map.
 
static bool isAllZeros (StringRef Arr)
 Return true if the array is empty or all zeros.
 

Variables

static cl::opt< boolUseConstantIntForFixedLengthSplat ("use-constant-int-for-fixed-length-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantInt's native fixed-length vector splat support."))
 
static cl::opt< boolUseConstantFPForFixedLengthSplat ("use-constant-fp-for-fixed-length-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantFP's native fixed-length vector splat support."))
 
static cl::opt< boolUseConstantIntForScalableSplat ("use-constant-int-for-scalable-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantInt's native scalable vector splat support."))
 
static cl::opt< boolUseConstantFPForScalableSplat ("use-constant-fp-for-scalable-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantFP's native scalable vector splat support."))
 

Macro Definition Documentation

◆ HANDLE_CONSTANT [1/2]

#define HANDLE_CONSTANT (   Name)
Value:
case Value::Name##Val: \
cast<Name>(this)->destroyConstantImpl(); \
break;

◆ HANDLE_CONSTANT [2/2]

#define HANDLE_CONSTANT (   Name)
Value:
case Value::Name##Val: \
Replacement = cast<Name>(this)->handleOperandChangeImpl(From, To); \
break;
BlockVerifier::State From

Function Documentation

◆ constantIsDead()

static bool constantIsDead ( const Constant C,
bool  RemoveDeadUsers 
)
static

Return true if the specified constantexpr is dead.

This involves recursively traversing users of the constantexpr. If RemoveDeadUsers is true, also remove dead users at the same time.

Definition at line 693 of file Constants.cpp.

References llvm::CallingConv::C, constantIsDead(), I, and llvm::ReplaceableMetadataImpl::SalvageDebugInfo().

Referenced by constantIsDead(), and llvm::Constant::removeDeadConstantUsers().

◆ ConstHasGlobalValuePredicate()

static bool ConstHasGlobalValuePredicate ( const Constant C,
bool(*)(const GlobalValue *)  Predicate 
)
static

◆ containsUndefinedElement()

static bool containsUndefinedElement ( const Constant C,
function_ref< bool(const Constant *)>  HasFn 
)
static

◆ getFoldedCast()

static Constant * getFoldedCast ( Instruction::CastOps  opc,
Constant C,
Type Ty,
bool  OnlyIfReduced = false 
)
static

◆ getFPSequenceIfElementsMatch()

template<typename SequentialTy , typename ElementTy >
static Constant * getFPSequenceIfElementsMatch ( ArrayRef< Constant * >  V)
static

◆ getIntSequenceIfElementsMatch()

template<typename SequentialTy , typename ElementTy >
static Constant * getIntSequenceIfElementsMatch ( ArrayRef< Constant * >  V)
static

◆ getSequenceIfElementsMatch()

template<typename SequenceTy >
static Constant * getSequenceIfElementsMatch ( Constant C,
ArrayRef< Constant * >  V 
)
static

Definition at line 1243 of file Constants.cpp.

References llvm::CallingConv::C.

◆ isAllZeros()

static bool isAllZeros ( StringRef  Arr)
static

Return true if the array is empty or all zeros.

Definition at line 2767 of file Constants.cpp.

References I.

Referenced by llvm::ConstantDataSequential::getImpl().

◆ rangeOnlyContains()

template<typename ItTy , typename EltTy >
static bool rangeOnlyContains ( ItTy  Start,
ItTy  End,
EltTy  Elt 
)
static

Definition at line 1209 of file Constants.cpp.

References End.

Variable Documentation

◆ UseConstantFPForFixedLengthSplat

cl::opt< bool > UseConstantFPForFixedLengthSplat("use-constant-fp-for-fixed-length-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantFP's native fixed-length vector splat support.")) ( "use-constant-fp-for-fixed-length-splat"  ,
cl::init(false)  ,
cl::Hidden  ,
cl::desc("Use ConstantFP's native fixed-length vector splat support.")   
)
static

◆ UseConstantFPForScalableSplat

cl::opt< bool > UseConstantFPForScalableSplat("use-constant-fp-for-scalable-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantFP's native scalable vector splat support.")) ( "use-constant-fp-for-scalable-splat"  ,
cl::init(false)  ,
cl::Hidden  ,
cl::desc("Use ConstantFP's native scalable vector splat support.")   
)
static

◆ UseConstantIntForFixedLengthSplat

cl::opt< bool > UseConstantIntForFixedLengthSplat("use-constant-int-for-fixed-length-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantInt's native fixed-length vector splat support.")) ( "use-constant-int-for-fixed-length-splat"  ,
cl::init(false)  ,
cl::Hidden  ,
cl::desc("Use ConstantInt's native fixed-length vector splat support.")   
)
static

◆ UseConstantIntForScalableSplat

cl::opt< bool > UseConstantIntForScalableSplat("use-constant-int-for-scalable-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantInt's native scalable vector splat support.")) ( "use-constant-int-for-scalable-splat"  ,
cl::init(false)  ,
cl::Hidden  ,
cl::desc("Use ConstantInt's native scalable vector splat support.")   
)
static