LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

llvm::Constant Class Reference

LLVM Constant Representation. More...

#include <Constant.h>

Inheritance diagram for llvm::Constant:

Inheritance graph
[legend]
Collaboration diagram for llvm::Constant:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual bool isNullValue () const =0
bool canTrap () const
bool ContainsRelocations () const
ConstantgetOperand (unsigned i)
const ConstantgetOperand (unsigned i) const
void setOperand (unsigned i, Constant *C)
void getVectorElements (SmallVectorImpl< Constant * > &Elts) const
virtual void destroyConstant ()
virtual void replaceUsesOfWithOnConstant (Value *, Value *, Use *)

Static Public Member Functions

ConstantgetNullValue (const Type *Ty)
ConstantgetAllOnesValue (const Type *Ty)
bool classof (const Constant *)
bool classof (const GlobalValue *)
bool classof (const Value *V)

Protected Member Functions

 Constant (const Type *ty, ValueTy vty, Use *Ops, unsigned NumOps)
void destroyConstantImpl ()

Detailed Description

LLVM Constant Representation.

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. Constant's 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 39 of file Constant.h.


Constructor & Destructor Documentation

llvm::Constant::Constant const Type ty,
ValueTy  vty,
Use Ops,
unsigned  NumOps
[inline, protected]
 

Definition at line 43 of file Constant.h.


Member Function Documentation

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.

Definition at line 65 of file Constants.cpp.

References llvm::User::getNumOperands(), llvm::ConstantExpr::getOpcode(), getOperand(), llvm::Value::getType(), and isNullValue().

Referenced by DominatesMergePoint(), and SimplifyCondBranchToTwoReturns().

bool llvm::Constant::classof const Value V  )  [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, llvm::GlobalVariable, and llvm::ConstantPlaceHolder.

Definition at line 99 of file Constant.h.

References llvm::Value::getValueID().

bool llvm::Constant::classof const GlobalValue  )  [inline, static]
 

Reimplemented in llvm::GlobalValue.

Definition at line 98 of file Constant.h.

bool llvm::Constant::classof const Constant  )  [inline, static]
 

Definition at line 97 of file Constant.h.

bool Constant::ContainsRelocations  )  const
 

ContaintsRelocations - Return true if the constant value contains relocations which cannot be resolved at compile time.

Definition at line 95 of file Constants.cpp.

References llvm::User::getNumOperands(), and getOperand().

Referenced by llvm::TargetAsmInfo::SectionKindForGlobal().

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 94 of file Constant.h.

Referenced by CleanupConstantGlobalUsers(), llvm::ConvertConstantType< ConstantExpr, Type >::convert(), destroyConstantImpl(), RemoveDeadConstant(), removeDeadUsersOfConstant(), and llvm::BitcodeReaderValueList::ResolveConstantForwardRefs().

void Constant::destroyConstantImpl  )  [protected]
 

Definition at line 35 of file Constants.cpp.

References destroyConstant(), DOUT, llvm::Value::use_back(), and llvm::Value::use_empty().

Referenced by llvm::ConstantExpr::destroyConstant(), llvm::UndefValue::destroyConstant(), llvm::ConstantPointerNull::destroyConstant(), llvm::ConstantVector::destroyConstant(), llvm::ConstantStruct::destroyConstant(), llvm::ConstantArray::destroyConstant(), and llvm::ConstantAggregateZero::destroyConstant().

Constant * Constant::getAllOnesValue const Type Ty  )  [static]
 

Static constructor to get a '-1' constant. This supports integers and vectors.

Reimplemented in llvm::ConstantInt.

Definition at line 133 of file Constants.cpp.

References llvm::ConstantInt::get(), llvm::ConstantVector::getAllOnesValue(), and llvm::IntegerType::getBitWidth().

Constant * Constant::getNullValue const Type Ty  )  [static]
 

Static constructor to get a '0' constant of arbitrary type...

Definition at line 105 of file Constants.cpp.

