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


Constructor & Destructor Documentation

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

Definition at line 507 of file Constants.h.

References llvm::Value::SubclassData.


Member Function Documentation

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

Reimplemented from llvm::Constant.

Definition at line 624 of file Constants.h.

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

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

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

Definition at line 623 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 1507 of file Constants.cpp.

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

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 1325 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::ConstantFoldInstruction(), getAdd(), getAnd(), getDiv(), getMul(), getNeg(), getNot(), getOr(), getRem(), getSetEQ(), getSetGE(), getSetGT(), getSetLE(), getSetLT(), getSetNE(), getShl(), getShr(), getSub(), getXor(), llvm::MapValue(), llvm::BytecodeReader::ParseConstantPoolValue(), and replaceUsesOfWithOnConstant().

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

Definition at line 424 of file Constants.cpp.

References get().

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

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

Definition at line 439 of file Constants.cpp.

References get().

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

Cast constant expr

Definition at line 1253 of file Constants.cpp.

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

Referenced by DISerializeVisitor::Apply(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInstruction(), 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(), getZeroExtend(), llvm::SCEVExpander::InsertCastOfTo(), LowerCTPOP(), llvm::MapValue(), llvm::BytecodeReader::ParseConstantPoolValue(), llvm::BytecodeReader::ParseInstruction(), PartialFact(), replaceUsesOfWithOnConstant(), llvm::JIT::runFunction(), llvm::ConstantRange::truncate(), and llvm::ConstantRange::zeroExtend().

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

Definition at line 433 of file Constants.cpp.

References get().

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

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

Definition at line 1452 of file Constants.cpp.

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

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

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

Definition at line 1441 of file Constants.cpp.

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

Referenced by getExtractElement().

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

Definition at line 1432 of file Constants.cpp.

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

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

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

Referenced by llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldGetElementPtr(), llvm::ConstantFoldInstruction(), getPtrPtrFromArrayPtr(), getSizeOf(), llvm::RSProfilers_std::IncrementCounterInBlock(), llvm::IncrementCounterInBlock(), llvm::InsertProfilingInitCall(), llvm::MapValue(), llvm::BytecodeReader::ParseConstantPoolValue(), and replaceUsesOfWithOnConstant().

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

Definition at line 1401 of file Constants.cpp.

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

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

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

Definition at line 1473 of file Constants.cpp.

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

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

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

Definition at line 1461 of file Constants.cpp.

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

Referenced by getInsertElement().

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

Definition at line 430 of file Constants.cpp.

References get().

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

References llvm::CallingConv::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 419 of file Constants.cpp.

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

Referenced by llvm::ConstantFoldBinaryInstruction(), and 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 605 of file Constants.h.

References llvm::Value::SubclassData.

Referenced by CleanupConstantGlobalUsers(), 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 1512 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 617 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 614 of file Constants.h.

References llvm::User::getOperand().

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

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

Definition at line 442 of file Constants.cpp.

References get().

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

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

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

Definition at line 436 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 544 of file Constants.h.

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

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

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

Definition at line 1364 of file Constants.cpp.

References llvm::Type::BoolTy, llvm::CallingConv::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::getSetEQ ( Constant C1,
Constant C2 
) [static]

Definition at line 448 of file Constants.cpp.

References get().

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

Definition at line 463 of file Constants.cpp.

References get().

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

Definition at line 457 of file Constants.cpp.

References get().

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

Definition at line 460 of file Constants.cpp.

References get().

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

Definition at line 454 of file Constants.cpp.

References get().

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

Definition at line 451 of file Constants.cpp.

References 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 1382 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::getShl ( Constant C1,
Constant C2 
) [static]

Definition at line 466 of file Constants.cpp.

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

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

Definition at line 469 of file Constants.cpp.

References get().

Referenced by getSShr(), and getUShr().

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

Definition at line 1497 of file Constants.cpp.

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

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

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

Definition at line 1485 of file Constants.cpp.

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

Referenced by getShuffleVector().

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

Definition at line 1265 of file Constants.cpp.

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

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 1289 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::getSShr ( Constant C1,
Constant C2 
) [static]

Definition at line 479 of file Constants.cpp.

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

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

Definition at line 427 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 1304 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::getUShr ( Constant C1,
Constant C2 
) [static]

Definition at line 473 of file Constants.cpp.

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

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

Definition at line 445 of file Constants.cpp.

References get().

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

Definition at line 1280 of file Constants.cpp.

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

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

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 1670 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.


Friends And Related Function Documentation

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

Definition at line 503 of file Constants.h.

friend struct ConvertConstantType< ConstantExpr, Type > [friend]

Definition at line 504 of file Constants.h.


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