LLVM API Documentation

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.
ConstantgetWithOperandReplaced (unsigned OpNo, Constant *Op) const
ConstantgetWithOperands (const std::vector< Constant * > &Ops) const
virtual void destroyConstant ()
virtual void replaceUsesOfWithOnConstant (Value *From, Value *To, Use *U)
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 ConstantgetPtrPtrFromArrayPtr (Constant *C)
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 ConstantgetExtractElement (Constant *Vec, Constant *Idx)
static ConstantgetInsertElement (Constant *Vec, Constant *Elt, Constant *Idx)
static ConstantgetShuffleVector (Constant *V1, Constant *V2, Constant *Mask)
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 (const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps)

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)
static ConstantgetExtractElementTy (const Type *Ty, Constant *Val, Constant *Idx)
static ConstantgetInsertElementTy (const Type *Ty, Constant *Val, Constant *Elt, Constant *Idx)
static ConstantgetShuffleVectorTy (const Type *Ty, Constant *V1, Constant *V2, Constant *Mask)

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 class uses the standard Instruction opcodes to define the various constant expressions. The Opcode field for the ConstantExpr class is maintained in the Value::SubclassData field.

Definition at line 508 of file Constants.h.


Constructor & Destructor Documentation

llvm::ConstantExpr::ConstantExpr ( const Type Ty,
unsigned  Opcode,
Use Ops,
unsigned  NumOps 
) [inline, protected]

Definition at line 514 of file Constants.h.

References llvm::Value::SubclassData.


Member Function Documentation

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

Definition at line 1411 of file Constants.cpp.

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

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

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 1489 of file Constants.cpp.

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

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

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

Definition at line 1471 of file Constants.cpp.

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

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

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

Definition at line 1508 of file Constants.cpp.

References C, llvm::ConstantFoldGetElementPtr(), ExprConstants, and llvm::GetElementPtrInst::getIndexedType().

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

Constant * ConstantExpr::getExtractElementTy ( const Type Ty,
Constant Val,
Constant Idx 
) [static, protected]

Definition at line 1548 of file Constants.cpp.

References llvm::ConstantFoldExtractElementInstruction(), ExprConstants, llvm::Instruction::ExtractElement, Idx, and Val.

Referenced by getExtractElement().

Constant * ConstantExpr::getInsertElementTy ( const Type Ty,
Constant Val,
Constant Elt,
Constant Idx 
) [static, protected]

Definition at line 1568 of file Constants.cpp.

References llvm::ConstantFoldInsertElementInstruction(), ExprConstants, Idx, llvm::Instruction::InsertElement, and Val.

Referenced by getInsertElement().

Constant * ConstantExpr::getShuffleVectorTy ( const Type Ty,
Constant V1,
Constant V2,
Constant Mask 
) [static, protected]

Definition at line 1592 of file Constants.cpp.

References llvm::ConstantFoldShuffleVectorInstruction(), ExprConstants, and llvm::Instruction::ShuffleVector.

Referenced by getShuffleVector().

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

Cast constant expr

Definition at line 1360 of file Constants.cpp.

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

Referenced by DISerializeVisitor::Apply(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInstOperands(), llvm::ConvertConstantType< ConstantExpr, Type >::convert(), llvm::ConvertExpressionToType(), llvm::SCEVSDivExpr::get(), llvm::SCEVZeroExtendExpr::get(), llvm::SCEVTruncateExpr::get(), llvm::SCEVConstant::get(), llvm::SCEVUnknown::getIntegerSCEV(), getSignExtend(), getSizeOf(), getSShr(), llvm::DISerializer::getString(), getUShr(), getWithOperandReplaced(), getWithOperands(), getZeroExtend(), llvm::SCEVExpander::InsertCastOfTo(), LowerCTPOP(), llvm::BytecodeReader::ParseConstantPoolValue(), llvm::BytecodeReader::ParseInstruction(), PartialFact(), replaceUsesOfWithOnConstant(), llvm::JIT::runFunction(), llvm::ConstantRange::truncate(), and llvm::ConstantRange::zeroExtend().

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

Definition at line 1372 of file Constants.cpp.

References llvm::Type::BoolTy, C, llvm::ConstantIntegral::getAllOnesValue(), getCast(), llvm::Constant::getNullValue(), llvm::Type::getPrimitiveSize(), llvm::Type::isIntegral(), and llvm::ConstantBool::True.

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

Definition at line 1387 of file Constants.cpp.

References llvm::Type::BoolTy, C, getCast(), llvm::Type::getPrimitiveSize(), and llvm::Type::isIntegral().

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

Select constant expr

Definition at line 551 of file Constants.h.

References C, getSelectTy(), and llvm::Value::getType().

Referenced by llvm::ConstantFoldInstOperands(), getWithOperandReplaced(), getWithOperands(), llvm::BytecodeReader::ParseConstantPoolValue(), and replaceUsesOfWithOnConstant().

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 ULong but the object is not necessarily a ConstantUInt).