References llvm::ConstantAggregateZero::get(), llvm::ConstantPointerNull::get(), llvm::ConstantFP::get(), llvm::ConstantInt::get(), and llvm::Type::getTypeID().

Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCall(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldExtractElementInstruction(), llvm::ConstantFoldExtractValueInstruction(), llvm::ConstantFoldInsertElementInstruction(), llvm::ConstantFoldInsertValueInstruction(), llvm::ConstantFoldInstruction(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), EvalVectorOp(), llvm::FindInsertedValue(), FoldBitCast(), llvm::ConstantExpr::getSizeOf(), GetVectorElement(), getVectorElements(), and llvm::RemoveSuccessor().

const Constant* llvm::Constant::getOperand unsigned  i  )  const [inline]
 

Reimplemented from llvm::User.

Definition at line 74 of file Constant.h.

Constant* llvm::Constant::getOperand unsigned  i  )  [inline]
 

Definition at line 71 of file Constant.h.

Referenced by llvm::AddCatchInfo(), BasicAliasAnalysis::alias(), llvm::MachineModuleInfo::AnalyzeModule(), DIVerifyVisitor::Apply(), DIDeserializeVisitor::Apply(), AddMaskingAnd::apply(), AddRHS::apply(), BitCastConstantVector(), canTrap(), CastOperand(), CheapToScalarize(), CommitValueTo(), InstCombiner::commonPointerCastTransforms(), ComputeLoadResult(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldExtractElementInstruction(), llvm::ConstantFoldExtractValueInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInsertElementInstruction(), llvm::ConstantFoldInsertValueInstruction(), llvm::ConstantFoldInstOperands(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), PruningFunctionCloner::ConstantFoldMappedInstruction(), ContainsRelocations(), llvm::ConvertConstantType< ConstantExpr, Type >::convert(), llvm::ConvertConstantType< ConstantVector, VectorType >::convert(), llvm::ConvertConstantType< ConstantStruct, StructType >::convert(), llvm::ConvertConstantType< ConstantArray, ArrayType >::convert(), SimpleInliner::doInitialization(), llvm::AsmPrinter::EmitConstantValueOnly(), llvm::AsmPrinter::EmitGlobalConstant(), llvm::X86IntelAsmPrinter::EmitString(), llvm::AsmPrinter::EmitString(), evaluateICmpRelation(), EvaluateStoreInto(), EvalVectorOp(), llvm::FindInsertedValue(), FindScalarElement(), FindStaticTors(), FoldBitCast(), foldConstantCastPair(), InstCombiner::FoldShiftByConstant(), GetAddressedElementFromGlobal(), getAggregateConstantElement(), llvm::GlobalAlias::getAliasedGlobal(), llvm::ConstantArray::getAsString(), getBitCastOperand(), llvm::GetConstantStringInfo(), llvm::ExecutionEngine::getConstantValue(), llvm::DbgStopPointInst::getDirectory(), llvm::DOTGraphTraits< SelectionDAG * >::getEdgeAttributes(), llvm::DbgStopPointInst::getFileName(), llvm::ProgramInfo::getFunction(), getGlobalVariable(), llvm::ShuffleVectorInst::getMaskValue(), llvm::ProgramInfo::getSourceFile(), llvm::ConstantVector::getSplatValue(), GetStringLengthH(), getUIntOperand(), GetUnderlyingObject(), getUnderlyingObject(), getValType(), llvm::SelectionDAGLowering::getValue(), GetVectorElement(), getVectorElements(), llvm::ConstantExpr::getWithOperandReplaced(), llvm::ConstantExpr::getWithOperands(), llvm::ExecutionEngine::InitializeMemory(), llvm::MachOWriter::InitMem(), InstCombineLoadCast(), llvm::ConstantVector::isAllOnesValue(), IsAlwaysValidPointer(), IsConstantOffsetFromGlobal(), llvm::ConstantArray::isCString(), isGlobalVariable(), isSimpleEnoughPointerToCommit(), llvm::ConstantArray::isString(), isStringValue(), isTargetConstant(), LinkAppendingVars(), llvm::PatternMatch::neg_match< LHS_t >::match(), llvm::PatternMatch::not_match< LHS_t >::match(), llvm::PatternMatch::BinaryOpClass_match< LHS_t, RHS_t, Class, OpcType >::match(), llvm::PatternMatch::Shr_match< LHS_t, RHS_t, ConcreteTy >::match(), llvm::PatternMatch::BinaryOp_match< LHS_t, RHS_t, Opcode, ConcreteTy >::match(), ParseGlobalCtors(), PointsToConstantGlobal(), printAsCString(), MSILWriter::printConstantExpr(), MSILWriter::printStaticConstant(), RemapOperand(), RemoveDeadConstant(), llvm::GlobalVariable::replaceUsesOfWithOnConstant(), llvm::ConstantExpr::replaceUsesOfWithOnConstant(), llvm::ConstantVector::replaceUsesOfWithOnConstant(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), llvm::ConstantArray::replaceUsesOfWithOnConstant(), llvm::DebugLabelFolder::runOnMachineFunction(), StripSymbols::runOnModule(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), llvm::SourceFileInfo::SourceFileInfo(), llvm::SourceFunctionInfo::SourceFunctionInfo(), SRAGlobal(), llvm::Value::stripPointerCasts(), SymbolicallyEvaluateGEP(), InstCombiner::visitCallInst(), InstCombiner::visitExtractElementInst(), InstCombiner::visitExtractValueInst(), Verifier::visitGlobalAlias(), InstCombiner::visitLoadInst(), Verifier::visitShuffleVectorInst(), WriteConstantInt(), and WriteConstants().

void Constant::getVectorElements 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.

Definition at line 162 of file Constants.cpp.

References llvm::SmallVectorImpl< T >::assign(), llvm::UndefValue::get(), llvm::SequentialType::getElementType(), getNullValue(), llvm::VectorType::getNumElements(), llvm::User::getNumOperands(), getOperand(), llvm::Value::getType(), and llvm::SmallVectorImpl< T >::push_back().

Referenced by llvm::ConstantFoldCompareInstruction(), llvm::ConstantExpr::getVFCmp(), and llvm::ConstantExpr::getVICmp().

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 BasicAliasAnalysis::alias(), DIVerifyVisitor::Apply(), DIDeserializeVisitor::Apply(), canTrap(), InstCombiner::commonRemTransforms(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldCompareInstruction(), llvm::ConstantFoldExtractElementInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInsertElementInstruction(), llvm::ConstantFoldInsertValueInstruction(), LinuxAsmPrinter::doFinalization(), PIC16AsmPrinter::doFinalization(), llvm::AsmPrinter::EmitConstantValueOnly(), llvm::AsmPrinter::EmitGlobalConstant(), evaluateICmpRelation(), FindStaticTors(), llvm::ConstantVector::get(), llvm::ConstantArray::get(), getGlobalVariable(), isGlobalVariable(), IsOnlyUsedInZeroEqualityComparison(), isSuitableForBSS(), MSILWriter::isZeroValue(), LLVMIsNull(), llvm::PatternMatch::zero_ty::match(), OptimizeOnceStoredGlobal(), llvm::X86ATTAsmPrinter::printModuleLevelGV(), SparcAsmPrinter::printModuleLevelGV(), PPCDarwinAsmPrinter::printModuleLevelGV(), PPCLinuxAsmPrinter::printModuleLevelGV(), MipsAsmPrinter::printModuleLevelGV(), IA64AsmPrinter::printModuleLevelGV(), ARMAsmPrinter::printModuleLevelGV(), MSILWriter::printStaticConstant(), MSILWriter::printVariableDefinition(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), llvm::ConstantArray::replaceUsesOfWithOnConstant(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), AddMaskingAnd::shouldApply(), InstCombiner::SimplifyDivRemOfSelect(), llvm::Value::stripPointerCasts(), SymbolicallyEvaluateGEP(), TryToShrinkGlobalToBoolean(), InstCombiner::visitAdd(), InstCombiner::visitCallInst(), InstCombiner::visitGetElementPtrInst(), InstCombiner::visitICmpInst(), InstCombiner::visitLoadInst(), and WriteConstants().

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 114 of file Constant.h.

Referenced by llvm::Value::uncheckedReplaceAllUsesWith().

void llvm::Constant::setOperand unsigned  i,
Constant C
[inline]
 

Definition at line 77 of file Constant.h.

Referenced by llvm::GlobalVariable::replaceUsesOfWithOnConstant(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), llvm::ConstantArray::replaceUsesOfWithOnConstant(), and llvm::GlobalAlias::setAliasee().


The documentation for this class was generated from the following files:


This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.