LLVM API Documentation
#include <Constant.h>
This is an important base class in LLVM. It provides the common facilities of all constant values in an LLVM program. A constant is a value that is immutable at runtime. Functions are constants because their address is immutable. Same with global variables.
All constants share the capabilities provided in this class. All constants can have a null value. They can have an operand list. Constants can be simple (integer and floating point values), complex (arrays and structures), or expression based (computations yielding a constant value composed of only certain operators and other constant values).
Note that Constants are immutable (once created they never change) and are fully shared by structural equivalence. This means that two structurally equivalent constants will always have the same address. Constants are created on demand as needed and never deleted: thus clients don't have to worry about the lifetime of the objects.
Definition at line 42 of file Constant.h.
Definition at line 64 of file Constant.h.
| llvm::Constant::Constant | ( | const Type * | ty, | |
| ValueTy | vty, | |||
| Use * | Ops, | |||
| unsigned | NumOps | |||
| ) | [inline, protected] |
Definition at line 47 of file Constant.h.
| void Constant::destroyConstantImpl | ( | ) | [protected] |
Definition at line 102 of file Constants.cpp.
References destroyConstant(), DOUT, llvm::Value::use_back(), llvm::Value::use_empty(), and V.
Referenced by llvm::ConstantVector::destroyConstant(), llvm::ConstantPointerNull::destroyConstant(), llvm::UndefValue::destroyConstant(), llvm::ConstantStruct::destroyConstant(), llvm::ConstantAggregateZero::destroyConstant(), llvm::ConstantArray::destroyConstant(), and llvm::ConstantExpr::destroyConstant().
| virtual bool llvm::Constant::isNullValue | ( | ) | const [pure virtual] |
isNullValue - Return true if this is the value that would be returned by getNullValue.
Implemented in llvm::ConstantInt, llvm::ConstantFP, llvm::ConstantAggregateZero, llvm::ConstantArray, llvm::ConstantStruct, llvm::ConstantVector, llvm::ConstantPointerNull, llvm::ConstantExpr, llvm::UndefValue, and llvm::GlobalValue.
Referenced by canTrap(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldCompareInstruction(), llvm::ConstantFoldExtractElementInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInsertElementInstruction(), llvm::ConstantFoldInsertValueInstruction(), llvm::AsmPrinter::EmitConstantValueOnly(), llvm::AsmPrinter::EmitGlobalConstant(), evaluateICmpRelation(), llvm::ConstantVector::get(), llvm::ConstantArray::get(), isNegativeZeroValue(), isSuitableForBSS(), OptimizeOnceStoredGlobal(), llvm::X86ATTAsmPrinter::PrintGlobalVariable(), llvm::MSILWriter::printStaticConstant(), llvm::MSILWriter::printVariableDefinition(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), llvm::ConstantArray::replaceUsesOfWithOnConstant(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), llvm::PIC16TargetObjectFile::SelectSectionForGlobal(), SymbolicallyEvaluateGEP(), TryToShrinkGlobalToBoolean(), and WriteConstants().
| virtual bool llvm::Constant::isNegativeZeroValue | ( | ) | const [inline, virtual] |
isNegativeZeroValue - Return true if the value is what would be returned by getZeroValueForNegation.
Reimplemented in llvm::ConstantFP.
Definition at line 58 of file Constant.h.
References isNullValue().
| bool Constant::canTrap | ( | ) | const |
canTrap - Return true if evaluation of this constant could trap. This is true for things like constant expressions that could divide by zero.
canTrap - Return true if evaluation of this constant could trap. This is true for things like constant expressions that could divide by zero.
Definition at line 132 of file Constants.cpp.
References canTrap(), llvm::dyn_cast(), llvm::User::getNumOperands(), llvm::ConstantExpr::getOpcode(), getOperand(), llvm::Value::getType(), and isNullValue().
Referenced by canTrap().
| Constant::PossibleRelocationsTy Constant::getRelocationInfo | ( | ) | const |
getRelocationInfo - This method classifies the entry according to whether or not it may generate a relocation entry. This must be conservative, so if it might codegen to a relocatable entry, it should say so. The return values are:
NoRelocation: This constant pool entry is guaranteed to never have a relocation applied to it (because it holds a simple constant like '4'). LocalRelocation: This entry has relocations, but the entries are guaranteed to be resolvable by the static linker, so the dynamic linker will never see them. GlobalRelocations: This entry may have arbitrary relocations.
FIXME: This really should not be in VMCore.
getRelocationInfo - This method classifies the entry according to whether or not it may generate a relocation entry. This must be conservative, so if it might codegen to a relocatable entry, it should say so. The return values are:
NoRelocation: This constant pool entry is guaranteed to never have a relocation applied to it (because it holds a simple constant like '4'). LocalRelocation: This entry has relocations, but the entries are guaranteed to be resolvable by the static linker, so the dynamic linker will never see them. GlobalRelocations: This entry may have arbitrary relocations.
FIXME: This really should not be in VMCore.
Definition at line 175 of file Constants.cpp.
References llvm::User::getNumOperands(), getOperand(), getRelocationInfo(), GlobalRelocations, GV, llvm::GlobalValue::hasHiddenVisibility(), llvm::GlobalValue::hasLocalLinkage(), LocalRelocation, and NoRelocation.
Referenced by llvm::TargetLoweringObjectFile::getKindForGlobal(), and getRelocationInfo().
Definition at line 88 of file Constant.h.
References llvm::User::getOperand().
Referenced by llvm::AddCatchInfo(), AnalyzeGlobal(), llvm::MachineModuleInfo::AnalyzeModule(), BitCastConstantVector(), canTrap(), CheapToScalarize(), CommitValueTo(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldExtractElementInstruction(), llvm::ConstantFoldExtractValueInstruction(), llvm::ConstantFoldInsertValueInstruction(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::ConvertConstant< ConstantStruct, StructType >::convert(), llvm::ConvertConstant< ConstantArray, ArrayType >::convert(), llvm::ConvertConstant< ConstantVector, VectorType >::convert(), llvm::ConvertConstant< ConstantExpr, Type >::convert(), llvm::X86IntelAsmPrinter::EmitString(), llvm::AsmPrinter::EmitString(), evaluateICmpRelation(), EvaluateStoreInto(), FindScalarElement(), FindStaticTors(), findUsedValues(), foldConstantCastPair(), getAggregateConstantElement(), llvm::GlobalAlias::getAliasedGlobal(), llvm::GlobalAlias::getAliasee(), llvm::ConstantArray::getAsString(), getCommonReturnValue(), llvm::GetConstantStringInfo(), llvm::DIDescriptor::getDescriptorField(), llvm::DbgStopPointInst::getDirectory(), llvm::DbgStopPointInst::getFileName(), llvm::DIDescriptor::getGlobalVariableField(), llvm::ShuffleVectorInst::getMaskValue(), getRelocationInfo(), llvm::ConstantVector::getSplatValue(), llvm::DIDescriptor::getStringField(), GetStringLengthH(), llvm::DIDescriptor::getUInt64Field(), getValType(), llvm::SelectionDAGLowering::getValue(), GetVectorElement(), llvm::ConstantExpr::getWithOperandReplaced(), llvm::ConstantExpr::getWithOperands(), llvm::ExecutionEngine::InitializeMemory(), llvm::MachOWriter::InitMem(), InstCombineLoadCast(), llvm::ConstantVector::isAllOnesValue(), IsConstantOffsetFromGlobal(), llvm::ConstantArray::isCString(), llvm::ConstantArray::isString(), ParseGlobalCtors(), printAsCString(), llvm::MSILWriter::printConstantExpr(), llvm::MSILWriter::printStaticConstant(), RemapOperand(), RemoveDeadConstant(), llvm::GlobalVariable::replaceUsesOfWithOnConstant(), llvm::ConstantExpr::replaceUsesOfWithOnConstant(), llvm::ConstantVector::replaceUsesOfWithOnConstant(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), llvm::ConstantArray::replaceUsesOfWithOnConstant(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), WriteConstantInt(), and WriteConstants().
Reimplemented from llvm::User.
Definition at line 91 of file Constant.h.
References llvm::User::getOperand().
Definition at line 94 of file Constant.h.
References llvm::User::setOperand().
Referenced by llvm::GlobalVariable::replaceUsesOfWithOnConstant(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), llvm::ConstantArray::replaceUsesOfWithOnConstant(), and llvm::GlobalAlias::setAliasee().
| void Constant::getVectorElements | ( | LLVMContext & | Context, | |
| SmallVectorImpl< Constant * > & | Elts | |||
| ) | const |
getVectorElements - This method, which is only valid on constant of vector type, returns the elements of the vector in the specified smallvector. This handles breaking down a vector undef into undef elements, etc. For constant exprs and other cases we can't handle, we return an empty vector.
getVectorElements - This method, which is only valid on constant of vector type, returns the elements of the vector in the specified smallvector. This handles breaking down a vector undef into undef elements, etc. For constant exprs and other cases we can't handle, we return an empty vector.
Definition at line 194 of file Constants.cpp.
References llvm::SmallVectorImpl< T >::assign(), llvm::UndefValue::get(), llvm::SequentialType::getElementType(), getNullValue(), llvm::VectorType::getNumElements(), llvm::Value::getType(), llvm::SmallVectorImpl< T >::push_back(), and VT.
Referenced by llvm::ConstantFoldCompareInstruction().
| virtual void llvm::Constant::destroyConstant | ( | ) | [inline, virtual] |
destroyConstant - Called if some element of this constant is no longer valid. At this point only other constants may be on the use_list for this constant. Any constants on our Use list must also be destroy'd. The implementation must be sure to remove the constant from the list of available cached constants. Implementations should call destroyConstantImpl as the last thing they do, to destroy all users and delete this.
Reimplemented in llvm::ConstantAggregateZero, llvm::ConstantArray, llvm::ConstantStruct, llvm::ConstantVector, llvm::ConstantPointerNull, llvm::ConstantExpr, llvm::UndefValue, and llvm::GlobalValue.
Definition at line 112 of file Constant.h.
Referenced by destroyConstantImpl(), RemoveDeadConstant(), and llvm::BitcodeReaderValueList::ResolveConstantForwardRefs().
Definition at line 115 of file Constant.h.
| static bool llvm::Constant::classof | ( | const GlobalValue * | ) | [inline, static] |
Reimplemented from llvm::User.
Reimplemented in llvm::ConstantInt, llvm::ConstantFP, llvm::ConstantAggregateZero, llvm::ConstantArray, llvm::ConstantStruct, llvm::ConstantVector, llvm::ConstantPointerNull, llvm::ConstantExpr, llvm::UndefValue, llvm::Function, llvm::GlobalAlias, llvm::GlobalValue, and llvm::GlobalVariable.
Definition at line 117 of file Constant.h.
References llvm::Value::ConstantFirstVal, llvm::Value::ConstantLastVal, and llvm::Value::getValueID().
| virtual void llvm::Constant::replaceUsesOfWithOnConstant | ( | Value * | , | |
| Value * | , | |||
| Use * | ||||
| ) | [inline, virtual] |
replaceUsesOfWithOnConstant - This method is a special form of User::replaceUsesOfWith (which does not work on constants) that does work on constants. Basically this method goes through the trouble of building a new constant that is equivalent to the current one, with all uses of From replaced with uses of To. After this construction is completed, all of the users of 'this' are replaced to use the new constant, and then 'this' is deleted. In general, you should not call this method, instead, use Value::replaceAllUsesWith, which automatically dispatches to this method as needed.
Reimplemented in llvm::ConstantArray, llvm::ConstantStruct, llvm::ConstantVector, llvm::ConstantExpr, and llvm::GlobalVariable.
Definition at line 132 of file Constant.h.
References llvm::User::getNumOperands().
Definition at line 45 of file Constants.cpp.
References llvm::lltok::APFloat, llvm::Type::ArrayTyID, llvm::Type::DoubleTyID, llvm::Type::FloatTyID, llvm::Type::FP128TyID, llvm::ConstantAggregateZero::get(), llvm::ConstantPointerNull::get(), llvm::ConstantFP::get(), llvm::ConstantInt::get(), llvm::Type::getContext(), llvm::Type::getTypeID(), llvm::Type::IntegerTyID, llvm::Type::PointerTyID, llvm::Type::PPC_FP128TyID, llvm::Type::StructTyID, llvm::Type::VectorTyID, llvm::Type::X86_FP80TyID, and zero.
Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCall(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldCompareInstruction(), llvm::ConstantFoldExtractElementInstruction(), llvm::ConstantFoldExtractValueInstruction(), llvm::ConstantFoldInsertElementInstruction(), llvm::ConstantFoldInsertValueInstruction(), llvm::ConstantFoldInstOperands(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::DIFactory::CreateCompileUnit(), llvm::DIFactory::CreateGlobalVariable(), llvm::IRBuilder< true, llvm::TargetFolder >::CreateIsNotNull(), llvm::IRBuilder< true, llvm::TargetFolder >::CreateIsNull(), llvm::DIFactory::CreateSubprogram(), evaluateICmpRelation(), llvm::FindInsertedValue(), llvm::X86InstrInfo::foldMemoryOperandImpl(), GetAddressedElementFromGlobal(), getAggregateConstantElement(), llvm::ConstantExpr::getAlignOf(), llvm::ConstantFP::getNegativeZero(), llvm::ConstantExpr::getOffsetOf(), llvm::FastISel::getRegForValue(), llvm::ConstantExpr::getSizeOf(), GetVectorElement(), getVectorElements(), llvm::ConstantFP::getZeroValueForNegation(), llvm::RSProfilers_std::IncrementCounterInBlock(), llvm::IncrementCounterInBlock(), llvm::InsertProfilingInitCall(), llvm::IntrinsicLowering::LowerIntrinsicCall(), OptimizeGlobalAddressOfMalloc(), PerformHeapAllocSRoA(), llvm::RemoveSuccessor(), RewriteHeapSROALoadUser(), and SRAGlobal().
Get the all ones value.
Definition at line 90 of file Constants.cpp.
References llvm::ConstantVector::get(), llvm::ConstantInt::get(), llvm::APInt::getAllOnesValue(), llvm::Type::getContext(), llvm::SequentialType::getElementType(), and llvm::VectorType::getNumElements().
Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCompareInstruction(), llvm::BinaryOperator::CreateNot(), llvm::X86InstrInfo::foldMemoryOperandImpl(), llvm::ScalarEvolution::getNegativeSCEV(), llvm::ConstantExpr::getNot(), and llvm::ScalarEvolution::getNotSCEV().
getIntegerValue - Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value.
Definition at line 73 of file Constants.cpp.
References llvm::CallingConv::C, llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::Type::getContext(), llvm::ConstantExpr::getIntToPtr(), and llvm::Type::getScalarType().