LLVM  6.0.0svn
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
llvm::CastInst Class Reference

This is the base class for all instructions that perform data casts. More...

#include "llvm/IR/InstrTypes.h"

Inheritance diagram for llvm::CastInst:
Inheritance graph
[legend]
Collaboration diagram for llvm::CastInst:
Collaboration graph
[legend]

Public Member Functions

bool isIntegerCast () const
 There are several places where we need to know if a cast instruction only deals with integer source and destination types. More...
 
bool isLosslessCast () const
 A lossless cast is one that does not alter the basic value. More...
 
bool isNoopCast (Type *IntPtrTy) const
 Determine if this cast is a no-op cast. More...
 
bool isNoopCast (const DataLayout &DL) const
 Determine if this cast is a no-op cast. More...
 
Instruction::CastOps getOpcode () const
 Return the opcode of this CastInst. More...
 
TypegetSrcTy () const
 Return the source type, as a convenience. More...
 
TypegetDestTy () const
 Return the destination type, as a convenience. More...
 
- Public Member Functions inherited from llvm::UnaryInstruction
void * operator new (size_t s)
 
 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value)
 Transparently provide more efficient getOperand methods. More...
 
- Public Member Functions inherited from llvm::Instruction
 Instruction (const Instruction &)=delete
 
Instructionoperator= (const Instruction &)=delete
 
Instructionuser_back ()
 Specialize the methods defined in Value, as we know that an instruction can only be used by other instructions. More...
 
const Instructionuser_back () const
 
const BasicBlockgetParent () const
 
BasicBlockgetParent ()
 
const ModulegetModule () const
 Return the module owning the function this instruction belongs to or nullptr it the function does not have a module. More...
 
ModulegetModule ()
 
const FunctiongetFunction () const
 Return the function this instruction belongs to. More...
 
FunctiongetFunction ()
 
void removeFromParent ()
 This method unlinks 'this' from the containing basic block, but does not delete it. More...
 
SymbolTableList< Instruction >::iterator eraseFromParent ()
 This method unlinks 'this' from the containing basic block and deletes it. More...
 
void insertBefore (Instruction *InsertPos)
 Insert an unlinked instruction into a basic block immediately before the specified instruction. More...
 
void insertAfter (Instruction *InsertPos)
 Insert an unlinked instruction into a basic block immediately after the specified instruction. More...
 
void moveBefore (Instruction *MovePos)
 Unlink this instruction from its current basic block and insert it into the basic block that MovePos lives in, right before MovePos. More...
 
void moveBefore (BasicBlock &BB, SymbolTableList< Instruction >::iterator I)
 Unlink this instruction and insert into BB before I. More...
 
void moveAfter (Instruction *MovePos)
 Unlink this instruction from its current basic block and insert it into the basic block that MovePos lives in, right after MovePos. More...
 
unsigned getOpcode () const
 Returns a member of one of the enums like Instruction::Add. More...
 
const chargetOpcodeName () const
 
bool isTerminator () const
 
bool isBinaryOp () const
 
bool isShift ()
 
bool isCast () const
 
bool isFuncletPad () const
 
bool isLogicalShift () const
 Return true if this is a logical shift left or a logical shift right. More...
 
bool isArithmeticShift () const
 Return true if this is an arithmetic shift right. More...
 
bool isBitwiseLogicOp () const
 Return true if this is and/or/xor. More...
 
bool hasMetadata () const
 Return true if this instruction has any metadata attached to it. More...
 
bool hasMetadataOtherThanDebugLoc () const
 Return true if this instruction has metadata attached to it other than a debug location. More...
 
MDNodegetMetadata (unsigned KindID) const
 Get the metadata of given kind attached to this Instruction. More...
 
MDNodegetMetadata (StringRef Kind) const
 Get the metadata of given kind attached to this Instruction. More...
 
void getAllMetadata (SmallVectorImpl< std::pair< unsigned, MDNode *>> &MDs) const
 Get all metadata attached to this Instruction. More...
 
void getAllMetadataOtherThanDebugLoc (SmallVectorImpl< std::pair< unsigned, MDNode *>> &MDs) const
 This does the same thing as getAllMetadata, except that it filters out the debug location. More...
 
void getAAMetadata (AAMDNodes &N, bool Merge=false) const
 Fills the AAMDNodes structure with AA metadata from this instruction. More...
 
void setMetadata (unsigned KindID, MDNode *Node)
 Set the metadata of the specified kind to the specified node. More...
 
void setMetadata (StringRef Kind, MDNode *Node)
 
void copyMetadata (const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
 Copy metadata from SrcInst to this instruction. More...
 
void swapProfMetadata ()
 If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including name string), swap the order of the metadata. More...
 
void setAAMetadata (const AAMDNodes &N)
 Sets the metadata on this instruction from the AAMDNodes structure. More...
 
bool extractProfMetadata (uint64_t &TrueVal, uint64_t &FalseVal) const
 Retrieve the raw weight values of a conditional branch or select. More...
 
bool extractProfTotalWeight (uint64_t &TotalVal) const
 Retrieve total raw weight values of a branch. More...
 
void updateProfWeight (uint64_t S, uint64_t T)
 Updates branch_weights metadata by scaling it by S / T. More...
 
void setProfWeight (uint64_t W)
 Sets the branch_weights metadata to W for CallInst. More...
 
void setDebugLoc (DebugLoc Loc)
 Set the debug location information for this instruction. More...
 
const DebugLocgetDebugLoc () const
 Return the debug location for this node as a DebugLoc. More...
 
void setHasNoUnsignedWrap (bool b=true)
 Set or clear the nsw flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasNoSignedWrap (bool b=true)
 Set or clear the nsw flag on this instruction, which must be an operator which supports this flag. More...
 
void setIsExact (bool b=true)
 Set or clear the exact flag on this instruction, which must be an operator which supports this flag. More...
 
bool hasNoUnsignedWrap () const
 Determine whether the no unsigned wrap flag is set. More...
 
