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::ConstantExpr Class Reference

#include <Constants.h>

Inheritance diagram for llvm::ConstantExpr:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual bool isNullValue () const
unsigned getOpcode () const
 getOpcode - Return the opcode at the root of this constant expression
const char * getOpcodeName () const
 getOpcodeName - Return a string representation for an opcode.
virtual void destroyConstant ()
virtual void replaceUsesOfWithOnConstant (Value *From, Value *To, bool DisableChecking=false)
ConstantgetOperand (unsigned i)
 Override methods to provide more type information...
ConstantgetOperand (unsigned i) const

Static Public Member Functions

static ConstantgetCast (Constant *C, const Type *Ty)
static ConstantgetSignExtend (Constant *C, const Type *Ty)
static ConstantgetZeroExtend (Constant *C, const Type *Ty)
static ConstantgetSelect (Constant *C, Constant *V1, Constant *V2)
static ConstantgetSizeOf (const Type *Ty)
static Constantget (unsigned Opcode, Constant *C1, Constant *C2)
static ConstantgetNeg (Constant *C)
static ConstantgetNot (Constant *C)
static ConstantgetAdd (Constant *C1, Constant *C2)
static ConstantgetSub (Constant *C1, Constant *C2)
static ConstantgetMul (Constant *C1, Constant *C2)
static ConstantgetDiv (Constant *C1, Constant *C2)
static ConstantgetRem (Constant *C1, Constant *C2)
static ConstantgetAnd (Constant *C1, Constant *C2)
static ConstantgetOr (Constant *C1, Constant *C2)
static ConstantgetXor (Constant *C1, Constant *C2)
static ConstantgetSetEQ (Constant *C1, Constant *C2)
static ConstantgetSetNE (Constant *C1, Constant *C2)
static ConstantgetSetLT (Constant *C1, Constant *C2)
static ConstantgetSetGT (Constant *C1, Constant *C2)
static ConstantgetSetLE (Constant *C1, Constant *C2)
static ConstantgetSetGE (Constant *C1, Constant *C2)
static ConstantgetShl (Constant *C1, Constant *C2)
static ConstantgetShr (Constant *C1, Constant *C2)
static ConstantgetUShr (Constant *C1, Constant *C2)
static ConstantgetSShr (Constant *C1, Constant *C2)
static ConstantgetGetElementPtr (Constant *C, const std::vector< Constant * > &IdxList)
static ConstantgetGetElementPtr (Constant *C, const std::vector< Value * > &IdxList)
static bool classof (const ConstantExpr *)
 Methods for support type inquiry through isa, cast, and dyn_cast:.
static bool classof (const Value *V)

Protected Member Functions

 ConstantExpr (unsigned Opcode, Constant *C, const Type *Ty)
 ConstantExpr (unsigned Opcode, Constant *C1, Constant *C2)
 ConstantExpr (Constant *C, Constant *V1, Constant *V2)
 ConstantExpr (Constant *C, const std::vector< Constant * > &IdxList, const Type *DestTy)

Static Protected Member Functions

static ConstantgetTy (const Type *Ty, unsigned Opcode, Constant *C1, Constant *C2)
static ConstantgetShiftTy (const Type *Ty, unsigned Opcode, Constant *C1, Constant *C2)
 getShiftTy - Return a shift left or shift right constant expr
static ConstantgetSelectTy (const Type *Ty, Constant *C1, Constant *C2, Constant *C3)
static ConstantgetGetElementPtrTy (const Type *Ty, Constant *C, const std::vector< Value * > &IdxList)

Friends

struct ConstantCreator< ConstantExpr, Type,std::pair< unsigned, std::vector< Constant * > > >
struct ConvertConstantType< ConstantExpr, Type >

Detailed Description

ConstantExpr - a constant value that is initialized with an expression using other constant values. This is only used to represent values that cannot be evaluated at compile-time (e.g., something derived from an address) because it does not have a mechanism to store the actual value. Use the appropriate Constant subclass above for known constants.

Definition at line 514 of file Constants.h.


Constructor & Destructor Documentation

ConstantExpr::ConstantExpr unsigned  Opcode,
Constant C,
const Type Ty
[protected]
 

Definition at line 287 of file Constants.cpp.

References llvm::User::Operands.

ConstantExpr::ConstantExpr unsigned  Opcode,
Constant C1,
Constant C2
[protected]
 

Definition at line 309 of file Constants.cpp.

References llvm::User::Operands.

ConstantExpr::ConstantExpr Constant C,
Constant V1,
Constant V2
[protected]
 

Definition at line 294 of file Constants.cpp.

References llvm::User::Operands.

ConstantExpr::ConstantExpr Constant C,
const std::vector< Constant * > &  IdxList,
const Type DestTy
[protected]
 

Definition at line 317 of file Constants.cpp.

