LLVM API Documentation
#include <Constant.h>
Inheritance diagram for llvm::Constant:


Public Member Functions | |
| virtual bool | isNullValue () const =0 |
| bool | canTrap () const |
| bool | ContainsRelocations () const |
| Constant * | getOperand (unsigned i) |
| const Constant * | getOperand (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 | |
| Constant * | getNullValue (const Type *Ty) |
| Constant * | getAllOnesValue (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 () |
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.
|
||||||||||||||||||||
|
Definition at line 43 of file Constant.h. |
|
|
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(). |
|
|
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(). |
|
|
Reimplemented in llvm::GlobalValue. Definition at line 98 of file Constant.h. |
|
|
Definition at line 97 of file Constant.h. |
|
|
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(). |
|
|
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(). |
|
|
|
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(). |
|
|
|
Reimplemented from llvm::User. Definition at line 74 of file Constant.h. |
|
|
|
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(). |
|
|
||||||||||||||||
|
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(). |
|
||||||||||||
|
Definition at line 77 of file Constant.h. Referenced by llvm::GlobalVariable::replaceUsesOfWithOnConstant(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), llvm::ConstantArray::replaceUsesOfWithOnConstant(), and llvm::GlobalAlias::setAliasee(). |