bool hasNoSignedWrap () const
 Determine whether the no signed wrap flag is set. More...
 
void dropPoisonGeneratingFlags ()
 Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs. More...
 
bool isExact () const
 Determine whether the exact flag is set. More...
 
void setHasUnsafeAlgebra (bool B)
 Set or clear the unsafe-algebra flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasNoNaNs (bool B)
 Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasNoInfs (bool B)
 Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasNoSignedZeros (bool B)
 Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports this flag. More...
 
void setHasAllowReciprocal (bool B)
 Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports this flag. More...
 
void setFastMathFlags (FastMathFlags FMF)
 Convenience function for setting multiple fast-math flags on this instruction, which must be an operator which supports these flags. More...
 
void copyFastMathFlags (FastMathFlags FMF)
 Convenience function for transferring all fast-math flag values to this instruction, which must be an operator which supports these flags. More...
 
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...
 
bool hasAllowContract () const
 Determine whether the allow-contract flag is set. More...
 
FastMathFlags getFastMathFlags () const
 Convenience function for getting all the fast-math flags, which must be an operator which supports these flags. More...
 
void copyFastMathFlags (const Instruction *I)
 Copy I's fast-math flags. More...
 
void copyIRFlags (const Value *V, bool IncludeWrapFlags=true)
 Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this instruction. More...
 
void andIRFlags (const Value *V)
 Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction. More...
 
bool isAssociative () const LLVM_READONLY
 Return true if the instruction is associative: More...
 
bool isCommutative () const
 Return true if the instruction is commutative: More...
 
bool isIdempotent () const
 Return true if the instruction is idempotent: More...
 
bool isNilpotent () const
 Return true if the instruction is nilpotent: More...
 
bool mayWriteToMemory () const
 Return true if this instruction may modify memory. More...
 
bool mayReadFromMemory () const
 Return true if this instruction may read memory. More...
 
bool mayReadOrWriteMemory () const
 Return true if this instruction may read or write memory. More...
 
bool isAtomic () const
 Return true if this instruction has an AtomicOrdering of unordered or higher. More...
 
bool hasAtomicLoad () const
 Return true if this atomic instruction loads from memory. More...
 
bool hasAtomicStore () const
 Return true if this atomic instruction stores to memory. More...
 
bool mayThrow () const
 Return true if this instruction may throw an exception. More...
 
bool isFenceLike () const
 Return true if this instruction behaves like a memory fence: it can load or store to memory location without being given a memory location. More...
 
bool mayHaveSideEffects () const
 Return true if the instruction may have side effects. More...
 
bool isEHPad () const
 Return true if the instruction is a variety of EH-block. More...
 
Instructionclone () const
 Create a copy of 'this' instruction that is identical in all ways except the following: More...
 
bool isIdenticalTo (const Instruction *I) const
 Return true if the specified instruction is exactly identical to the current one. More...
 
bool isIdenticalToWhenDefined (const Instruction *I) const
 This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags, which may specify conditions under which the instruction's result is undefined. More...
 
bool isSameOperationAs (const Instruction *I, unsigned flags=0) const
 This function determines if the specified instruction executes the same operation as the current one. More...
 
bool isUsedOutsideOfBlock (const BasicBlock *BB) const
 Return true if there are any uses of this instruction in blocks other than the specified block. More...
 
void dropUnknownNonDebugMetadata (ArrayRef< unsigned > KnownIDs)
 Drop all unknown metadata except for debug locations. More...
 
void dropUnknownNonDebugMetadata ()
 
void dropUnknownNonDebugMetadata (unsigned ID1)
 
void dropUnknownNonDebugMetadata (unsigned ID1, unsigned ID2)
 
- Public Member Functions inherited from llvm::User
 User (const User &)=delete
 
void operator delete (void *Usr)
 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...
 
const UsegetOperandList () const
 
UsegetOperandList ()
 
ValuegetOperand (unsigned i) const
 
void setOperand (unsigned i, Value *Val)
 
const UsegetOperandUse (unsigned i) const
 
UsegetOperandUse (unsigned i)
 
unsigned getNumOperands () const
 
ArrayRef< const uint8_t > getDescriptor () const
 Returns the descriptor co-allocated with this User instance. More...
 
MutableArrayRef< uint8_t > getDescriptor ()
 Returns the descriptor co-allocated with this User instance. More...
 
void setGlobalVariableNumOperands (unsigned NumOps)
 Set the number of operands on a GlobalVariable. More...
 
void setNumHungOffUseOperands (unsigned NumOps)
 Subclasses with hung off uses need to manage the operand count themselves. More...
 
op_iterator op_begin ()
 
const_op_iterator op_begin () const
 
op_iterator op_end ()
 
const_op_iterator op_end () const
 
op_range operands ()
 
const_op_range operands () const
 
value_op_iterator value_op_begin ()
 
value_op_iterator value_op_end ()
 
iterator_range< value_op_iteratoroperand_values ()
 
const_value_op_iterator value_op_begin () const
 
const_value_op_iterator value_op_end () const
 
iterator_range< const_value_op_iteratoroperand_values () const
 
void dropAllReferences ()
 Drop all references to operands. More...
 
void replaceUsesOfWith (Value *From, Value *To)
 Replace uses of one Value with another. More...
 
- Public Member Functions inherited from llvm::Value
 Value (const Value &)=delete
 
Valueoperator= (const Value &)=delete
 
void deleteValue ()
 Delete a pointer to a generic Value. More...
 
void dump () const
 Support for debugging, callable in GDB: V->dump() More...
 
TypegetType () const
 All values are typed, get the type of this value. More...
 
LLVMContextgetContext () const
 All values hold a context through their type. More...
 
bool hasName () const
 
ValueNamegetValueName () const
 
void setValueName (ValueName *VN)
 
StringRef getName () const
 Return a constant reference to the value's name. More...
 
void setName (const Twine &Name)
 Change the name of the value. More...
 