References E, and llvm::User::Operands.


Member Function Documentation

static bool llvm::ConstantExpr::classof const Value V  )  [inline, static]
 

Reimplemented from llvm::Constant.

Definition at line 629 of file Constants.h.

References llvm::Value::ConstantExprVal, and llvm::Value::getValueType().

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

Methods for support type inquiry through isa, cast, and dyn_cast:.

Definition at line 628 of file Constants.h.

void ConstantExpr::destroyConstant  )  [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 from llvm::Constant.

Definition at line 1405 of file Constants.cpp.

References llvm::Constant::destroyConstantImpl().

Referenced by llvm::ConvertConstantType< ConstantExpr, Type >::convert(), and replaceUsesOfWithOnConstant().

Constant * ConstantExpr::get unsigned  Opcode,
Constant C1,
Constant C2
[static]
 

ConstantExpr::get - Return a binary or shift operator constant expression, folding if possible.

Definition at line 1287 of file Constants.cpp.

References Add(), llvm::ISD::And, llvm::Type::BoolTy, getTy(), llvm::Value::getType(), llvm::Type::isFloatingPoint(), llvm::Type::isInteger(), llvm::Type::isIntegral(), llvm::Instruction::isRelational(), Mul(), llvm::ISD::Or, llvm::ISD::SetEQ, llvm::ISD::SetGE, llvm::ISD::SetGT, llvm::ISD::SetLE, llvm::ISD::SetLT, llvm::ISD::SetNE, llvm::Instruction::Shl, llvm::Type::UByteTy, and llvm::ISD::Xor.

Referenced by Add(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInstruction(), getAdd(), getAnd(), getDiv(), getMul(), getNeg(), getNot(), getOr(), getRem(), getSetEQ(), getSetGE(), getSetGT(), getSetLE(), getSetLT(), getSetNE(), getShl(), getShr(), getSub(), getXor(), llvm::MapValue(), Mul(), negate(), llvm::BytecodeReader::ParseConstantValue(), RemapOperand(), and replaceUsesOfWithOnConstant().

Constant * ConstantExpr::getAdd Constant C1,
Constant C2
[static]
 

Definition at line 340 of file Constants.cpp.

References Add(), and get().

Referenced by llvm::SCEVAddExpr::get(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), and Next().

Constant * ConstantExpr::getAnd Constant C1,
Constant C2
[static]
 

Definition at line 355 of file Constants.cpp.

References llvm::ISD::And, and get().

Constant * ConstantExpr::getCast Constant C,
const Type Ty
[static]
 

Cast constant expr

Definition at line 1229 of file Constants.cpp.

References llvm::Instruction::Cast, llvm::ConstantFoldCastInstruction(), and llvm::Type::isFirstClassType().

Referenced by Binomial(), llvm::ClassifyExpr(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInstruction(), llvm::ConvertConstantType< ConstantExpr, Type >::convert(), llvm::ConvertExpressionToType(), llvm::SCEVUDivExpr::get(), llvm::SCEVZeroExtendExpr::get(), llvm::SCEVTruncateExpr::get(), llvm::SCEVConstant::get(), llvm::SCEVUnknown::getIntegerSCEV(), getSignExtend(), getSizeOf(), getSShr(), getUShr(), getZeroExtend(), LinkAppendingVars(), LinkGlobals(), llvm::MapValue(), llvm::BytecodeReader::ParseConstantValue(), llvm::BytecodeReader::ParseInstruction(), PartialFact(), RemapOperand(), replaceUsesOfWithOnConstant(), llvm::JIT::runFunction(), llvm::ConstantRange::truncate(), and llvm::ConstantRange::zeroExtend().

Constant * ConstantExpr::getDiv Constant C1,
Constant C2
[static]
 

Definition at line 349 of file Constants.cpp.

References get().

Referenced by llvm::SCEVUDivExpr::get(), and llvm::SCEVAddRecExpr::getNumIterationsInRange().

static Constant* llvm::ConstantExpr::getGetElementPtr Constant C,
const std::vector< Value * > &  IdxList
[static]
 

Constant * ConstantExpr::getGetElementPtr Constant C,
const std::vector< Constant * > &  IdxList
[static]
 

Getelementptr form. std::vector<Value*> is only accepted for convenience: all elements must be Constant's.

Definition at line 1382 of file Constants.cpp.

References llvm::PointerType::get(), getGetElementPtrTy(), llvm::GetElementPtrInst::getIndexedType(), and llvm::Value::getType().

Referenced by llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInstruction(), getSizeOf(), llvm::IncrementCounterInBlock(), llvm::InsertProfilingInitCall(), llvm::MapValue(), llvm::BytecodeReader::ParseConstantValue(), RemapOperand(), and replaceUsesOfWithOnConstant().

Constant * ConstantExpr::getGetElementPtrTy const Type Ty,
Constant C,
const std::vector< Value * > &  IdxList
[static, protected]
 

Definition at line 1362 of file Constants.cpp.

References llvm::ConstantFoldGetElementPtr(), llvm::GetElementPtrInst::getIndexedType(), and llvm::Value::getType().

Referenced by llvm::ConvertConstantType< ConstantExpr, Type >::convert(), and getGetElementPtr().

Constant * ConstantExpr::getMul Constant C1,
Constant C2
[static]
 

Definition at line 346 of file Constants.cpp.

References get(), and Mul().

Referenced by llvm::ConstantFoldGetElementPtr(), and llvm::SCEVMulExpr::get().

Constant * ConstantExpr::getNeg Constant C  )  [static]
 

ConstantExpr::get* - Return some common constants without having to specify the full Instruction::OPCODE identifier.

Definition at line 329 of file Constants.cpp.

References llvm::ConstantFP::get(), get(), llvm::Constant::getNullValue(), llvm::Value::getType(), and llvm::Type::isFloatingPoint().

Referenced by getNegativeSCEV(), and llvm::PatternMatch::neg_match< LHS_t >::match().

Constant * ConstantExpr::getNot Constant C  )  [static]
 

Definition at line 335 of file Constants.cpp.

References get(), llvm::ConstantIntegral::getAllOnesValue(), and llvm::ISD::Xor.

Referenced by llvm::PatternMatch::not_match< LHS_t >::match().

unsigned llvm::ConstantExpr::getOpcode  )  const [inline]
 

