LLVM API Documentation
Base class of casting instructions. More...
#include <InstrTypes.h>
Public Member Functions | |
bool | isIntegerCast () const |
Determine if this is an integer-only cast. More... | |
bool | isLosslessCast () const |
Determine if this is a lossless cast. More... | |
bool | isNoopCast (Type *IntPtrTy) const |
Determine if this cast is a no-op cast. More... | |
Instruction::CastOps | getOpcode () const |
Return the opcode of this CastInst. More... | |
Type * | getSrcTy () const |
Return the source type, as a convenience. More... | |
Type * | getDestTy () const |
Return the destination type, as a convenience. More... | |
![]() | |
void * | operator new (size_t s) |
~UnaryInstruction () | |
DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value) | |
Transparently provide more efficient getOperand methods. More... | |
![]() | |
~Instruction () | |
Instruction * | use_back () |
const Instruction * | use_back () const |
const BasicBlock * | getParent () const |
BasicBlock * | getParent () |
void | removeFromParent () |
void | eraseFromParent () |
void | insertBefore (Instruction *InsertPos) |
void | insertAfter (Instruction *InsertPos) |
void | moveBefore (Instruction *MovePos) |
unsigned | getOpcode () const |
getOpcode() returns a member of one of the enums like Instruction::Add. More... | |
const char * | getOpcodeName () const |
bool | isTerminator () const |
bool | isBinaryOp () const |
bool | isShift () |
bool | isCast () const |
bool | isLogicalShift () const |
bool | isArithmeticShift () const |
isArithmeticShift - Return true if this is an arithmetic shift right. More... | |
bool | hasMetadata () const |
bool | hasMetadataOtherThanDebugLoc () const |
MDNode * | getMetadata (unsigned KindID) const |
MDNode * | getMetadata (StringRef Kind) const |
void | getAllMetadata (SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const |
void | getAllMetadataOtherThanDebugLoc (SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const |
void | setMetadata (unsigned KindID, MDNode *Node) |
void | setMetadata (StringRef Kind, MDNode *Node) |
void | setDebugLoc (const DebugLoc &Loc) |
setDebugLoc - Set the debug location information for this instruction. More... | |
const DebugLoc & | getDebugLoc () const |
getDebugLoc - Return the debug location for this node as a DebugLoc. More... | |
void | setHasUnsafeAlgebra (bool B) |
void | setHasNoNaNs (bool B) |
void | setHasNoInfs (bool B) |
void | setHasNoSignedZeros (bool B) |
void | setHasAllowReciprocal (bool B) |
void | setFastMathFlags (FastMathFlags FMF) |
bool | hasUnsafeAlgebra () const |
Determine whether the unsafe-algebra flag is set. More... | |
bool | hasNoNaNs () const |
Determine whether the no-NaNs flag is set. More... | |
bool | hasNoInfs () const |
Determine whether the no-infs flag is set. More... | |
bool | hasNoSignedZeros () const |
Determine whether the no-signed-zeros flag is set. More... | |
bool | hasAllowReciprocal () const |
Determine whether the allow-reciprocal flag is set. More... | |
FastMathFlags | getFastMathFlags () const |
void | copyFastMathFlags (const Instruction *I) |
Copy I's fast-math flags. More... | |
bool | isAssociative () const |
bool | isCommutative () const |
bool | isIdempotent () const |
bool | isNilpotent () const |
bool | mayWriteToMemory () const |
bool | mayReadFromMemory () const |
bool | mayReadOrWriteMemory () const |
bool | mayThrow () const |
bool | mayReturn () const |
bool | mayHaveSideEffects () const |
Instruction * | clone () const |
bool | isIdenticalTo (const Instruction *I) const |
bool | isIdenticalToWhenDefined (const Instruction *I) const |
bool | isSameOperationAs (const Instruction *I, unsigned flags=0) const |
Determine if one instruction is the same operation as another. More... | |
bool | isUsedOutsideOfBlock (const BasicBlock *BB) const |
![]() | |
~User () | |
void | operator delete (void *Usr) |
operator delete - free memory allocated for User and Use objects More... | |
void | operator delete (void *, unsigned) |
placement delete - required by std, but never called. More... | |
void | operator delete (void *, unsigned, bool) |
placement delete - required by std, but never called. More... | |
Value * | getOperand (unsigned i) const |
void | setOperand (unsigned i, Value *Val) |
const Use & | getOperandUse (unsigned i) const |
Use & | getOperandUse (unsigned i) |
unsigned | getNumOperands () const |
op_iterator | op_begin () |
const_op_iterator | op_begin () const |
op_iterator | op_end () |
const_op_iterator | op_end () const |
value_op_iterator | value_op_begin () |
value_op_iterator | value_op_end () |
void | dropAllReferences () |
void | replaceUsesOfWith (Value *From, Value *To) |
![]() | |
virtual | ~Value () |
void | dump () const |
dump - Support for debugging, callable in GDB: V->dump() More... | |
void | print (raw_ostream &O, AssemblyAnnotationWriter *AAW=0) const |
Type * | getType () const |
LLVMContext & | getContext () const |
All values hold a context through their type. More... | |
bool | hasName () const |
ValueName * | getValueName () const |
void | setValueName (ValueName *VN) |
StringRef | getName () const |
void | setName (const Twine &Name) |
void | takeName (Value *V) |
void | replaceAllUsesWith (Value *V) |
bool | use_empty () const |
use_iterator | use_begin () |
const_use_iterator | use_begin () const |
use_iterator | use_end () |
const_use_iterator | use_end () const |
User * | use_back () |
const User * | use_back () const |
bool | hasOneUse () const |
bool | hasNUses (unsigned N) const |
bool | hasNUsesOrMore (unsigned N) const |
bool | isUsedInBasicBlock (const BasicBlock *BB) const |
unsigned | getNumUses () const |
void | addUse (Use &U) |
unsigned | getValueID () const |
unsigned | getRawSubclassOptionalData () const |
void | clearSubclassOptionalData () |
bool | hasSameSubclassOptionalData (const Value *V) const |
void | intersectOptionalDataWith (const Value *V) |
bool | hasValueHandle () const |
Value * | stripPointerCasts () |
Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value, returning the original uncasted value. More... | |
const Value * | stripPointerCasts () const |
Value * | stripPointerCastsNoFollowAliases () |
Strips off any unneeded pointer casts and all-zero GEPs from the specified value, returning the original uncasted value. More... | |
const Value * | stripPointerCastsNoFollowAliases () const |
Value * | stripInBoundsConstantOffsets () |
Strips off unneeded pointer casts and all-constant GEPs from the specified value, returning the original pointer value. More... | |
const Value * | stripInBoundsConstantOffsets () const |
Value * | stripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) |
Strips like stripInBoundsConstantOffsets but also accumulates the constant offset stripped. More... | |
const Value * | stripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const |
Value * | stripInBoundsOffsets () |
Strips off unneeded pointer casts and any in-bounds offsets from the specified value, returning the original pointer value. More... | |
const Value * | stripInBoundsOffsets () const |
bool | isDereferenceablePointer () const |
Value * | DoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) |
const Value * | DoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const |
void | mutateType (Type *Ty) |
![]() | |
Instruction * | getPrevNode () |
Get the previous node, or 0 for the list head. More... | |
const Instruction * | getPrevNode () const |
Get the previous node, or 0 for the list head. More... | |
Instruction * | getNextNode () |
Get the next node, or 0 for the list tail. More... | |
const Instruction * | getNextNode () const |
Get the next node, or 0 for the list tail. More... | |
Static Public Member Functions | |
static CastInst * | Create (Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0) |
Construct any of the CastInst subclasses. More... | |
static CastInst * | Create (Instruction::CastOps, Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd) |
Construct any of the CastInst subclasses. More... | |
static CastInst * | CreateZExtOrBitCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0) |
Create a ZExt or BitCast cast instruction. More... | |
static CastInst * | CreateZExtOrBitCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd) |
Create a ZExt or BitCast cast instruction. More... | |
static CastInst * | CreateSExtOrBitCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0) |
Create a SExt or BitCast cast instruction. More... | |
static CastInst * | CreateSExtOrBitCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd) |
Create a SExt or BitCast cast instruction. More... | |
static CastInst * | CreatePointerCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd) |
Create a BitCast or a PtrToInt cast instruction. More... | |
static CastInst * | CreatePointerCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0) |
Create a BitCast or a PtrToInt cast instruction. More... | |
static CastInst * | CreateIntegerCast (Value *S, Type *Ty, bool isSigned, const Twine &Name="", Instruction *InsertBefore=0) |
Create a ZExt, BitCast, or Trunc for int -> int casts. More... | |
static CastInst * | CreateIntegerCast (Value *S, Type *Ty, bool isSigned, const Twine &Name, BasicBlock *InsertAtEnd) |
Create a ZExt, BitCast, or Trunc for int -> int casts. More... | |
static CastInst * | CreateFPCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0) |
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts. More... | |
static CastInst * | CreateFPCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd) |
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts. More... | |
static CastInst * | CreateTruncOrBitCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0) |
Create a Trunc or BitCast cast instruction. More... | |
static CastInst * | CreateTruncOrBitCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd) |
Create a Trunc or BitCast cast instruction. More... | |
static bool | isCastable (Type *SrcTy, Type *DestTy) |
Check whether it is valid to call getCastOpcode for these types. More... | |
static bool | isBitCastable (Type *SrcTy, Type *DestTy) |
Check whether a bitcast between these types is valid. More... | |
static Instruction::CastOps | getCastOpcode (const Value *Val, bool SrcIsSigned, Type *Ty, bool DstIsSigned) |
Infer the opcode for cast operand and type. More... | |
static bool | isNoopCast (Instruction::CastOps Opcode, Type *SrcTy, Type *DstTy, Type *IntPtrTy) |
Determine if the described cast is a no-op cast. More... | |
static unsigned | isEliminableCastPair (Instruction::CastOps firstOpcode, Instruction::CastOps secondOpcode, Type *SrcTy, Type *MidTy, Type *DstTy, Type *SrcIntPtrTy, Type *MidIntPtrTy, Type *DstIntPtrTy) |
Determine if a cast pair is eliminable. More... | |
static bool | castIsValid (Instruction::CastOps op, Value *S, Type *DstTy) |
Determine if a cast is valid without creating one. More... | |
static bool | classof (const Instruction *I) |
Methods for support type inquiry through isa, cast, and dyn_cast: More... | |
static bool | classof (const Value *V) |
![]() | |
static bool | classof (const Instruction *I) |
static bool | classof (const Value *V) |
![]() | |
static const char * | getOpcodeName (unsigned OpCode) |
static bool | isTerminator (unsigned OpCode) |
static bool | isBinaryOp (unsigned Opcode) |
static bool | isShift (unsigned Opcode) |
Determine if the Opcode is one of the shift instructions. More... | |
static bool | isCast (unsigned OpCode) |
Determine if the OpCode is one of the CastInst instructions. More... | |
static bool | isAssociative (unsigned op) |
static bool | isCommutative (unsigned op) |
static bool | isIdempotent (unsigned op) |
static bool | isNilpotent (unsigned op) |
static bool | classof (const Value *V) |
Methods for support type inquiry through isa, cast, and dyn_cast: More... | |
![]() | |
static bool | classof (const Value *V) |
Protected Member Functions | |
CastInst (Type *Ty, unsigned iType, Value *S, const Twine &NameStr="", Instruction *InsertBefore=0) | |
Constructor with insert-before-instruction semantics for subclasses. More... | |
CastInst (Type *Ty, unsigned iType, Value *S, const Twine &NameStr, BasicBlock *InsertAtEnd) | |
Constructor with insert-at-end-of-block semantics for subclasses. More... | |
![]() | |
UnaryInstruction (Type *Ty, unsigned iType, Value *V, Instruction *IB=0) | |
UnaryInstruction (Type *Ty, unsigned iType, Value *V, BasicBlock *IAE) | |
![]() | |
void | setInstructionSubclassData (unsigned short D) |
unsigned | getSubclassDataFromInstruction () const |
Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, Instruction *InsertBefore=0) | |
Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd) | |
virtual Instruction * | clone_impl () const =0 |
![]() | |
void * | operator new (size_t s, unsigned Us) |
User (Type *ty, unsigned vty, Use *OpList, unsigned NumOps) | |
Use * | allocHungoffUses (unsigned) const |
void | dropHungoffUses () |
template<int Idx> | |
Use & | Op () |
template<int Idx> | |
const Use & | Op () const |
![]() | |
virtual void | printCustom (raw_ostream &O) const |
Value (Type *Ty, unsigned scid) | |
unsigned short | getSubclassDataFromValue () const |
void | setValueSubclassData (unsigned short D) |
![]() | |
ilist_node () | |
Base class of casting instructions.
CastInst - This is the base class for all instructions that perform data casts. It is simply provided so that instruction category testing can be performed with code like:
if (isa<CastInst>(Instr)) { ... }
Definition at line 387 of file InstrTypes.h.
|
inlineprotected |
Constructor with insert-before-instruction semantics for subclasses.
Definition at line 391 of file InstrTypes.h.
|
inlineprotected |
Constructor with insert-at-end-of-block semantics for subclasses.
Definition at line 397 of file InstrTypes.h.
|
static |
Determine if a cast is valid without creating one.
This method can be used to determine if a cast from S to DstTy using Opcode op is valid or not.
Check that the construction parameters for a CastInst are correct. This could be broken out into the separate constructors but it is useful to have it in one place and to eliminate the redundant code for getting the sizes of the types involved.
Definition at line 2753 of file Instructions.cpp.
References llvm::Type::getPointerAddressSpace(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Type::isAggregateType(), llvm::Type::isFirstClassType(), llvm::Type::isFPOrFPVectorTy(), llvm::Type::isIntegerTy(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPointerTy(), llvm::Type::isPtrOrPtrVectorTy(), and llvm::Type::isVectorTy().
Referenced by llvm::AddrSpaceCastInst::AddrSpaceCastInst(), llvm::BitCastInst::BitCastInst(), Create(), llvm::FPExtInst::FPExtInst(), llvm::FPToSIInst::FPToSIInst(), llvm::FPToUIInst::FPToUIInst(), llvm::FPTruncInst::FPTruncInst(), llvm::ConstantExpr::getAddrSpaceCast(), llvm::ConstantExpr::getBitCast(), llvm::ConstantExpr::getCast(), llvm::IntToPtrInst::IntToPtrInst(), llvm::PtrToIntInst::PtrToIntInst(), llvm::SExtInst::SExtInst(), llvm::SIToFPInst::SIToFPInst(), llvm::TruncInst::TruncInst(), llvm::UIToFPInst::UIToFPInst(), and llvm::ZExtInst::ZExtInst().
|
inlinestatic |
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition at line 619 of file InstrTypes.h.
References llvm::Instruction::isCast().
Definition at line 622 of file InstrTypes.h.
|
static |
Construct any of the CastInst subclasses.
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's constructor. The opcode must be in the CastOps category (Instruction::isCast(opcode) returns true). This constructor has insert-before-instruction semantics to automatically insert the new CastInst before InsertBefore (if it is non-null).
op | The opcode of the cast instruction |
S | The value to be casted (operand 0) |
Ty | The type to which cast should be made |
Name | Name for the instruction |
InsertBefore | Place to insert the instruction |
Definition at line 2350 of file Instructions.cpp.
References castIsValid(), and llvm_unreachable.
Referenced by BuildNew(), llvm::InstCombiner::commonCastTransforms(), llvm::NoFolder::CreateCast(), llvm::IRBuilder< true, TargetFolder >::CreateCast(), CreateFPCast(), CreateIntegerCast(), CreatePointerCast(), CreateSExtOrBitCast(), CreateTruncOrBitCast(), CreateZExtOrBitCast(), llvm::InstCombiner::FoldSelectOpOp(), llvm::ConstantExpr::getAsInstruction(), OptimizeNoopCopyExpression(), llvm::UpgradeBitCastInst(), llvm::InstCombiner::visitAnd(), llvm::InstCombiner::visitBitCast(), llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitExtractElementInst(), llvm::InstCombiner::visitGetElementPtrInst(), llvm::InstCombiner::visitOr(), and llvm::InstCombiner::visitXor().
|
static |
Construct any of the CastInst subclasses.
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's constructor. The opcode must be in the CastOps category. This constructor has insert-at-end-of-block semantics to automatically insert the new CastInst at the end of InsertAtEnd (if its non-null).
op | The opcode for the cast instruction |
S | The value to be casted (operand 0) |
Ty | The type to which operand is casted |
Name | The name for the instruction |
InsertAtEnd | The block to insert the instruction into |
Definition at line 2372 of file Instructions.cpp.
References castIsValid(), and llvm_unreachable.
|
static |
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
S | The floating point value to be casted |
Ty | The floating point type to cast to |
Name | Name for the instruction |
InsertBefore | Place to insert the instruction |
Definition at line 2513 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), and llvm::Type::isFPOrFPVectorTy().
Referenced by llvm::NoFolder::CreateFPCast(), and llvm::IRBuilder< true, TargetFolder >::CreateFPCast().
|
static |
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
S | The floating point value to be casted |
Ty | The floating point type to cast to |
Name | The name for the instruction |
InsertAtEnd | The block to insert the instruction into |
Definition at line 2526 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), and llvm::Type::isFPOrFPVectorTy().
|
static |
Create a ZExt, BitCast, or Trunc for int -> int casts.
S | The pointer value to be casted (operand 0) |
Ty | The type to which cast should be made |
isSigned | Whether to regard S as signed or not |
Name | Name for the instruction |
InsertBefore | Place to insert the instruction |
Definition at line 2485 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), and llvm::Type::isIntOrIntVectorTy().
Referenced by llvm::NoFolder::CreateIntCast(), llvm::IRBuilder< true, TargetFolder >::CreateIntCast(), createMalloc(), llvm::InstCombiner::visitPtrToInt(), and llvm::InstCombiner::visitTrunc().
|
static |
Create a ZExt, BitCast, or Trunc for int -> int casts.
S | The integer value to be casted (operand 0) |
Ty | The integer type to which operand is casted |
isSigned | Whether to regard S as signed or not |
Name | The name for the instruction |
InsertAtEnd | The block to insert the instruction into |
Definition at line 2499 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), and llvm::Type::isIntOrIntVectorTy().
|
static |
Create a BitCast or a PtrToInt cast instruction.
S | The pointer value to be casted (operand 0) |
Ty | The type to which operand is casted |
Name | The name for the instruction |
InsertAtEnd | The block to insert the instruction into |
Definition at line 2442 of file Instructions.cpp.
References Create(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPtrOrPtrVectorTy(), and llvm::Type::isVectorTy().
Referenced by llvm::NoFolder::CreatePointerCast(), and llvm::IRBuilder< true, TargetFolder >::CreatePointerCast().
|
static |
Create a BitCast or a PtrToInt cast instruction.
S | The pointer value to be casted (operand 0) |
Ty | The type to which cast should be made |
Name | Name for the instruction |
InsertBefore | Place to insert the instruction |
Definition at line 2464 of file Instructions.cpp.
References Create(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPtrOrPtrVectorTy(), and llvm::Type::isVectorTy().
|
static |
Create a SExt or BitCast cast instruction.
S | The value to be casted (operand 0) |
Ty | The type to which cast should be made |
Name | Name for the instruction |
InsertBefore | Place to insert the instruction |
Definition at line 2410 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().
Referenced by llvm::NoFolder::CreateSExtOrBitCast(), llvm::IRBuilder< true, TargetFolder >::CreateSExtOrBitCast(), llvm::InstCombiner::visitCallInst(), and llvm::InstCombiner::visitSub().
|
static |
Create a SExt or BitCast cast instruction.
S | The value to be casted (operand 0) |
Ty | The type to which operand is casted |
Name | The name for the instruction |
InsertAtEnd | The block to insert the instruction into |
Definition at line 2418 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().
|
static |
Create a Trunc or BitCast cast instruction.
S | The value to be casted (operand 0) |
Ty | The type to which cast should be made |
Name | Name for the instruction |
InsertBefore | Place to insert the instruction |
Definition at line 2426 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().
Referenced by llvm::NoFolder::CreateTruncOrBitCast(), and llvm::IRBuilder< true, TargetFolder >::CreateTruncOrBitCast().
|
static |
Create a Trunc or BitCast cast instruction.
S | The value to be casted (operand 0) |
Ty | The type to which operand is casted |
Name | The name for the instruction |
InsertAtEnd | The block to insert the instruction into |
Definition at line 2434 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().
|
static |
Create a ZExt or BitCast cast instruction.
S | The value to be casted (operand 0) |
Ty | The type to which cast should be made |
Name | Name for the instruction |
InsertBefore | Place to insert the instruction |
Definition at line 2394 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().
Referenced by llvm::NoFolder::CreateZExtOrBitCast(), llvm::IRBuilder< true, TargetFolder >::CreateZExtOrBitCast(), llvm::InstCombiner::visitCallInst(), and llvm::InstCombiner::visitSub().
|
static |
Create a ZExt or BitCast cast instruction.
S | The value to be casted (operand 0) |
Ty | The type to which operand is casted |
Name | The name for the instruction |
InsertAtEnd | The block to insert the instruction into |
Definition at line 2402 of file Instructions.cpp.
References Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().
|
static |
Infer the opcode for cast operand and type.
Returns the opcode necessary to cast Val into Ty using usual casting rules.
Val | The value to cast |
SrcIsSigned | Whether to treat the source as signed |
Ty | The Type to which the value should be casted |
DstIsSigned | Whether to treate the dest. as signed |
Definition at line 2650 of file Instructions.cpp.
References llvm::Type::getPointerAddressSpace(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::Type::isFirstClassType(), llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::Type::isVectorTy(), llvm::Type::isX86_MMXTy(), and llvm_unreachable.
Referenced by CastGEPIndices(), llvm::ConstantFoldCastInstruction(), getFoldedAlignOf(), getFoldedOffsetOf(), and getFoldedSizeOf().
|
inline |
Return the destination type, as a convenience.
Definition at line 610 of file InstrTypes.h.
References llvm::Intrinsic::getType().
|
inline |
Return the opcode of this CastInst.
Definition at line 603 of file InstrTypes.h.
References llvm::Instruction::getOpcode().
Referenced by llvm::AddrSpaceCastInst::AddrSpaceCastInst(), llvm::BitCastInst::BitCastInst(), llvm::InstCombiner::commonCastTransforms(), llvm::FPExtInst::FPExtInst(), llvm::FPToSIInst::FPToSIInst(), llvm::FPToUIInst::FPToUIInst(), llvm::FPTruncInst::FPTruncInst(), llvm::IntToPtrInst::IntToPtrInst(), isEliminableCastPair(), isIntegerCast(), isLosslessCast(), isNoopCast(), OptimizeNoopCopyExpression(), llvm::PtrToIntInst::PtrToIntInst(), llvm::SExtInst::SExtInst(), llvm::SIToFPInst::SIToFPInst(), llvm::TruncInst::TruncInst(), llvm::UIToFPInst::UIToFPInst(), llvm::InstCombiner::visitFPTrunc(), llvm::InstCombiner::visitICmpInstWithCastAndCast(), llvm::InstCombiner::visitOr(), and llvm::ZExtInst::ZExtInst().
|
inline |
Return the source type, as a convenience.
Definition at line 608 of file InstrTypes.h.
Referenced by llvm::InstCombiner::visitFCmpInst().
Check whether a bitcast between these types is valid.
SrcTy | The Type from which the value should be cast. |
DestTy | The Type to which the value should be cast. |
Definition at line 2602 of file Instructions.cpp.
References llvm::Type::getPrimitiveSizeInBits(), llvm::Type::isFirstClassType(), and llvm::Type::isX86_MMXTy().
Check whether it is valid to call getCastOpcode for these types.
SrcTy | The Type from which the value should be cast. |
DestTy | The Type to which the value should be cast. |
Definition at line 2541 of file Instructions.cpp.
References llvm::Type::getPrimitiveSizeInBits(), llvm::Type::isFirstClassType(), llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::Type::isVectorTy(), and llvm::Type::isX86_MMXTy().
|
static |
Determine if a cast pair is eliminable.
Determine how a pair of casts can be eliminated, if they can be at all. This is a helper function for both CastInst and ConstantExpr.
This function determines if a pair of casts can be eliminated and what opcode should be used in the elimination. This assumes that there are two instructions like this:
firstOp | Opcode of first cast |
secondOp | Opcode of second cast |
SrcTy | SrcTy of 1st cast |
MidTy | DstTy of 1st cast & SrcTy of 2nd cast |
DstTy | DstTy of 2nd cast |
SrcIntPtrTy | Integer type corresponding to Ptr SrcTy, or null |
MidIntPtrTy | Integer type corresponding to Ptr MidTy, or null |
DstIntPtrTy | Integer type corresponding to Ptr DstTy, or null |
Definition at line 2125 of file Instructions.cpp.
References llvm::Type::getPointerAddressSpace(), llvm::Type::getScalarSizeInBits(), llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPtrOrPtrVectorTy(), llvm::Type::isVectorTy(), and llvm_unreachable.
Referenced by foldConstantCastPair(), and isEliminableCastPair().
bool CastInst::isIntegerCast | ( | ) | const |
Determine if this is an integer-only cast.
There are several places where we need to know if a cast instruction only deals with integer source and destination types. To simplify that logic, this method is provided.
Definition at line 2045 of file Instructions.cpp.
References getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), and llvm::Type::isIntegerTy().
bool CastInst::isLosslessCast | ( | ) | const |
Determine if this is a lossless cast.
A lossless cast is one that does not alter the basic value. It implies a no-op cast but is more stringent, preventing things like int->float, long->double, or int->ptr.
Definition at line 2058 of file Instructions.cpp.
References getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), and llvm::Type::isPointerTy().
Referenced by isSafeToEliminateVarargsCast().
|
static |
Determine if the described cast is a no-op cast.
Determine if the described cast is a no-op.
A no-op cast is one that can be effected without changing any bits. It implies that the source and destination types are the same size. The IntPtrTy argument is used to make accurate determinations for casts involving Integer and Pointer types. They are no-op casts if the integer is the same size as the pointer. However, pointer size varies with platform. Generally, the result of DataLayout::getIntPtrType() should be passed in. If that's not available, use Type::Int64Ty, which will make the isNoopCast call conservative.
This function determines if the CastInst does not require any bits to be changed in order to effect the cast. Essentially, it identifies cases where no code gen is necessary for the cast, hence the name no-op cast. For example, the following are all no-op casts:
Opcode | Opcode of cast |
SrcTy | SrcTy of cast |
DestTy | DstTy of cast |
IntPtrTy | Integer type corresponding to Ptr types |
Definition at line 2083 of file Instructions.cpp.
References llvm::Type::getScalarSizeInBits(), and llvm_unreachable.
Referenced by isNoopCast().
Determine if this cast is a no-op cast.
Determine if a cast is a no-op.
IntPtrTy | Integer type corresponding to pointer |
Definition at line 2113 of file Instructions.cpp.
References getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), and isNoopCast().