Definition at line 1396 of file Constants.cpp.

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

Constant * ConstantExpr::getPtrPtrFromArrayPtr ( Constant C  )  [static]

getPtrPtrFromArrayPtr constant expr - given a pointer to a constant array, return a pointer to a pointer of the array element type.

Definition at line 1404 of file Constants.cpp.

References C, llvm::ConstantUInt::get(), getGetElementPtr(), and llvm::Type::UIntTy.

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 1432 of file Constants.cpp.

References llvm::Type::BoolTy, getTy(), llvm::Value::getType(), llvm::Type::isFloatingPoint(), llvm::Type::isInteger(), llvm::Type::isIntegral(), llvm::Instruction::isRelational(), llvm::Instruction::Shl, and llvm::Type::UByteTy.

Referenced by llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInstOperands(), llvm::ConstantFoldInstruction(), getAdd(), getAnd(), getDiv(), getMul(), getNeg(), getNot(), getOr(), getRem(), getSetEQ(), getSetGE(), getSetGT(), getSetLE(), getSetLT(), getSetNE(), getShl(), getShr(), getSub(), getWithOperandReplaced(), getWithOperands(), getXor(), llvm::BytecodeReader::ParseConstantPoolValue(), and replaceUsesOfWithOnConstant().

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

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

Definition at line 428 of file Constants.cpp.

References C, llvm::ConstantFP::get(), get(), and llvm::Constant::getNullValue().

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

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

Definition at line 434 of file Constants.cpp.

References C, get(), and llvm::ConstantIntegral::getAllOnesValue().

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

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

Definition at line 439 of file Constants.cpp.

References get().

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

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

Definition at line 442 of file Constants.cpp.

References get().

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

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

Definition at line 445 of file Constants.cpp.

References get().

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

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

Definition at line 448 of file Constants.cpp.

References get().

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

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

Definition at line 451 of file Constants.cpp.

References get().

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

Definition at line 454 of file Constants.cpp.

References get().

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

Definition at line 457 of file Constants.cpp.

References get().

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

Definition at line 460 of file Constants.cpp.

References get().

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

Definition at line 463 of file Constants.cpp.

References get().

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

Definition at line 466 of file Constants.cpp.

References get().

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

Definition at line 469 of file Constants.cpp.

References get().

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

Definition at line 472 of file Constants.cpp.

References get().

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

Definition at line 475 of file Constants.cpp.

References get().

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

Definition at line 478 of file Constants.cpp.

References get().

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

Definition at line 481 of file Constants.cpp.

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

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

Definition at line 484 of file Constants.cpp.

References get().

Referenced by getSShr(), and getUShr().

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

Definition at line 488 of file Constants.cpp.

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

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

Definition at line 494 of file Constants.cpp.

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

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 1528 of file Constants.cpp.

References C, llvm::PointerType::get(), getGetElementPtrTy(), llvm::GetElementPtrInst::getIndexedType(), and Ty.

Referenced by llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInstOperands(), getPtrPtrFromArrayPtr(), getSizeOf(), getWithOperandReplaced(), getWithOperands(), llvm::RSProfilers_std::IncrementCounterInBlock(), llvm::IncrementCounterInBlock(), llvm::InsertProfilingInitCall(), llvm::BytecodeReader::ParseConstantPoolValue(), and replaceUsesOfWithOnConstant().

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

Definition at line 1539 of file Constants.cpp.

References C, llvm::PointerType::get(), getGetElementPtrTy(), llvm::GetElementPtrInst::getIndexedType(), and Ty.

Constant * ConstantExpr::getExtractElement ( Constant Vec,
Constant Idx 
) [static]

Definition at line 1559 of file Constants.cpp.

References getExtractElementTy(), llvm::Value::getType(), Idx, llvm::Type::UIntTy, and Val.

Referenced by llvm::ConstantFoldInstOperands(), getWithOperandReplaced(), getWithOperands(), llvm::BytecodeReader::ParseConstantPoolValue(), and replaceUsesOfWithOnConstant().

Constant * ConstantExpr::getInsertElement ( Constant Vec,
Constant Elt,
Constant Idx 
) [static]

