LLVM API Documentation
#include <Constant.h>
Inheritance diagram for llvm::Constant:
Public Member Functions | |
virtual bool | isNullValue () const=0 |
virtual void | print (std::ostream &O) const |
Constant * | getOperand (unsigned i) |
const Constant * | getOperand (unsigned i) const |
void | setOperand (unsigned i, Constant *C) |
virtual void | destroyConstant () |
virtual void | replaceUsesOfWithOnConstant (Value *, Value *, Use *) |
std::string | getStringValue (bool Chop=true, unsigned Offset=0) |
Static Public Member Functions | |
static Constant * | getNullValue (const Type *Ty) |
static bool | classof (const Constant *) |
static bool | classof (const GlobalValue *) |
static bool | classof (const Value *V) |
static void | clearAllValueMaps () |
Protected Member Functions | |
Constant (const Type *Ty, ValueTy vty, Use *Ops, unsigned NumOps, const std::string &Name="") | |
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 38 of file Constant.h.
void Constant::destroyConstantImpl | ( | ) | [protected] |
Definition at line 36 of file Constants.cpp.
References destroyConstant(), llvm::Value::use_back(), llvm::Value::use_empty(), and V.
Referenced by llvm::ConstantExpr::destroyConstant(), llvm::UndefValue::destroyConstant(), llvm::ConstantPointerNull::destroyConstant(), llvm::ConstantPacked::destroyConstant(), llvm::ConstantStruct::destroyConstant(), llvm::ConstantArray::destroyConstant(), and llvm::ConstantAggregateZero::destroyConstant().
Static constructor to get a '0' constant of arbitrary type...
Definition at line 65 of file Constants.cpp.
References llvm::Type::ArrayTyID, llvm::Type::BoolTyID, llvm::Type::DoubleTy, llvm::Type::DoubleTyID, llvm::Type::FloatTy, llvm::Type::FloatTyID, llvm::ConstantAggregateZero::get(), llvm::ConstantPointerNull::get(), llvm::ConstantFP::get(), llvm::ConstantUInt::get(), llvm::ConstantSInt::get(), llvm::ConstantBool::get(), llvm::Type::getTypeID(), llvm::Type::IntTy, llvm::Type::IntTyID, llvm::Type::LongTy, llvm::Type::LongTyID, llvm::Type::PackedTyID, llvm::Type::PointerTyID, llvm::Type::SByteTy, llvm::Type::SByteTyID, llvm::Type::ShortTy, llvm::Type::ShortTyID, llvm::Type::StructTyID, llvm::Type::UByteTy, llvm::Type::UByteTyID, llvm::Type::UIntTy, llvm::Type::UIntTyID, llvm::Type::ULongTy, llvm::Type::ULongTyID, llvm::Type::UShortTy, and llvm::Type::UShortTyID.
Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldExtractElementInstruction(), llvm::ConstantFoldInsertElementInstruction(), llvm::ConstantFoldInstruction(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::ConvertExpressionToType(), llvm::BinaryOperator::createNeg(), llvm::ExpressionConvertibleToType(), llvm::SCEVUnknown::getIntegerSCEV(), llvm::ConstantExpr::getNeg(), llvm::ConstantExpr::getSignExtend(), llvm::ConstantExpr::getSizeOf(), llvm::RSProfilers_std::IncrementCounterInBlock(), llvm::IncrementCounterInBlock(), llvm::InsertProfilingInitCall(), llvm::BinaryOperator::isNeg(), llvm::DefaultIntrinsicLowering::LowerIntrinsicCall(), llvm::BytecodeReader::ParseCompactionTable(), llvm::RemoveSuccessor(), llvm::SCEVExpander::visitAddRecExpr(), and llvm::ConstantRange::zeroExtend().
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::ConstantIntegral, llvm::ConstantBool, llvm::ConstantInt, llvm::ConstantFP, llvm::ConstantAggregateZero, llvm::ConstantArray, llvm::ConstantStruct, llvm::ConstantPacked, llvm::ConstantPointerNull, llvm::ConstantExpr, llvm::UndefValue, and llvm::GlobalValue.
Referenced by llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInsertElementInstruction(), llvm::AsmPrinter::EmitConstantValueOnly(), llvm::AsmPrinter::EmitGlobalConstant(), evaluateRelation(), getStringValue(), OptimizeConstantExpr(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), llvm::ConstantArray::replaceUsesOfWithOnConstant(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), and ShrinkGlobalToBoolean().
void Constant::print | ( | std::ostream & | O | ) | const [virtual] |
print - Implement operator<< on Value...
Implements llvm::Value.
Reimplemented in llvm::Function, and llvm::GlobalVariable.
Definition at line 1314 of file AsmWriter.cpp.
References llvm::Type::getDescription(), llvm::Value::getType(), and WriteConstantInt().
Constant* llvm::Constant::getOperand | ( | unsigned | i | ) | [inline] |
Reimplemented in llvm::ConstantExpr.
Definition at line 60 of file Constant.h.
References llvm::User::getOperand().
Referenced by CastConstantPacked(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::ConvertConstantType< ConstantPacked, PackedType >::convert(), llvm::ConvertConstantType< ConstantStruct, StructType >::convert(), llvm::ConvertConstantType< ConstantArray, ArrayType >::convert(), llvm::ConvertExpressionToType(), llvm::AsmPrinter::EmitGlobalConstant(), llvm::X86IntelAsmPrinter::EmitString(), llvm::AsmPrinter::EmitString(), evaluateRelation(), EvaluateStoreInto(), EvalVectorOp(), FindScalarElement(), FindStaticTors(), getAggregateConstantElement(), llvm::ConstantArray::getAsString(), getCommonReturnValue(), llvm::DbgStopPointInst::getDirectory(), llvm::DbgStopPointInst::getFileName(), getShuffleMask(), getUIntOperand(), getValType(), llvm::ExecutionEngine::InitializeMemory(), llvm::BinaryOperator::isNeg(), llvm::ConstantArray::isString(), llvm::MapValue(), ParseGlobalCtors(), printAsCString(), RemapOperand(), llvm::GlobalVariable::replaceUsesOfWithOnConstant(), llvm::ConstantPacked::replaceUsesOfWithOnConstant(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), llvm::ConstantArray::replaceUsesOfWithOnConstant(), llvm::ExecutionEngine::runStaticConstructorsDestructors(), and WriteConstantInt().
const Constant* llvm::Constant::getOperand | ( | unsigned | i | ) | const [inline] |
Reimplemented from llvm::User.
Reimplemented in llvm::ConstantExpr.
Definition at line 63 of file Constant.h.
References llvm::User::getOperand().
void llvm::Constant::setOperand | ( | unsigned | i, | |
Constant * | C | |||
) | [inline] |
Definition at line 66 of file Constant.h.
References C, and llvm::User::setOperand().
Referenced by llvm::GlobalVariable::replaceUsesOfWithOnConstant(), llvm::ConstantStruct::replaceUsesOfWithOnConstant(), and llvm::ConstantArray::replaceUsesOfWithOnConstant().
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::ConstantPacked, llvm::ConstantPointerNull, llvm::ConstantExpr, llvm::UndefValue, and llvm::GlobalValue.
Definition at line 77 of file Constant.h.
Referenced by destroyConstantImpl().
static bool llvm::Constant::classof | ( | const Constant * | ) | [inline, static] |
Definition at line 80 of file Constant.h.
static bool llvm::Constant::classof | ( | const GlobalValue * | ) | [inline, static] |
static bool llvm::Constant::classof | ( | const Value * | V | ) | [inline, static] |
Reimplemented from llvm::User.
Reimplemented in llvm::ConstantIntegral, llvm::ConstantBool, llvm::ConstantInt, llvm::ConstantSInt, llvm::ConstantUInt, llvm::ConstantFP, llvm::ConstantAggregateZero, llvm::ConstantArray, llvm::ConstantStruct, llvm::ConstantPacked, llvm::ConstantPointerNull, llvm::ConstantExpr, llvm::UndefValue, llvm::Function, llvm::GlobalValue, and llvm::GlobalVariable.
Definition at line 82 of file Constant.h.
References llvm::Value::ConstantFirstVal, llvm::Value::ConstantLastVal, and V.
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::ConstantPacked, llvm::ConstantExpr, and llvm::GlobalVariable.
Definition at line 97 of file Constant.h.
References llvm::User::getNumOperands().
void Constant::clearAllValueMaps | ( | ) | [static] |
clearAllValueMaps - This method frees all internal memory used by the constant subsystem, which can be used in environments where this memory is otherwise reported as a leak.
Definition at line 1853 of file Constants.cpp.
References AggZeroConstants, ArrayConstants, llvm::ValueMap< ValType, TypeClass, ConstantClass, HasLargeKey >::clear(), DoubleConstants, E, ExprConstants, FloatConstants, NullPtrConstants, PackedConstants, SIntConstants, StructConstants, UIntConstants, and UndefValueConstants.
std::string Constant::getStringValue | ( | bool | Chop = true , |
|
unsigned | Offset = 0 | |||
) |
getStringValue - Turn an LLVM constant pointer that eventually points to a global into a string value. Return an empty string if we can't do it. Parameter Chop determines if the result is chopped at the first null terminator.
Definition at line 1882 of file Constants.cpp.
References C, llvm::ConstantArray::getAsString(), getStringValue(), GV, isNullValue(), and llvm::ConstantArray::isString().
Referenced by llvm::DbgStopPointInst::getDirectory(), llvm::DbgStopPointInst::getFileName(), getStringValue(), and llvm::SelectionDAGLowering::visitMemIntrinsic().