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

 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Constant)
 Transparently provide more efficient getOperand methods.
bool isCast () const
 Return true if this is a convert constant expression.
bool isCompare () const
 Return true if this is a compare constant expression.
bool hasIndices () const
 Return true if this is an insertvalue or extractvalue expression, and the getIndices() method may be used.
virtual bool isNullValue () const
unsigned getOpcode () const
 getOpcode - Return the opcode at the root of this constant expression
unsigned getPredicate () const
const SmallVector< unsigned, 4 > & getIndices () const
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
ConstantgetWithOperands (Constant *const *Ops, unsigned NumOps) const
virtual void destroyConstant ()
virtual void replaceUsesOfWithOnConstant (Value *From, Value *To, Use *U)

Static Public Member Functions

static ConstantgetTrunc (Constant *C, const Type *Ty)
static ConstantgetSExt (Constant *C, const Type *Ty)
static ConstantgetZExt (Constant *C, const Type *Ty)
static ConstantgetFPTrunc (Constant *C, const Type *Ty)
static ConstantgetFPExtend (Constant *C, const Type *Ty)
static ConstantgetUIToFP (Constant *C, const Type *Ty)
static ConstantgetSIToFP (Constant *C, const Type *Ty)
static ConstantgetFPToUI (Constant *C, const Type *Ty)
static ConstantgetFPToSI (Constant *C, const Type *Ty)
static ConstantgetPtrToInt (Constant *C, const Type *Ty)
static ConstantgetIntToPtr (Constant *C, const Type *Ty)
static ConstantgetBitCast (Constant *C, const Type *Ty)
static ConstantgetCast (unsigned ops, Constant *C, const Type *Ty)
static ConstantgetZExtOrBitCast (Constant *C, const Type *Ty)
static ConstantgetSExtOrBitCast (Constant *C, const Type *Ty)
static ConstantgetTruncOrBitCast (Constant *C, const Type *Ty)
static ConstantgetPointerCast (Constant *C, const Type *Ty)
 Create a BitCast or a PtrToInt cast constant expression.
static ConstantgetIntegerCast (Constant *C, const Type *Ty, bool isSigned)
 Create a ZExt, Bitcast or Trunc for integer -> integer casts.
static ConstantgetFPCast (Constant *C, const Type *Ty)
 Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.
static ConstantgetSelect (Constant *C, Constant *V1, Constant *V2)
static ConstantgetSizeOf (const Type *Ty)
static Constantget (unsigned Opcode, Constant *C1, Constant *C2)
static ConstantgetCompare (unsigned short pred, Constant *C1, Constant *C2)
 Return an ICmp, FCmp, VICmp, or VFCmp comparison operator constant expression.
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 ConstantgetUDiv (Constant *C1, Constant *C2)
static ConstantgetSDiv (Constant *C1, Constant *C2)
static ConstantgetFDiv (Constant *C1, Constant *C2)
static ConstantgetURem (Constant *C1, Constant *C2)
static ConstantgetSRem (Constant *C1, Constant *C2)
static ConstantgetFRem (Constant *C1, Constant *C2)
static ConstantgetAnd (Constant *C1, Constant *C2)
static ConstantgetOr (Constant *C1, Constant *C2)
static ConstantgetXor (Constant *C1, Constant *C2)
static ConstantgetICmp (unsigned short pred, Constant *LHS, Constant *RHS)
static ConstantgetFCmp (unsigned short pred, Constant *LHS, Constant *RHS)
static ConstantgetVICmp (unsigned short pred, Constant *LHS, Constant *RHS)
static ConstantgetVFCmp (unsigned short pred, Constant *LHS, Constant *RHS)
static ConstantgetShl (Constant *C1, Constant *C2)
static ConstantgetLShr (Constant *C1, Constant *C2)
static ConstantgetAShr (Constant *C1, Constant *C2)
static ConstantgetGetElementPtr (Constant *C, Constant *const *IdxList, unsigned NumIdx)
static ConstantgetGetElementPtr (Constant *C, Value *const *IdxList, unsigned NumIdx)
static ConstantgetExtractElement (Constant *Vec, Constant *Idx)
static ConstantgetInsertElement (Constant *Vec, Constant *Elt, Constant *Idx)
static ConstantgetShuffleVector (Constant *V1, Constant *V2, Constant *Mask)
static ConstantgetExtractValue (Constant *Agg, const unsigned *IdxList, unsigned NumIdx)
static ConstantgetInsertValue (Constant *Agg, Constant *Val, const unsigned *IdxList, unsigned NumIdx)
static ConstantgetZeroValueForNegationExpr (const Type *Ty)
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 ConstantgetCompareTy (unsigned short pred, Constant *C1, Constant *C2)
static ConstantgetSelectTy (const Type *Ty, Constant *C1, Constant *C2, Constant *C3)
static ConstantgetGetElementPtrTy (const Type *Ty, Constant *C, Value *const *Idxs, unsigned NumIdxs)
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)
static ConstantgetExtractValueTy (const Type *Ty, Constant *Agg, const unsigned *Idxs, unsigned NumIdxs)
static ConstantgetInsertValueTy (const Type *Ty, Constant *Agg, Constant *Val, const unsigned *Idxs, unsigned NumIdxs)

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


Constructor & Destructor Documentation

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