void takeName (Value *V)
 Transfer the name from V to this value. More...
 
void replaceAllUsesWith (Value *V)
 Change all uses of this to point to a new Value. More...
 
void replaceNonMetadataUsesWith (Value *V)
 Change non-metadata uses of this to point to a new Value. More...
 
void replaceUsesOutsideBlock (Value *V, BasicBlock *BB)
 replaceUsesOutsideBlock - Go through the uses list for this definition and make each use point to "V" instead of "this" when the use is outside the block. More...
 
void assertModuleIsMaterializedImpl () const
 
void assertModuleIsMaterialized () const
 
bool use_empty () const
 
use_iterator materialized_use_begin ()
 
const_use_iterator materialized_use_begin () const
 
use_iterator use_begin ()
 
const_use_iterator use_begin () const
 
use_iterator use_end ()
 
const_use_iterator use_end () const
 
iterator_range< use_iteratormaterialized_uses ()
 
iterator_range< const_use_iteratormaterialized_uses () const
 
iterator_range< use_iteratoruses ()
 
iterator_range< const_use_iteratoruses () const
 
bool user_empty () const
 
user_iterator materialized_user_begin ()
 
const_user_iterator materialized_user_begin () const
 
user_iterator user_begin ()
 
const_user_iterator user_begin () const
 
user_iterator user_end ()
 
const_user_iterator user_end () const
 
Useruser_back ()
 
const Useruser_back () const
 
iterator_range< user_iteratormaterialized_users ()
 
iterator_range< const_user_iteratormaterialized_users () const
 
iterator_range< user_iteratorusers ()
 
iterator_range< const_user_iteratorusers () const
 
bool hasOneUse () const
 Return true if there is exactly one user of this value. More...
 
bool hasNUses (unsigned N) const
 Return true if this Value has exactly N users. More...
 
bool hasNUsesOrMore (unsigned N) const
 Return true if this value has N users or more. More...
 
bool isUsedInBasicBlock (const BasicBlock *BB) const
 Check if this value is used in the specified basic block. More...
 
unsigned getNumUses () const
 This method computes the number of uses of this Value. More...
 
void addUse (Use &U)
 This method should only be used by the Use class. More...
 
unsigned getValueID () const
 Return an ID for the concrete type of this object. More...
 
unsigned getRawSubclassOptionalData () const
 Return the raw optional flags value contained in this value. More...
 
void clearSubclassOptionalData ()
 Clear the optional flags contained in this value. More...
 
bool hasSameSubclassOptionalData (const Value *V) const
 Check the optional flags for equality. More...
 
bool hasValueHandle () const
 Return true if there is a value handle associated with this value. More...
 
bool isUsedByMetadata () const
 Return true if there is metadata referencing this value. More...
 
bool isSwiftError () const
 Return true if this value is a swifterror value. More...
 
const ValuestripPointerCasts () const
 Strip off pointer casts, all-zero GEPs, and aliases. More...
 
ValuestripPointerCasts ()
 
const ValuestripPointerCastsAndBarriers () const
 Strip off pointer casts, all-zero GEPs, aliases and barriers. More...
 
ValuestripPointerCastsAndBarriers ()
 
const ValuestripPointerCastsNoFollowAliases () const
 Strip off pointer casts and all-zero GEPs. More...
 
ValuestripPointerCastsNoFollowAliases ()
 
const ValuestripInBoundsConstantOffsets () const
 Strip off pointer casts and all-constant inbounds GEPs. More...
 
ValuestripInBoundsConstantOffsets ()
 
const ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const
 Accumulate offsets from stripInBoundsConstantOffsets(). More...
 
ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset)
 
const ValuestripInBoundsOffsets () const
 Strip off pointer casts and inbounds GEPs. More...
 
ValuestripInBoundsOffsets ()
 
unsigned getPointerDereferenceableBytes (const DataLayout &DL, bool &CanBeNull) const
 Returns the number of bytes known to be dereferenceable for the pointer value. More...
 
unsigned getPointerAlignment (const DataLayout &DL) const
 Returns an alignment of the pointer value. More...
 
const ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const
 Translate PHI node to its predecessor from the given basic block. More...
 
ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB)
 
void mutateType (Type *Ty)
 Mutate the type of this Value to be of the specified type. More...
 
template<class Compare >
void sortUseList (Compare Cmp)
 Sort the use-list. More...
 
void reverseUseList ()
 Reverse the use-list. More...
 
void print (raw_ostream &O, bool IsForDebug=false) const
 Implement operator<< on Value. More...
 
void print (raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug=false) const
 
