LLVM API Documentation
#include <Constants.h>
Inheritance diagram for llvm::ConstantExpr:
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. | |
Constant * | getWithOperandReplaced (unsigned OpNo, Constant *Op) const |
Constant * | getWithOperands (const std::vector< Constant * > &Ops) const |
virtual void | destroyConstant () |
virtual void | replaceUsesOfWithOnConstant (Value *From, Value *To, Use *U) |
Constant * | getOperand (unsigned i) |
Override methods to provide more type information... | |
Constant * | getOperand (unsigned i) const |
Static Public Member Functions | |
static Constant * | getCast (Constant *C, const Type *Ty) |
static Constant * | getSignExtend (Constant *C, const Type *Ty) |
static Constant * | getZeroExtend (Constant *C, const Type *Ty) |
static Constant * | getSelect (Constant *C, Constant *V1, Constant *V2) |
static Constant * | getSizeOf (const Type *Ty) |
static Constant * | getPtrPtrFromArrayPtr (Constant *C) |
static Constant * | get (unsigned Opcode, Constant *C1, Constant *C2) |
static Constant * | getNeg (Constant *C) |
static Constant * | getNot (Constant *C) |
static Constant * | getAdd (Constant *C1, Constant *C2) |
static Constant * | getSub (Constant *C1, Constant *C2) |
static Constant * | getMul (Constant *C1, Constant *C2) |
static Constant * | getDiv (Constant *C1, Constant *C2) |
static Constant * | getRem (Constant *C1, Constant *C2) |
static Constant * | getAnd (Constant *C1, Constant *C2) |
static Constant * | getOr (Constant *C1, Constant *C2) |
static Constant * | getXor (Constant *C1, Constant *C2) |
static Constant * | getSetEQ (Constant *C1, Constant *C2) |
static Constant * | getSetNE (Constant *C1, Constant *C2) |
static Constant * | getSetLT (Constant *C1, Constant *C2) |
static Constant * | getSetGT (Constant *C1, Constant *C2) |
static Constant * | getSetLE (Constant *C1, Constant *C2) |
static Constant * | getSetGE (Constant *C1, Constant *C2) |
static Constant * | getShl (Constant *C1, Constant *C2) |
static Constant * | getShr (Constant *C1, Constant *C2) |
static Constant * | getUShr (Constant *C1, Constant *C2) |
static Constant * | getSShr (Constant *C1, Constant *C2) |
static Constant * | getGetElementPtr (Constant *C, const std::vector< Constant * > &IdxList) |
static Constant * | getGetElementPtr (Constant *C, const std::vector< Value * > &IdxList) |
static Constant * | getExtractElement (Constant *Vec, Constant *Idx) |
static Constant * | getInsertElement (Constant *Vec, Constant *Elt, Constant *Idx) |
static Constant * | getShuffleVector (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 Constant * | getTy (const Type *Ty, unsigned Opcode, Constant *C1, Constant *C2) |
static Constant * | getShiftTy (const Type *Ty, unsigned Opcode, Constant *C1, Constant *C2) |
getShiftTy - Return a shift left or shift right constant expr | |
static Constant * | getSelectTy (const Type *Ty, Constant *C1, Constant *C2, Constant *C3) |
static Constant * | getGetElementPtrTy (const Type *Ty, Constant *C, const std::vector< Value * > &IdxList) |
static Constant * | getExtractElementTy (const Type *Ty, Constant *Val, Constant *Idx) |
static Constant * | getInsertElementTy (const Type *Ty, Constant *Val, Constant *Elt, Constant *Idx) |
static Constant * | getShuffleVectorTy (const Type *Ty, Constant *V1, Constant *V2, Constant *Mask) |
Friends | |
struct | ConstantCreator< ConstantExpr, Type, std::pair< unsigned, std::vector< Constant * > > > |
struct | ConvertConstantType< ConstantExpr, Type > |
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.
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().
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().
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.
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().
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.
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.
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().
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().
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().
Definition at line 439 of file Constants.cpp.
References get().
Referenced by llvm::SCEVAddExpr::get(), and llvm::SCEVAddRecExpr::getNumIterationsInRange().
Definition at line 442 of file Constants.cpp.
References get().
Referenced by llvm::SCEVAddRecExpr::getNumIterationsInRange(), llvm::ConstantRange::getSetSize(), and llvm::ConstantRange::subtract().
Definition at line 445 of file Constants.cpp.
References get().
Referenced by llvm::ConstantFoldGetElementPtr(), and llvm::SCEVMulExpr::get().
Definition at line 448 of file Constants.cpp.
References get().
Referenced by llvm::SCEVSDivExpr::get(), and llvm::SCEVAddRecExpr::getNumIterationsInRange().
Definition at line 488 of file Constants.cpp.
References getCast(), getShr(), llvm::Value::getType(), and llvm::Type::isUnsigned().
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.
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().
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.
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().
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.
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.