getOpcode - Return the opcode at the root of this constant expression

Definition at line 609 of file Constants.h.

Referenced by llvm::ConvertConstantType< ConstantExpr, Type >::convert(), DecomposeConstantExpr(), evaluateRelation(), getOpcodeName(), getValType(), and replaceUsesOfWithOnConstant().

const char * ConstantExpr::getOpcodeName  )  const
 

getOpcodeName - Return a string representation for an opcode.

Definition at line 1410 of file Constants.cpp.

References getOpcode(), and llvm::Instruction::getOpcodeName().

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

Reimplemented from llvm::Constant.

Definition at line 622 of file Constants.h.

References llvm::User::getOperand().

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

Override methods to provide more type information...

Reimplemented from llvm::Constant.

Definition at line 619 of file Constants.h.

References llvm::User::getOperand().

Referenced by llvm::ConvertConstantType< ConstantExpr, Type >::convert(), DecomposeConstantExpr(), evaluateRelation(), GetGEPGlobalInitializer(), getValType(), and replaceUsesOfWithOnConstant().

Constant * ConstantExpr::getOr Constant C1,
Constant C2
[static]
 

Definition at line 358 of file Constants.cpp.

References get(), and llvm::ISD::Or.

Constant * ConstantExpr::getRem Constant C1,
Constant C2
[static]
 

Definition at line 352 of file Constants.cpp.

References get().

static Constant* llvm::ConstantExpr::getSelect Constant C,
Constant V1,
Constant V2
[inline, static]
 

Select constant expr

Definition at line 556 of file Constants.h.

References C, and getSelectTy().

Referenced by llvm::ConstantFoldInstruction(), llvm::MapValue(), llvm::BytecodeReader::ParseConstantValue(), RemapOperand(), and replaceUsesOfWithOnConstant().

Constant * ConstantExpr::getSelectTy const Type Ty,
Constant C1,
Constant C2,
Constant C3
[static, protected]
 

Definition at line 1325 of file Constants.cpp.

References llvm::Type::BoolTy, llvm::ConstantFoldSelectInstruction(), llvm::Value::getType(), llvm::Type::isFirstClassType(), and llvm::Instruction::Select.

Referenced by llvm::ConvertConstantType< ConstantExpr, Type >::convert(), and getSelect().

Constant * ConstantExpr::getSetEQ Constant C1,
Constant C2
[static]
 

Definition at line 364 of file Constants.cpp.

References get(), and llvm::ISD::SetEQ.

Constant * ConstantExpr::getSetGE Constant C1,
Constant C2
[static]
 

Definition at line 379 of file Constants.cpp.

References get(), and llvm::ISD::SetGE.

Constant * ConstantExpr::getSetGT Constant C1,
Constant C2
[static]
 

Definition at line 373 of file Constants.cpp.

References get(), and llvm::ISD::SetGT.

Constant * ConstantExpr::getSetLE Constant C1,
Constant C2
[static]
 

Definition at line 376 of file Constants.cpp.

References get(), and llvm::ISD::SetLE.

Referenced by LTE().

Constant * ConstantExpr::getSetLT Constant C1,
Constant C2
[static]
 

Definition at line 370 of file Constants.cpp.

References get(), and llvm::ISD::SetLT.

Referenced by LT().

