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. | |
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 501 of file Constants.h.
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().
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().
Definition at line 424 of file Constants.cpp.
References get().
Referenced by llvm::SCEVAddExpr::get(), and llvm::SCEVAddRecExpr::getNumIterationsInRange().
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().
Definition at line 433 of file Constants.cpp.
References get().
Referenced by llvm::SCEVSDivExpr::get(), and llvm::SCEVAddRecExpr::getNumIterationsInRange().
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().
Definition at line 430 of file Constants.cpp.
References get().
Referenced by llvm::ConstantFoldGetElementPtr(), and llvm::SCEVMulExpr::get().
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().
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().
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.
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::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::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().
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.
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.
Definition at line 479 of file Constants.cpp.
References getCast(), getShr(), llvm::Value::getType(), and llvm::Type::isSigned().
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().
Definition at line 473 of file Constants.cpp.
References getCast(), getShr(), llvm::Value::getType(), and llvm::Type::isUnsigned().
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.
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.
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.