Definition at line 1580 of file Constants.cpp.

References getInsertElementTy(), llvm::Value::getType(), Idx, llvm::Type::UIntTy, and Val.

Referenced by llvm::ConstantFoldInstOperands(), getWithOperandReplaced(), getWithOperands(), llvm::BytecodeReader::ParseConstantPoolValue(), and replaceUsesOfWithOnConstant().

Constant * ConstantExpr::getShuffleVector ( Constant V1,
Constant V2,
Constant Mask 
) [static]

Definition at line 1604 of file Constants.cpp.

References getShuffleVectorTy(), and llvm::ShuffleVectorInst::isValidOperands().

Referenced by llvm::ConstantFoldInstOperands(), getWithOperandReplaced(), getWithOperands(), llvm::BytecodeReader::ParseConstantPoolValue(), and replaceUsesOfWithOnConstant().

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 609 of file Constants.h.

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

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

Definition at line 612 of file Constants.h.

References llvm::Value::SubclassData.

Referenced by CleanupConstantGlobalUsers(), llvm::ConvertConstantType< ConstantExpr, Type >::convert(), evaluateRelation(), getOpcodeName(), getValType(), getWithOperandReplaced(), getWithOperands(), OptimizeConstantExpr(), and replaceUsesOfWithOnConstant().

const char * ConstantExpr::getOpcodeName (  )  const

getOpcodeName - Return a string representation for an opcode.

Definition at line 1619 of file Constants.cpp.

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

Constant * ConstantExpr::getWithOperandReplaced ( unsigned  OpNo,
Constant Op 
) const

getWithOperandReplaced - Return a constant expression identical to this one, but with the specified operand set to the specified value.

Definition at line 502 of file Constants.cpp.

References llvm::Instruction::Cast, llvm::Instruction::ExtractElement, get(), getCast(), getExtractElement(), getGetElementPtr(), getInsertElement(), llvm::User::getNumOperands(), getOpcode(), getOperand(), getSelect(), getShuffleVector(), llvm::Value::getType(), llvm::Instruction::InsertElement, Op, Ops, llvm::Instruction::Select, and llvm::Instruction::ShuffleVector.

Constant * ConstantExpr::getWithOperands ( const std::vector< Constant * > &  Ops  )  const

getWithOperands - This returns the current constant expression with the operands replaced with the specified values. The specified operands must match count and type with the existing ones.

Definition at line 554 of file Constants.cpp.

References llvm::Instruction::Cast, llvm::Instruction::ExtractElement, get(), getCast(), getExtractElement(), getGetElementPtr(), getInsertElement(), llvm::User::getNumOperands(), getOpcode(), getOperand(), getSelect(), getShuffleVector(), llvm::Value::getType(), llvm::Instruction::InsertElement, llvm::Instruction::Select, and llvm::Instruction::ShuffleVector.

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 1614 of file Constants.cpp.

References llvm::Constant::destroyConstantImpl(), and ExprConstants.

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

void ConstantExpr::replaceUsesOfWithOnConstant ( Value From,
Value To,
Use U 
) [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 1777 of file Constants.cpp.

References llvm::Instruction::Cast, destroyConstant(), llvm::Instruction::ExtractElement, get(), getCast(), getExtractElement(), getGetElementPtr(), getInsertElement(), llvm::User::getNumOperands(), getOpcode(), getOperand(), getSelect(), getShuffleVector(), llvm::Value::getType(), llvm::Instruction::InsertElement, Replacement, llvm::Instruction::Select, llvm::Instruction::ShuffleVector, llvm::Value::uncheckedReplaceAllUsesWith(), and Val.

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

Override methods to provide more type information...

Reimplemented from llvm::Constant.

Definition at line 630 of file Constants.h.

References llvm::User::getOperand().

Referenced by CommitValueTo(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::ConvertConstantType< ConstantExpr, Type >::convert(), evaluateRelation(), EvaluateStoreInto(), getValType(), getWithOperandReplaced(), getWithOperands(), OptimizeConstantExpr(), and replaceUsesOfWithOnConstant().

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

Reimplemented from llvm::Constant.

Definition at line 633 of file Constants.h.

References llvm::User::getOperand().

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

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

Definition at line 639 of file Constants.h.

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

Reimplemented from llvm::Constant.

Definition at line 640 of file Constants.h.

References llvm::Value::ConstantExprVal, and V.


Friends And Related Function Documentation

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

Definition at line 510 of file Constants.h.

friend struct ConvertConstantType< ConstantExpr, Type > [friend]

Definition at line 511 of file Constants.h.


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