Constant * ConstantExpr::getSetNE Constant C1,
Constant C2
[static]
 

Definition at line 367 of file Constants.cpp.

References get(), and llvm::ISD::SetNE.

Constant * ConstantExpr::getShiftTy const Type Ty,
unsigned  Opcode,
Constant C1,
Constant C2
[static, protected]
 

getShiftTy - Return a shift left or shift right constant expr

Definition at line 1343 of file Constants.cpp.

References llvm::ConstantFoldBinaryInstruction(), llvm::Value::getType(), llvm::Type::isIntegral(), llvm::Instruction::Shl, and llvm::Type::UByteTy.

Referenced by llvm::ConvertConstantType< ConstantExpr, Type >::convert(), and getTy().

Constant * ConstantExpr::getShl Constant C1,
Constant C2
[static]
 

Definition at line 382 of file Constants.cpp.

References get(), and llvm::Instruction::Shl.

Constant * ConstantExpr::getShr Constant C1,
Constant C2
[static]
 

Definition at line 385 of file Constants.cpp.

References get().

Referenced by getSShr(), and getUShr().

Constant * ConstantExpr::getSignExtend Constant C,
const Type Ty
[static]
 

Definition at line 1241 of file Constants.cpp.

References getCast(), llvm::Type::getPrimitiveSize(), llvm::Type::getSignedVersion(), llvm::Value::getType(), and llvm::Type::isInteger().

Constant * ConstantExpr::getSizeOf const Type Ty  )  [static]
 

getSizeOf constant expr - computes the size of a type in a target independent way (Note: the return type is UInt but the object is not necessarily a ConstantUInt).

Definition at line 1257 of file Constants.cpp.

References llvm::ConstantInt::get(), llvm::PointerType::get(), getCast(), getGetElementPtr(), llvm::Constant::getNullValue(), and llvm::Type::UIntTy.

Constant * ConstantExpr::getSShr Constant C1,
Constant C2
[static]
 

Definition at line 395 of file Constants.cpp.

References getCast(), getShr(), llvm::Type::getSignedVersion(), llvm::Value::getType(), and llvm::Type::isSigned().

Constant * ConstantExpr::getSub Constant C1,
Constant C2
[static]
 

Definition at line 343 of file Constants.cpp.

References get().

Referenced by llvm::SCEVAddRecExpr::getNumIterationsInRange(), llvm::ConstantRange::getSetSize(), and llvm::ConstantRange::subtract().

Constant * ConstantExpr::getTy const Type Ty,
unsigned  Opcode,
Constant C1,
Constant C2
[static, protected]
 

Definition at line 1266 of file Constants.cpp.

References llvm::Type::BoolTy, llvm::ConstantFoldBinaryInstruction(), getShiftTy(), llvm::Value::getType(), llvm::Instruction::isRelational(), and llvm::Instruction::Shl.

Referenced by llvm::ConvertConstantType< ConstantExpr, Type >::convert(), and get().

Constant * ConstantExpr::getUShr Constant C1,
Constant C2
[static]
 

Definition at line 389 of file Constants.cpp.

References getCast(), getShr(), llvm::Value::getType(), llvm::Type::getUnsignedVersion(), and llvm::Type::isUnsigned().

Constant * ConstantExpr::getXor Constant C1,
Constant C2
[static]
 

Definition at line 361 of file Constants.cpp.

References get(), and llvm::ISD::Xor.

Constant * ConstantExpr::getZeroExtend Constant C,
const Type Ty
[static]
 

Definition at line 1249 of file Constants.cpp.

References getCast(), llvm::Type::getPrimitiveSize(), llvm::Value::getType(), llvm::Type::getUnsignedVersion(), and llvm::Type::isInteger().

virtual bool llvm::ConstantExpr::isNullValue  )  const [inline, virtual]
 

isNullValue - Return true if this is the value that would be returned by getNullValue.

Implements llvm::Constant.

Definition at line 606 of file Constants.h.

void ConstantExpr::replaceUsesOfWithOnConstant Value From,
Value ToV,
bool  DisableChecking = false
[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 from llvm::Constant.

Definition at line 528 of file Constants.cpp.

References llvm::Instruction::Cast, destroyConstant(), get(), getCast(), getGetElementPtr(), llvm::User::getNumOperands(), getOpcode(), getOperand(), getSelect(), llvm::Value::getType(), llvm::Value::replaceAllUsesWith(), llvm::Instruction::Select, and llvm::Value::uncheckedReplaceAllUsesWith().


Friends And Related Function Documentation

friend struct ConstantCreator< ConstantExpr, Type,std::pair< unsigned, std::vector< Constant * > > > [friend]
 

Definition at line 517 of file Constants.h.

friend struct ConvertConstantType< ConstantExpr, Type > [friend]
 

Definition at line 518 of file Constants.h.


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