Definition at line 560 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]

Constant * ConstantExpr::getCompareTy ( unsigned short  pred,
Constant C1,
Constant C2 
) [static, protected]

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

Constant * ConstantExpr::getGetElementPtrTy ( const Type Ty,
Constant C,
Value *const *  Idxs,
unsigned  NumIdxs 
) [static, protected]

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

Definition at line 2293 of file Constants.cpp.

References llvm::ConstantFoldExtractElementInstruction().

Referenced by getExtractElement().

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

Definition at line 2313 of file Constants.cpp.

References llvm::ConstantFoldInsertElementInstruction(), and InsertElement.

Referenced by getInsertElement().

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

Definition at line 2336 of file Constants.cpp.

References llvm::ConstantFoldShuffleVectorInstruction().

Referenced by getShuffleVector().

Constant * ConstantExpr::getExtractValueTy ( const Type Ty,
Constant Agg,
const unsigned Idxs,
unsigned  NumIdxs 
) [static, protected]

Constant * ConstantExpr::getInsertValueTy ( const Type Ty,
Constant Agg,
Constant Val,
const unsigned Idxs,
unsigned  NumIdxs 
) [static, protected]

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

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

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

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

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

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

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

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

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

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

Definition at line 1969 of file Constants.cpp.

References getFoldedCast(), llvm::Value::getType(), llvm::Type::isInteger(), and PtrToInt.

Referenced by getCast().

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

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

llvm::ConstantExpr::DECLARE_TRANSPARENT_OPERAND_ACCESSORS ( Constant   ) 

Transparently provide more efficient getOperand methods.

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

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

Parameters:
C  The constant to zext or bitcast
Ty  The type to zext or bitcast C to

Definition at line 1833 of file Constants.cpp.

References BitCast, getCast(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), and ZExt.

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

Parameters:
C  The constant to sext or bitcast
Ty  The type to sext or bitcast C to

Definition at line 1839 of file Constants.cpp.

References BitCast, getCast(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), and llvm::Attribute::SExt.

Referenced by llvm::ConstantFoldGetElementPtr().

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

Parameters:
C  The constant to trunc or bitcast
Ty  The type to trunc or bitcast C to

Definition at line 1845 of file Constants.cpp.

References BitCast, getCast(), llvm::Type::getPrimitiveSizeInBits(), and llvm::Value::getType().

Referenced by llvm::TargetFolder::CreateTruncOrBitCast(), and llvm::ConstantFolder::CreateTruncOrBitCast().

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

Create a BitCast or a PtrToInt cast constant expression.

Parameters:
C  The pointer value to be casted (operand 0)
Ty  The type to which cast should be made

Definition at line 1851 of file Constants.cpp.

References BitCast, getCast(), llvm::Value::getType(), llvm::Type::isInteger(), and PtrToInt.

Referenced by llvm::ConstantFoldCastInstruction().

Constant * ConstantExpr::getIntegerCast ( Constant C,
const Type Ty,
bool  isSigned 
) [static]

Create a ZExt, Bitcast or Trunc for integer -> integer casts.

Parameters:
C  The integer constant to be casted
Ty  The integer type to cast to
isSigned  Whether C should be treated as signed or not

Definition at line 1860 of file Constants.cpp.

References BitCast, getCast(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Type::isInteger(), opcode, llvm::Attribute::SExt, and ZExt.

Referenced by llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldInstOperands(), llvm::TargetFolder::CreateIntCast(), llvm::ConstantFolder::CreateIntCast(), and llvm::AsmPrinter::EmitConstantValueOnly().

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

Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.

Parameters:
C  The integer constant to be casted
Ty  The integer type to cast to

Definition at line 1872 of file Constants.cpp.

References FPTrunc, getCast(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Type::isFloatingPoint(), and opcode.

bool ConstantExpr::isCast (  )  const

Return true if this is a convert constant expression.

Definition at line 729 of file Constants.cpp.

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

Referenced by FindStaticTors(), foldConstantCastPair(), and replaceUsesOfWithOnConstant().

bool ConstantExpr::isCompare (  )  const

Return true if this is a compare constant expression.

Definition at line 733 of file Constants.cpp.

References FCmp, getOpcode(), and VICmp.

Referenced by llvm::ConstantFoldConstantExpression(), getValType(), and replaceUsesOfWithOnConstant().

bool ConstantExpr::hasIndices (  )  const

Return true if this is an insertvalue or extractvalue expression, and the getIndices() method may be used.

Definition at line 738 of file Constants.cpp.

References ExtractValue, and getOpcode().

Referenced by getValType().

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

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 an i64).

Definition at line 1999 of file Constants.cpp.

References llvm::ConstantInt::get(), getCast(), getGetElementPtr(), llvm::Constant::getNullValue(), llvm::PointerType::getUnqual(), llvm::Type::Int32Ty, llvm::Type::Int64Ty, and PtrToInt.

Referenced by llvm::InlineFunction().

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

Constant * ConstantExpr::getCompare ( unsigned short  pred,
Constant C1,
Constant C2 
) [static]

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

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

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

Definition at line 754 of file Constants.cpp.

References llvm::Value::getType(), and getZeroValueForNegationExpr().

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

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

Constant * ConstantExpr::getAdd ( Constant