void printAsOperand (raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
 Print the name of this Value out to the specified raw_ostream. More...
 
void printAsOperand (raw_ostream &O, bool PrintType, ModuleSlotTracker &MST) const
 
- Public Member Functions inherited from llvm::ilist_node_with_parent< Instruction, BasicBlock >
InstructiongetPrevNode ()
 
const InstructiongetPrevNode () const
 Get the previous node, or nullptr for the list head. More...
 
InstructiongetNextNode ()
 Get the next node, or nullptr for the list tail. More...
 
const InstructiongetNextNode () const
 Get the next node, or nullptr for the list tail. More...
 
- Public Member Functions inherited from llvm::ilist_node_impl< ilist_detail::compute_node_options< Instruction, Options... >::type >
self_iterator getIterator ()
 
const_self_iterator getIterator () const
 
reverse_self_iterator getReverseIterator ()
 
const_reverse_self_iterator getReverseIterator () const
 
bool isSentinel () const
 Check whether this is the sentinel node. More...
 

Static Public Member Functions

static CastInstCreate (Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's constructor. More...
 
static CastInstCreate (Instruction::CastOps, Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
 Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's constructor. More...
 
static CastInstCreateZExtOrBitCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Create a ZExt or BitCast cast instruction. More...
 
static CastInstCreateZExtOrBitCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
 Create a ZExt or BitCast cast instruction. More...
 
static CastInstCreateSExtOrBitCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Create a SExt or BitCast cast instruction. More...
 
static CastInstCreateSExtOrBitCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
 Create a SExt or BitCast cast instruction. More...
 
static CastInstCreatePointerCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
 Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction. More...
 
static CastInstCreatePointerCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction. More...
 
static CastInstCreatePointerBitCastOrAddrSpaceCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
 Create a BitCast or an AddrSpaceCast cast instruction. More...
 
static CastInstCreatePointerBitCastOrAddrSpaceCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Create a BitCast or an AddrSpaceCast cast instruction. More...
 
static CastInstCreateBitOrPointerCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Create a BitCast, a PtrToInt, or an IntToPTr cast instruction. More...
 
static CastInstCreateIntegerCast (Value *S, Type *Ty, bool isSigned, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Create a ZExt, BitCast, or Trunc for int -> int casts. More...
 
static CastInstCreateIntegerCast (Value *S, Type *Ty, bool isSigned, const Twine &Name, BasicBlock *InsertAtEnd)
 Create a ZExt, BitCast, or Trunc for int -> int casts. More...
 
static CastInstCreateFPCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Create an FPExt, BitCast, or FPTrunc for fp -> fp casts. More...
 
static CastInstCreateFPCast (Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
 Create an FPExt, BitCast, or FPTrunc for fp -> fp casts. More...
 
static CastInstCreateTruncOrBitCast (Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
 Create a Trunc or BitCast cast instruction. More...
 
static CastInstCreateTruncOrBitCast (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 bool isBitOrNoopPointerCastable (Type *SrcTy, Type *DestTy, const DataLayout &DL)
 Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op. More...
 
static Instruction::CastOps getCastOpcode (const Value *Val, bool SrcIsSigned, Type *Ty, bool DstIsSigned)
 Returns the opcode necessary to cast Val into Ty using usual casting rules. More...
 
static bool isNoopCast (Instruction::CastOps Opcode, Type *SrcTy, Type *DstTy, Type *IntPtrTy)
 A no-op cast is one that can be effected without changing any bits. More...
 
static unsigned isEliminableCastPair (Instruction::CastOps firstOpcode, Instruction::CastOps secondOpcode, Type *SrcTy, Type *MidTy, Type *DstTy, Type *SrcIntPtrTy, Type *MidIntPtrTy, Type *DstIntPtrTy)
 Determine how a pair of casts can be eliminated, if they can be at all. More...
 
static bool castIsValid (Instruction::CastOps op, Value *S, Type *DstTy)
 This method can be used to determine if a cast from S to DstTy using Opcode op is valid or not. 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 Public Member Functions inherited from llvm::UnaryInstruction
static bool classof (const Instruction *I)
 
static bool classof (const Value *V)
 
- Static Public Member Functions inherited from llvm::Instruction
static const chargetOpcodeName (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 isBitwiseLogicOp (unsigned Opcode)
 Determine if the Opcode is and/or/xor. More...
 
static bool isCast (unsigned OpCode)
 Determine if the OpCode is one of the CastInst instructions. More...
 
static bool isFuncletPad (unsigned OpCode)
 Determine if the OpCode is one of the FuncletPadInst instructions. More...
 
static bool isAssociative (unsigned Opcode)
 
static bool isCommutative (unsigned Opcode)
 
static bool isIdempotent (unsigned Opcode)
 
static bool isNilpotent (unsigned Opcode)
 
static bool classof (const Value *V)
 Methods for support type inquiry through isa, cast, and dyn_cast: More...
 
- Static Public Member Functions inherited from llvm::User
static bool classof (const Value *V)
 

Protected Member Functions

 CastInst (Type *Ty, unsigned iType, Value *S, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
 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...
 
- Protected Member Functions inherited from llvm::UnaryInstruction
 UnaryInstruction (Type *Ty, unsigned iType, Value *V, Instruction *IB=nullptr)
 
 UnaryInstruction (Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
 
- Protected Member Functions inherited from llvm::Instruction
 ~Instruction ()
 
void setInstructionSubclassData (unsigned short D)
 
unsigned getSubclassDataFromInstruction () const
 
 Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, Instruction *InsertBefore=nullptr)
 
 Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)
 
- Protected Member Functions inherited from llvm::User
void * operator new (size_t Size)
 Allocate a User with an operand pointer co-allocated. More...
 
void * operator new (size_t Size, unsigned Us)
 Allocate a User with the operands co-allocated. More...
 
void * operator new (size_t Size, unsigned Us, unsigned DescBytes)
 Allocate a User with the operands co-allocated. More...
 
 User (Type *ty, unsigned vty, Use *, unsigned NumOps)
 
void allocHungoffUses (unsigned N, bool IsPhi=false)
 Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User. More...
 
void growHungoffUses (unsigned N, bool IsPhi=false)
 Grow the number of hung off uses. More...
 
 ~User ()=default
 
template<int Idx>
UseOp ()
 
template<int Idx>
const UseOp () const
 
- Protected Member Functions inherited from llvm::Value
 Value (Type *Ty, unsigned scid)
 
 ~Value ()
 Value's destructor should be virtual by design, but that would require that Value and all of its subclasses have a vtable that effectively duplicates the information in the value ID. More...
 
unsigned short getSubclassDataFromValue () const
 
void setValueSubclassData (unsigned short D)
 
- Protected Member Functions inherited from llvm::ilist_node_with_parent< Instruction, BasicBlock >
 ilist_node_with_parent ()=default
 
- Protected Member Functions inherited from llvm::ilist_node_impl< ilist_detail::compute_node_options< Instruction, Options... >::type >
 ilist_node_impl ()=default
 

Additional Inherited Members

- Public Types inherited from llvm::Instruction
enum  OperationEquivalenceFlags { CompareIgnoringAlignment = 1<<0, CompareUsingScalarTypes = 1<<1 }
 When checking for operation equivalence (using isSameOperationAs) it is sometimes useful to ignore certain attributes. More...
 
enum  TermOps
 
enum  BinaryOps
 
enum  MemoryOps
 
enum  CastOps
 
enum  FuncletPadOps
 
enum  OtherOps
 
- Public Types inherited from llvm::User
using op_iterator = Use *
 
using const_op_iterator = const Use *
 
using op_range = iterator_range< op_iterator >
 
using const_op_range = iterator_range< const_op_iterator >
 
- Public Types inherited from llvm::Value
enum  ValueTy
 Concrete subclass of this. More...
 
using use_iterator = use_iterator_impl< Use >
 
using const_use_iterator = use_iterator_impl< const Use >
 
using user_iterator = user_iterator_impl< User >
 
using const_user_iterator = user_iterator_impl< const User >
 
- Static Public Attributes inherited from llvm::Value
static const unsigned MaxAlignmentExponent = 29
 The maximum alignment for instructions. More...
 
static const unsigned MaximumAlignment = 1u << MaxAlignmentExponent
 
- Protected Types inherited from llvm::Value
enum  : unsigned { NumUserOperandsBits = 28 }
 The number of operands in the subclass. More...
 
- Protected Types inherited from llvm::ilist_node_impl< ilist_detail::compute_node_options< Instruction, Options... >::type >
using self_iterator = ilist_iterator< ilist_detail::compute_node_options< Instruction, Options... >::type, false, false >
 
using const_self_iterator = ilist_iterator< ilist_detail::compute_node_options< Instruction, Options... >::type, false, true >
 
using reverse_self_iterator = ilist_iterator< ilist_detail::compute_node_options< Instruction, Options... >::type, true, false >
 
using const_reverse_self_iterator = ilist_iterator< ilist_detail::compute_node_options< Instruction, Options... >::type, true, true >
 
- Static Protected Member Functions inherited from llvm::User
template<int Idx, typename U >
static UseOpFrom (const U *that)
 
- Protected Attributes inherited from llvm::Value
unsigned char SubclassOptionalData: 7
 Hold subclass data that can be dropped. More...
 
unsigned NumUserOperands: NumUserOperandsBits
 
unsigned IsUsedByMD: 1
 
unsigned HasName: 1
 
unsigned HasHungOffUses: 1
 
unsigned HasDescriptor: 1
 

Detailed Description

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)) { ... } Base class of casting instructions.

Definition at line 560 of file InstrTypes.h.

Constructor & Destructor Documentation

◆ CastInst() [1/2]

llvm::CastInst::CastInst ( Type Ty,
unsigned  iType,
Value S,
const Twine NameStr = "",
Instruction InsertBefore = nullptr 
)
inlineprotected

Constructor with insert-before-instruction semantics for subclasses.

Definition at line 563 of file InstrTypes.h.

References llvm::Value::setName().

◆ CastInst() [2/2]

llvm::CastInst::CastInst ( Type Ty,
unsigned  iType,
Value S,
const Twine NameStr,
BasicBlock InsertAtEnd 
)
inlineprotected

Constructor with insert-at-end-of-block semantics for subclasses.

Definition at line 569 of file InstrTypes.h.

References llvm::Value::setName().

Member Function Documentation

◆ castIsValid()

bool CastInst::castIsValid ( Instruction::CastOps  op,
Value S,
Type DstTy 
)
static

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.

Returns
true iff the proposed cast is valid. Determine if a cast is valid without creating one.

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 3015 of file Instructions.cpp.

References llvm::dyn_cast(), llvm::PointerType::getAddressSpace(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Value::getType(), llvm::Type::isAggregateType(), llvm::Type::isFirstClassType(), llvm::Type::isFPOrFPVectorTy(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPtrOrPtrVectorTy(), and llvm::Type::isVectorTy().

Referenced by llvm::AddrSpaceCastInst::AddrSpaceCastInst(), llvm::BitCastInst::BitCastInst(), llvm::FPExtInst::FPExtInst(), llvm::FPToSIInst::FPToSIInst(), llvm::FPToUIInst::FPToUIInst(), llvm::FPTruncInst::FPTruncInst(), FunctionNumber(), llvm::ConstantExpr::getAddrSpaceCast(), llvm::ConstantExpr::getBitCast(), llvm::ConstantExpr::getCast(), getSuccPad(), llvm::IntToPtrInst::IntToPtrInst(), llvm::IsConstantOffsetFromGlobal(), isFuncOrArgAttr(), llvm::isLegalToPromote(), llvm::PtrToIntInst::PtrToIntInst(), readWideAPInt(), llvm::SExtInst::SExtInst(), llvm::SIToFPInst::SIToFPInst(), llvm::TruncInst::TruncInst(), llvm::UIToFPInst::UIToFPInst(), and llvm::ZExtInst::ZExtInst().

◆ classof() [1/2]

static bool llvm::CastInst::classof ( const Instruction I)
inlinestatic

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

Definition at line 836 of file InstrTypes.h.

References llvm::Instruction::isCast().

◆ classof() [2/2]

static bool llvm::CastInst::classof ( const Value V)
inlinestatic

Definition at line 839 of file InstrTypes.h.

References llvm::TerminatorInst::classof().

◆ Create() [1/2]

CastInst * CastInst::Create ( Instruction::CastOps  op,
Value S,
Type Ty,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

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). Construct any of the CastInst subclasses

Parameters
opThe opcode of the cast instruction
SThe value to be casted (operand 0)
TyThe type to which cast should be made
NameName for the instruction
InsertBeforePlace to insert the instruction

Definition at line 2577 of file Instructions.cpp.

References assert(), and llvm_unreachable.

Referenced by buildNew(), llvm::InstCombiner::commonCastTransforms(), llvm::NoFolder::CreateCast(), llvm::IRBuilder< TargetFolder >::CreateCast(), foldAddWithConstant(), foldLogicCastConstant(), foldSelectICmpAndOr(), FunctionNumber(), llvm::ConstantExpr::getAsInstruction(), getSelectFoldableConstant(), isBroadcastShuffle(), isSafeAndProfitableToSinkLoad(), llvm::PHITransAddr::PHITranslateWithInsertion(), readWideAPInt(), llvm::recognizeBSwapOrBitReverseIdiom(), SimplifyNVVMIntrinsic(), SinkCast(), SinkShiftAndTruncate(), llvm::UpgradeBitCastInst(), llvm::InstCombiner::visitBitCast(), llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitExtractElementInst(), and llvm::InstCombiner::visitGetElementPtrInst().

◆ Create() [2/2]

CastInst * CastInst::Create ( Instruction::CastOps  op,
Value S,
Type Ty,
const Twine Name,
BasicBlock InsertAtEnd 
)
static

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). Construct any of the CastInst subclasses

Parameters
opThe opcode for the cast instruction
SThe value to be casted (operand 0)
TyThe type to which operand is casted
NameThe name for the instruction
InsertAtEndThe block to insert the instruction into

Definition at line 2599 of file Instructions.cpp.

References assert(), and llvm_unreachable.

◆ CreateBitOrPointerCast()

CastInst * CastInst::CreateBitOrPointerCast ( Value S,
Type Ty,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.

If the value is a pointer type and the destination an integer type, creates a PtrToInt cast. If the value is an integer type and the destination a pointer type, creates an IntToPtr cast. Otherwise, creates a bitcast.

Parameters
SThe pointer value to be casted (operand 0)
TyThe type to which cast should be made
NameName for the instruction
InsertBeforePlace to insert the instruction

Definition at line 2730 of file Instructions.cpp.

References llvm::BinaryOperator::Create(), llvm::Value::getType(), llvm::Type::isIntegerTy(), and llvm::Type::isPointerTy().

Referenced by findInitTrampoline(), foldSelectICmpAndOr(), and llvm::JumpThreadingPass::SimplifyPartiallyRedundantLoad().

◆ CreateFPCast() [1/2]

CastInst * CastInst::CreateFPCast ( Value S,
Type Ty,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.

Parameters
SThe floating point value to be casted
TyThe floating point type to cast to
NameName for the instruction
InsertBeforePlace to insert the instruction

Definition at line 2769 of file Instructions.cpp.

References assert(), llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), and llvm::Type::isFPOrFPVectorTy().

Referenced by llvm::NoFolder::CreateFPCast(), llvm::IRBuilder< TargetFolder >::CreateFPCast(), and llvm::InstCombiner::visitFPTrunc().

◆ CreateFPCast() [2/2]

CastInst * CastInst::CreateFPCast ( Value S,
Type Ty,
const Twine Name,
BasicBlock InsertAtEnd 
)
static

Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.

Parameters
SThe floating point value to be casted
TyThe floating point type to cast to
NameThe name for the instruction
InsertAtEndThe block to insert the instruction into

Definition at line 2782 of file Instructions.cpp.

References assert(), llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), and llvm::Type::isFPOrFPVectorTy().

◆ CreateIntegerCast() [1/2]

CastInst * CastInst::CreateIntegerCast ( Value S,
Type Ty,
bool  isSigned,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

Create a ZExt, BitCast, or Trunc for int -> int casts.

Parameters
SThe pointer value to be casted (operand 0)
TyThe type to which cast should be made
isSignedWhether to regard S as signed or not
NameName for the instruction
InsertBeforePlace to insert the instruction

Definition at line 2741 of file Instructions.cpp.

References assert(), llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), and llvm::Type::isIntOrIntVectorTy().

Referenced by llvm::NoFolder::CreateIntCast(), llvm::IRBuilder< TargetFolder >::CreateIntCast(), createMalloc(), llvm::createSeparateConstOffsetFromGEPPass(), decomposeSimpleLinearExpr(), llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitPtrToInt(), llvm::InstCombiner::visitTrunc(), and llvm::InstCombiner::visitZExt().

◆ CreateIntegerCast() [2/2]

CastInst * CastInst::CreateIntegerCast ( Value S,
Type Ty,
bool  isSigned,
const Twine Name,
BasicBlock InsertAtEnd 
)
static

Create a ZExt, BitCast, or Trunc for int -> int casts.

Parameters
SThe integer value to be casted (operand 0)
TyThe integer type to which operand is casted
isSignedWhether to regard S as signed or not
NameThe name for the instruction
InsertAtEndThe block to insert the instruction into

Definition at line 2755 of file Instructions.cpp.

References assert(), llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), and llvm::Type::isIntOrIntVectorTy().

◆ CreatePointerBitCastOrAddrSpaceCast() [1/2]

CastInst * CastInst::CreatePointerBitCastOrAddrSpaceCast ( Value S,
Type Ty,
const Twine Name,
BasicBlock InsertAtEnd 
)
static

Create a BitCast or an AddrSpaceCast cast instruction.

Parameters
SThe pointer value to be casted (operand 0)
TyThe type to which operand is casted
NameThe name for the instruction
InsertAtEndThe block to insert the instruction into

Definition at line 2704 of file Instructions.cpp.

References assert(), llvm::BinaryOperator::Create(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), and llvm::Type::isPtrOrPtrVectorTy().

Referenced by llvm::IRBuilder< TargetFolder >::CreatePointerBitCastOrAddrSpaceCast(), and llvm::InstCombiner::visitGetElementPtrInst().

◆ CreatePointerBitCastOrAddrSpaceCast() [2/2]

CastInst * CastInst::CreatePointerBitCastOrAddrSpaceCast ( Value S,
Type Ty,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

Create a BitCast or an AddrSpaceCast cast instruction.

Parameters
SThe pointer value to be casted (operand 0)
TyThe type to which cast should be made
NameName for the instruction
InsertBeforePlace to insert the instruction

Definition at line 2717 of file Instructions.cpp.

References assert(), llvm::BinaryOperator::Create(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), and llvm::Type::isPtrOrPtrVectorTy().

◆ CreatePointerCast() [1/2]

CastInst * CastInst::CreatePointerCast ( Value S,
Type Ty,
const Twine Name,
BasicBlock InsertAtEnd 
)
static

Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction.

Parameters
SThe pointer value to be casted (operand 0)
TyThe type to which operand is casted
NameThe name for the instruction
InsertAtEndThe block to insert the instruction into

Definition at line 2669 of file Instructions.cpp.

References assert(), llvm::BinaryOperator::Create(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPtrOrPtrVectorTy(), and llvm::Type::isVectorTy().

Referenced by llvm::NoFolder::CreatePointerCast(), llvm::IRBuilder< TargetFolder >::CreatePointerCast(), llvm::InnerLoopVectorizer::getOrCreateTripCount(), and moveUp().

◆ CreatePointerCast() [2/2]

CastInst * CastInst::CreatePointerCast ( Value S,
Type Ty,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.

Create a BitCast or a PtrToInt cast instruction.

Parameters
SThe pointer value to be casted (operand 0)
TyThe type to which cast should be made
NameName for the instruction
InsertBeforePlace to insert the instruction

Definition at line 2687 of file Instructions.cpp.

References assert(), llvm::BinaryOperator::Create(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPtrOrPtrVectorTy(), and llvm::Type::isVectorTy().

◆ CreateSExtOrBitCast() [1/2]

CastInst * CastInst::CreateSExtOrBitCast ( Value S,
Type Ty,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

Create a SExt or BitCast cast instruction.

Parameters
SThe value to be casted (operand 0)
TyThe type to which cast should be made
NameName for the instruction
InsertBeforePlace to insert the instruction

Definition at line 2637 of file Instructions.cpp.

References llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().

Referenced by llvm::NoFolder::CreateSExtOrBitCast(), llvm::IRBuilder< TargetFolder >::CreateSExtOrBitCast(), and llvm::InstCombiner::visitSub().

◆ CreateSExtOrBitCast() [2/2]

CastInst * CastInst::CreateSExtOrBitCast ( Value S,
Type Ty,
const Twine Name,
BasicBlock InsertAtEnd 
)
static

Create a SExt or BitCast cast instruction.

Parameters
SThe value to be casted (operand 0)
TyThe type to which operand is casted
NameThe name for the instruction
InsertAtEndThe block to insert the instruction into

Definition at line 2645 of file Instructions.cpp.

References llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().

◆ CreateTruncOrBitCast() [1/2]

CastInst * CastInst::CreateTruncOrBitCast ( Value S,
Type Ty,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

Create a Trunc or BitCast cast instruction.

Parameters
SThe value to be casted (operand 0)
TyThe type to which cast should be made
NameName for the instruction
InsertBeforePlace to insert the instruction

Definition at line 2653 of file Instructions.cpp.

References llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().

Referenced by llvm::NoFolder::CreateTruncOrBitCast(), and llvm::IRBuilder< TargetFolder >::CreateTruncOrBitCast().

◆ CreateTruncOrBitCast() [2/2]

CastInst * CastInst::CreateTruncOrBitCast ( Value S,
Type Ty,
const Twine Name,
BasicBlock InsertAtEnd 
)
static

Create a Trunc or BitCast cast instruction.

Parameters
SThe value to be casted (operand 0)
TyThe type to which operand is casted
NameThe name for the instruction
InsertAtEndThe block to insert the instruction into

Definition at line 2661 of file Instructions.cpp.

References llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().

◆ CreateZExtOrBitCast() [1/2]

CastInst * CastInst::CreateZExtOrBitCast ( Value S,
Type Ty,
const Twine Name = "",
Instruction InsertBefore = nullptr 
)
static

Create a ZExt or BitCast cast instruction.

Parameters
SThe value to be casted (operand 0)
TyThe type to which cast should be made
NameName for the instruction
InsertBeforePlace to insert the instruction

Definition at line 2621 of file Instructions.cpp.

References llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().

Referenced by llvm::NoFolder::CreateZExtOrBitCast(), llvm::IRBuilder< TargetFolder >::CreateZExtOrBitCast(), isSafeAndProfitableToSinkLoad(), and llvm::InstCombiner::visitSub().

◆ CreateZExtOrBitCast() [2/2]

CastInst * CastInst::CreateZExtOrBitCast ( Value S,
Type Ty,
const Twine Name,
BasicBlock InsertAtEnd 
)
static

Create a ZExt or BitCast cast instruction.

Parameters
SThe value to be casted (operand 0)
TyThe type to which operand is casted
NameThe name for the instruction
InsertAtEndThe block to insert the instruction into

Definition at line 2629 of file Instructions.cpp.

References llvm::BinaryOperator::Create(), llvm::Type::getScalarSizeInBits(), and llvm::Value::getType().

◆ getCastOpcode()

Instruction::CastOps CastInst::getCastOpcode ( const Value Val,
bool  SrcIsSigned,
Type Ty,
bool  DstIsSigned 
)
static

Returns the opcode necessary to cast Val into Ty using usual casting rules.

Infer the opcode for cast operand and type

Parameters
ValThe value to cast
SrcIsSignedWhether to treat the source as signed
TyThe Type to which the value should be casted
DstIsSignedWhether to treate the dest. as signed

Definition at line 2912 of file Instructions.cpp.

References assert(), 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 BuildConstantFromSCEV(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldLoadFromConstPtr(), llvm::InnerLoopVectorizer::createVectorizedLoopSkeleton(), findInitTrampoline(), findInsertPointAfter(), getFoldedAlignOf(), getFoldedOffsetOf(), and getFoldedSizeOf().

◆ getDestTy()

Type* llvm::CastInst::getDestTy ( ) const
inline

Return the destination type, as a convenience.

Definition at line 827 of file InstrTypes.h.

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

Referenced by asmClobbersCTR(), constantFoldUser(), decomposeSimpleLinearExpr(), getScalarIntrinsicDeclaration(), and matchDeMorgansLaws().

◆ getOpcode()

Instruction::CastOps llvm::CastInst::getOpcode ( ) const
inline

◆ getSrcTy()

Type* llvm::CastInst::getSrcTy ( ) const
inline

◆ isBitCastable()

bool CastInst::isBitCastable ( Type SrcTy,
Type DestTy 
)
static

Check whether a bitcast between these types is valid.

Parameters
SrcTyThe Type from which the value should be cast.
DestTyThe Type to which the value should be cast.

Definition at line 2852 of file Instructions.cpp.

References llvm::Type::getPrimitiveSizeInBits(), llvm::Type::isFirstClassType(), and llvm::Type::isX86_MMXTy().

Referenced by llvm::isLegalToPromote().

◆ isBitOrNoopPointerCastable()

bool CastInst::isBitOrNoopPointerCastable ( Type SrcTy,
Type DestTy,
const DataLayout DL 
)
static

Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op.

This ensures that any pointer<->integer cast has enough bits in the integer and any other cast is a bitcast.

Parameters
SrcTyThe Type from which the value should be cast.
DestTyThe Type to which the value should be cast.

Definition at line 2892 of file Instructions.cpp.

References llvm::DataLayout::getPointerTypeSizeInBits().

Referenced by llvm::InnerLoopVectorizer::createBitOrPointerCast(), llvm::FindAvailablePtrLoadStore(), and findInitTrampoline().

◆ isCastable()

bool CastInst::isCastable ( Type SrcTy,
Type DestTy 
)
static

Check whether it is valid to call getCastOpcode for these types.

Parameters
SrcTyThe Type from which the value should be cast.
DestTyThe Type to which the value should be cast.

Definition at line 2797 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().

◆ isEliminableCastPair()

unsigned CastInst::isEliminableCastPair ( Instruction::CastOps  firstOp,
Instruction::CastOps  secondOp,
Type SrcTy,
Type MidTy,
Type DstTy,
Type SrcIntPtrTy,
Type MidIntPtrTy,
Type DstIntPtrTy 
)
static

Determine how a pair of casts can be eliminated, if they can be at all.

This function determines if a pair of casts can be eliminated and what opcode should be used in the elimination.

This is a helper function for both CastInst and ConstantExpr.

Returns
0 if the CastInst pair can't be eliminated, otherwise returns Instruction::CastOps value for a cast that can replace the pair, casting SrcTy to DstTy. Determine if a cast pair is eliminable

This assumes that there are two instructions like this:

  • F = firstOpcode SrcTy x to MidTy
  • S = secondOpcode MidTy F to DstTy The function returns a resultOpcode so these two casts can be replaced with:
  • Replacement = resultOpcode SrcTy x to DstTy If no such cast is permitted, the function returns 0.
Parameters
firstOpOpcode of first cast
secondOpOpcode of second cast
SrcTySrcTy of 1st cast
MidTyDstTy of 1st cast & SrcTy of 2nd cast
DstTyDstTy of 2nd cast
SrcIntPtrTyInteger type corresponding to Ptr SrcTy, or null
MidIntPtrTyInteger type corresponding to Ptr MidTy, or null
DstIntPtrTyInteger type corresponding to Ptr DstTy, or null

Definition at line 2354 of file Instructions.cpp.

References assert(), llvm::Type::getPointerAddressSpace(), llvm::Type::getPointerElementType(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::Type::isFloatingPointTy(), llvm::Type::isIntegerTy(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isPtrOrPtrVectorTy(), llvm::Type::isVectorTy(), and llvm_unreachable.

Referenced by decomposeSimpleLinearExpr(), foldConstantCastPair(), and SimplifyCastInst().

◆ isIntegerCast()

bool CastInst::isIntegerCast ( ) const

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.

Returns
true iff the cast has only integral typed operand and dest type. Determine if this is an integer-only cast.

Definition at line 2261 of file Instructions.cpp.

References llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), and llvm::Type::isIntegerTy().

◆ isLosslessCast()

bool CastInst::isLosslessCast ( ) const

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.

Returns
true iff the cast is lossless. Determine if this is a lossless cast.

Definition at line 2274 of file Instructions.cpp.

References llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), and llvm::Type::isPointerTy().

Referenced by isSafeToEliminateVarargsCast().

◆ isNoopCast() [1/3]

bool CastInst::isNoopCast ( Instruction::CastOps  Opcode,
Type SrcTy,
Type DestTy,
Type IntPtrTy 
)
static

A no-op cast is one that can be effected without changing any bits.

This function determines if the CastInst does not require any bits to be changed in order to effect the cast.

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. Determine if the described cast is a no-op 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:

bitcast i32* x to i8*

bitcast <2 x i32> x to <4 x i16>

ptrtoint i32* x to i32 ; on 32-bit plaforms only

Determine if the described cast is a no-op.

Parameters
OpcodeOpcode of cast
SrcTySrcTy of cast
DestTyDstTy of cast
IntPtrTyInteger type corresponding to Ptr types

Definition at line 2299 of file Instructions.cpp.

References llvm::Type::getScalarSizeInBits(), and llvm_unreachable.

Referenced by isZero().

◆ isNoopCast() [2/3]

bool CastInst::isNoopCast ( Type IntPtrTy) const

Determine if this cast is a no-op cast.

Determine if a cast is a no-op.

Parameters
IntPtrTyInteger type corresponding to pointer

Definition at line 2329 of file Instructions.cpp.

References llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), and llvm::Value::getType().

◆ isNoopCast() [3/3]

bool CastInst::isNoopCast ( const DataLayout DL) const

Determine if this cast is a no-op cast.

Parameters
DLis the DataLayout to get the Int Ptr type from.

Definition at line 2333 of file Instructions.cpp.

References llvm::Value::getContext(), llvm::DataLayout::getIntPtrType(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), and llvm::Value::getType().


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