36 ? cast<CallInst>(II)->op_end() - 1
37 : cast<InvokeInst>(II)->op_end() - 3;
64 return "both values to select must have same type";
69 return "vector select condition element type must be i1";
72 return "selected values for vector select must be vectors";
74 return "vector select requires selected vectors to have "
75 "the same vector length as select condition";
77 return "select condition must be i1 or <n x i1>";
87 PHINode::PHINode(
const PHINode &PN)
89 allocHungoffUses(PN.getNumOperands()), PN.getNumOperands()),
90 ReservedSpace(PN.getNumOperands()) {
106 Use *Begin =
static_cast<Use*
>(::operator
new(size));
107 Use *End = Begin +
N;
108 (void)
new(End)
Use::UserRef(const_cast<PHINode*>(
this), 1);
142 void PHINode::growOperands() {
144 unsigned NumOps = e + e / 2;
145 if (NumOps < 2) NumOps = 2;
150 ReservedSpace = NumOps;
153 std::copy(OldOps, OldOps + e,
op_begin());
154 std::copy(OldBlocks, OldBlocks + e,
block_begin());
166 if (ConstantValue !=
this)
171 if (ConstantValue ==
this)
173 return ConstantValue;
180 LandingPadInst::LandingPadInst(
Type *RetTy,
Value *PersonalityFn,
181 unsigned NumReservedValues,
const Twine &NameStr,
184 init(PersonalityFn, 1 + NumReservedValues, NameStr);
187 LandingPadInst::LandingPadInst(
Type *RetTy,
Value *PersonalityFn,
188 unsigned NumReservedValues,
const Twine &NameStr,
191 init(PersonalityFn, 1 + NumReservedValues, NameStr);
196 allocHungoffUses(LP.getNumOperands()), LP.getNumOperands()),
197 ReservedSpace(LP.getNumOperands()) {
199 for (
unsigned I = 0, E = ReservedSpace;
I != E; ++
I)
210 unsigned NumReservedClauses,
211 const Twine &NameStr,
213 return new LandingPadInst(RetTy, PersonalityFn, NumReservedClauses, NameStr,
218 unsigned NumReservedClauses,
219 const Twine &NameStr,
221 return new LandingPadInst(RetTy, PersonalityFn, NumReservedClauses, NameStr,
225 void LandingPadInst::init(
Value *PersFn,
unsigned NumReservedValues,
226 const Twine &NameStr) {
227 ReservedSpace = NumReservedValues;
237 void LandingPadInst::growOperands(
unsigned Size) {
239 if (ReservedSpace >= e + Size)
return;
240 ReservedSpace = (e + Size / 2) * 2;
244 for (
unsigned i = 0; i != e; ++i)
245 NewOps[i] = OldOps[i];
254 assert(OpNo < ReservedSpace &&
"Growing didn't work!");
272 cast<FunctionType>(cast<PointerType>(Func->
getType())->getElementType());
274 assert((Args.
size() == FTy->getNumParams() ||
275 (FTy->isVarArg() && Args.
size() > FTy->getNumParams())) &&
276 "Calling a function with bad signature!");
278 for (
unsigned i = 0; i != Args.
size(); ++i)
279 assert((i >= FTy->getNumParams() ||
280 FTy->getParamType(i) == Args[i]->getType()) &&
281 "Calling a function with a bad signature!");
288 void CallInst::init(
Value *Func,
const Twine &NameStr) {
289 assert(
NumOperands == 1 &&
"NumOperands not set up?");
294 cast<FunctionType>(cast<PointerType>(Func->
getType())->getElementType());
296 assert(FTy->getNumParams() == 0 &&
"Calling a function with bad signature");
305 ->getElementType())->getReturnType(),
315 ->getElementType())->getReturnType(),
322 CallInst::CallInst(
const CallInst &CI)
325 CI.getNumOperands()) {
345 AttributeSet::get(Context, i, B));
350 if (AttributeList.
hasAttribute(AttributeSet::FunctionIndex, A))
353 return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, A);
361 return F->getAttributes().hasAttribute(i, A);
367 assert(val &&
"IsConstantOne does not work with NULL val");
368 return isa<ConstantInt>(val) && cast<ConstantInt>(val)->isOne();
376 assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) &&
377 "createMalloc needs either InsertBefore or InsertAtEnd");
385 else if (ArraySize->
getType() != IntPtrTy) {
396 AllocSize = ArraySize;
397 }
else if (
Constant *CO = dyn_cast<Constant>(ArraySize)) {
405 AllocSize = BinaryOperator::CreateMul(ArraySize, AllocSize,
406 "mallocsize", InsertBefore);
408 AllocSize = BinaryOperator::CreateMul(ArraySize, AllocSize,
409 "mallocsize", InsertAtEnd);
413 assert(AllocSize->
getType() == IntPtrTy &&
"malloc arg is wrong size");
416 Module* M = BB->getParent()->getParent();
418 Value *MallocFunc = MallocF;
426 MCall =
CallInst::Create(MallocFunc, AllocSize,
"malloccall", InsertBefore);
428 if (Result->
getType() != AllocPtrType)
430 Result =
new BitCastInst(MCall, AllocPtrType, Name, InsertBefore);
434 if (Result->
getType() != AllocPtrType) {
437 Result =
new BitCastInst(MCall, AllocPtrType, Name);
441 if (
Function *
F = dyn_cast<Function>(MallocFunc)) {
443 if (!
F->doesNotAlias(0))
F->setDoesNotAlias(0);
445 assert(!MCall->
getType()->
isVoidTy() &&
"Malloc has void return type");
461 return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, AllocSize,
462 ArraySize, MallocF, Name);
477 return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, AllocSize,
478 ArraySize, MallocF, Name);
483 assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) &&
484 "createFree needs either InsertBefore or InsertAtEnd");
486 "Can not free something of nonpointer type!");
489 Module* M = BB->getParent()->getParent();
498 if (Source->
getType() != IntPtrTy)
499 PtrCast =
new BitCastInst(Source, IntPtrTy,
"", InsertBefore);
502 if (Source->
getType() != IntPtrTy)
503 PtrCast =
new BitCastInst(Source, IntPtrTy,
"", InsertAtEnd);
507 if (
Function *
F = dyn_cast<Function>(FreeFunc))
515 return createFree(Source, InsertBefore, NULL);
523 assert(FreeCall &&
"CreateFree did not create a CallInst");
536 Op<-1>() = IfException;
540 cast<FunctionType>(cast<PointerType>(Fn->
getType())->getElementType());
542 assert(((Args.
size() == FTy->getNumParams()) ||
543 (FTy->isVarArg() && Args.
size() > FTy->getNumParams())) &&
544 "Invoking a function with bad signature");
546 for (
unsigned i = 0, e = Args.
size(); i != e; i++)
547 assert((i >= FTy->getNumParams() ||
548 FTy->getParamType(i) == Args[i]->getType()) &&
549 "Invoking a function with a bad signature!");
559 - II.getNumOperands(),
560 II.getNumOperands()) {
567 BasicBlock *InvokeInst::getSuccessorV(
unsigned idx)
const {
570 unsigned InvokeInst::getNumSuccessorsV()
const {
573 void InvokeInst::setSuccessorV(
unsigned idx,
BasicBlock *B) {
578 if (AttributeList.
hasAttribute(AttributeSet::FunctionIndex, A))
581 return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, A);
589 return F->getAttributes().hasAttribute(i, A);
619 RI.getNumOperands()) {
621 Op<0>() = RI.
Op<0>();
644 unsigned ReturnInst::getNumSuccessorsV()
const {
650 void ReturnInst::setSuccessorV(
unsigned idx,
BasicBlock *NewSucc) {
654 BasicBlock *ReturnInst::getSuccessorV(
unsigned idx)
const {
668 Op<0>() = RI.
Op<0>();
683 unsigned ResumeInst::getNumSuccessorsV()
const {
687 void ResumeInst::setSuccessorV(
unsigned idx,
BasicBlock *NewSucc) {
691 BasicBlock *ResumeInst::getSuccessorV(
unsigned idx)
const {
702 0, 0, InsertBefore) {
709 unsigned UnreachableInst::getNumSuccessorsV()
const {
713 void UnreachableInst::setSuccessorV(
unsigned idx,
BasicBlock *NewSucc) {
717 BasicBlock *UnreachableInst::getSuccessorV(
unsigned idx)
const {
725 void BranchInst::AssertOK() {
728 "May only branch on boolean predicates!");
735 assert(IfTrue != 0 &&
"Branch destination may not be null!");
755 assert(IfTrue != 0 &&
"Branch destination may not be null!");
773 BranchInst::BranchInst(
const BranchInst &BI) :
776 BI.getNumOperands()) {
777 Op<-1>() = BI.
Op<-1>();
779 assert(BI.
getNumOperands() == 3 &&
"BR can have 1 or 3 operands!");
780 Op<-3>() = BI.
Op<-3>();
781 Op<-2>() = BI.
Op<-2>();
788 "Cannot swap successors of an unconditional branch");
794 if (!ProfileData || ProfileData->getNumOperands() != 3)
799 ProfileData->getOperand(0),
800 ProfileData->getOperand(2),
801 ProfileData->getOperand(1)
807 BasicBlock *BranchInst::getSuccessorV(
unsigned idx)
const {
810 unsigned BranchInst::getNumSuccessorsV()
const {
813 void BranchInst::setSuccessorV(
unsigned idx,
BasicBlock *B) {
826 assert(!isa<BasicBlock>(Amt) &&
827 "Passed basic block into allocation size parameter! Use other ctor");
829 "Allocation array size is not an integer!");
837 getAISize(Ty->getContext(), ArraySize), InsertBefore) {
839 assert(!Ty->
isVoidTy() &&
"Cannot allocate void!");
846 getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
848 assert(!Ty->
isVoidTy() &&
"Cannot allocate void!");
855 getAISize(Ty->getContext(), 0), InsertBefore) {
857 assert(!Ty->
isVoidTy() &&
"Cannot allocate void!");
864 getAISize(Ty->getContext(), 0), InsertAtEnd) {
866 assert(!Ty->
isVoidTy() &&
"Cannot allocate void!");
873 getAISize(Ty->getContext(), ArraySize), InsertBefore) {
875 assert(!Ty->
isVoidTy() &&
"Cannot allocate void!");
882 getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
884 assert(!Ty->
isVoidTy() &&
"Cannot allocate void!");
893 assert((Align & (Align-1)) == 0 &&
"Alignment is not a power of 2!");
895 "Alignment is greater than MaximumAlignment!");
896 setInstructionSubclassData(
Log2_32(Align) + 1);
897 assert(
getAlignment() == Align &&
"Alignment representation error!");
926 void LoadInst::AssertOK() {
928 "Ptr must have pointer type.");
930 "Alignment required for atomic load");
935 Load, Ptr, InsertBef) {
945 Load, Ptr, InsertAE) {
956 Load, Ptr, InsertBef) {
967 Load, Ptr, InsertAE) {
978 Load, Ptr, InsertBef) {
989 Load, Ptr, InsertAE) {
1002 Load, Ptr, InsertBef) {
1015 Load, Ptr, InsertAE) {
1025 Load, Ptr, InsertBef) {
1030 if (Name && Name[0])
setName(Name);
1035 Load, Ptr, InsertAE) {
1040 if (Name && Name[0])
setName(Name);
1046 Load, Ptr, InsertBef) {
1051 if (Name && Name[0])
setName(Name);
1057 Load, Ptr, InsertAE) {
1062 if (Name && Name[0])
setName(Name);
1066 assert((Align & (Align-1)) == 0 &&
"Alignment is not a power of 2!");
1068 "Alignment is greater than MaximumAlignment!");
1071 assert(
getAlignment() == Align &&
"Alignment representation error!");
1078 void StoreInst::AssertOK() {
1081 "Ptr must have pointer type!");
1084 &&
"Ptr must be a pointer to Val type!");
1086 "Alignment required for atomic load");
1205 assert((Align & (Align-1)) == 0 &&
"Alignment is not a power of 2!");
1207 "Alignment is greater than MaximumAlignment!");
1210 assert(
getAlignment() == Align &&
"Alignment representation error!");
1227 "All operands must be non-null!");
1229 "Ptr must have pointer type!");
1232 &&
"Ptr must be a pointer to Cmp type!");
1235 &&
"Ptr must be a pointer to NewVal type!");
1237 "AtomicCmpXchg instructions must be atomic!");
1248 Init(Ptr, Cmp, NewVal, Ordering, SynchScope);
1259 Init(Ptr, Cmp, NewVal, Ordering, SynchScope);
1266 void AtomicRMWInst::Init(BinOp Operation,
Value *Ptr,
Value *Val,
1276 "All operands must be non-null!");
1278 "Ptr must have pointer type!");
1281 &&
"Ptr must be a pointer to Val type!");
1283 "AtomicRMW instructions must be atomic!");
1294 Init(Operation, Ptr, Val, Ordering, SynchScope);
1305 Init(Operation, Ptr, Val, Ordering, SynchScope);
1334 assert(
NumOperands == 1 + IdxList.
size() &&
"NumOperands not initialized?");
1343 - GEPI.getNumOperands(),
1344 GEPI.getNumOperands()) {
1358 template <
typename IndexTy>
1365 if (IdxList.
empty())
1373 unsigned CurIdx = 1;
1374 for (; CurIdx != IdxList.
size(); ++CurIdx) {
1377 IndexTy Index = IdxList[CurIdx];
1381 return CurIdx == IdxList.
size() ? Agg : 0;
1403 if (!CI->isZero())
return false;
1427 return cast<GEPOperator>(
this)->
isInBounds();
1431 APInt &Offset)
const {
1440 ExtractElementInst::ExtractElementInst(
Value *Val,
Value *Index,
1447 assert(isValidOperands(Val, Index) &&
1448 "Invalid extractelement instruction operands!");
1454 ExtractElementInst::ExtractElementInst(
Value *Val,
Value *Index,
1461 assert(isValidOperands(Val, Index) &&
1462 "Invalid extractelement instruction operands!");
1481 InsertElementInst::InsertElementInst(
Value *Vec,
Value *Elt,
Value *Index,
1488 "Invalid insertelement instruction operands!");
1495 InsertElementInst::InsertElementInst(
Value *Vec,
Value *Elt,
Value *Index,
1502 "Invalid insertelement instruction operands!");
1511 const Value *Index) {
1515 if (Elt->
getType() != cast<VectorType>(Vec->
getType())->getElementType())
1538 "Invalid shuffle vector instruction operands!");
1555 "Invalid shuffle vector instruction operands!");
1564 const Value *Mask) {
1575 if (isa<UndefValue>(Mask) || isa<ConstantAggregateZero>(Mask))
1579 unsigned V1Size = cast<VectorType>(V1->
getType())->getNumElements();
1580 for (
unsigned i = 0, e = MV->getNumOperands(); i != e; ++i) {
1581 if (
ConstantInt *CI = dyn_cast<ConstantInt>(MV->getOperand(i))) {
1582 if (CI->uge(V1Size*2))
1584 }
else if (!isa<UndefValue>(MV->getOperand(i))) {
1592 dyn_cast<ConstantDataSequential>(Mask)) {
1593 unsigned V1Size = cast<VectorType>(V1->
getType())->getNumElements();
1595 if (CDS->getElementAsInteger(i) >= V1Size*2)
1604 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(Mask))
1605 if (CE->getOpcode() == Instruction::UserOp1)
1615 assert(i < Mask->
getType()->getVectorNumElements() &&
"Index out of range");
1617 return CDS->getElementAsInteger(i);
1619 if (isa<UndefValue>(C))
1621 return cast<ConstantInt>(
C)->getZExtValue();
1631 for (
unsigned i = 0; i != NumElts; ++i)
1632 Result.
push_back(CDS->getElementAsInteger(i));
1635 for (
unsigned i = 0; i != NumElts; ++i) {
1637 Result.
push_back(isa<UndefValue>(C) ? -1 :
1638 cast<ConstantInt>(C)->getZExtValue());
1648 const Twine &Name) {
1649 assert(
NumOperands == 2 &&
"NumOperands not initialized?");
1655 assert(Idxs.
size() > 0 &&
"InsertValueInst must have at least one index");
1658 Val->
getType() &&
"Inserted value must match indexed type!");
1669 Indices(IVI.Indices) {
1680 assert(
NumOperands == 1 &&
"NumOperands not initialized?");
1684 assert(Idxs.
size() > 0 &&
"ExtractValueInst must have at least one index");
1692 Indices(EVI.Indices) {
1704 for (
unsigned CurIdx = 0; CurIdx != Idxs.
size(); ++CurIdx) {
1705 unsigned Index = Idxs[CurIdx];
1712 if (
ArrayType *AT = dyn_cast<ArrayType>(Agg)) {
1713 if (Index >= AT->getNumElements())
1715 }
else if (
StructType *
ST = dyn_cast<StructType>(Agg)) {
1716 if (Index >=
ST->getNumElements())
1723 Agg = cast<CompositeType>(Agg)->getTypeAtIndex(Index);
1725 return const_cast<Type*
>(Agg);
1761 (void)LHS; (void)RHS;
1762 assert(LHS->
getType() == RHS->getType() &&
1763 "Binary operator operand types must match!");
1769 "Arithmetic operation should return same type as operands!");
1770 assert(
getType()->isIntOrIntVectorTy() &&
1771 "Tried to create an integer operation on a non-integer type!");
1773 case FAdd:
case FSub:
1776 "Arithmetic operation should return same type as operands!");
1777 assert(
getType()->isFPOrFPVectorTy() &&
1778 "Tried to create a floating-point operation on a "
1779 "non-floating-point type!");
1784 "Arithmetic operation should return same type as operands!");
1786 cast<VectorType>(
getType())->getElementType()->isIntegerTy())) &&
1787 "Incorrect operand type (not integer) for S/UDIV");
1791 "Arithmetic operation should return same type as operands!");
1792 assert(
getType()->isFPOrFPVectorTy() &&
1793 "Incorrect operand type (not floating point) for FDIV");
1798 "Arithmetic operation should return same type as operands!");
1800 cast<VectorType>(
getType())->getElementType()->isIntegerTy())) &&
1801 "Incorrect operand type (not integer) for S/UREM");
1805 "Arithmetic operation should return same type as operands!");
1806 assert(
getType()->isFPOrFPVectorTy() &&
1807 "Incorrect operand type (not floating point) for FREM");
1813 "Shift operation should return same type as operands!");
1814 assert((
getType()->isIntegerTy() ||
1816 cast<VectorType>(
getType())->getElementType()->isIntegerTy())) &&
1817 "Tried to create a shift operation on a non-integral type!");
1822 "Logical operation should return same type as operands!");
1823 assert((
getType()->isIntegerTy() ||
1825 cast<VectorType>(
getType())->getElementType()->isIntegerTy())) &&
1826 "Tried to create a logical operation on a non-integral type!");
1838 "Cannot create binary operator with two operands of differing type!");
1855 Op->
getType(), Name, InsertBefore);
1863 Op->
getType(), Name, InsertAtEnd);
1869 return BinaryOperator::CreateNSWSub(zero, Op, Name, InsertBefore);
1875 return BinaryOperator::CreateNSWSub(zero, Op, Name, InsertAtEnd);
1881 return BinaryOperator::CreateNUWSub(zero, Op, Name, InsertBefore);
1887 return BinaryOperator::CreateNUWSub(zero, Op, Name, InsertAtEnd);
1894 Op->
getType(), Name, InsertBefore);
1901 Op->
getType(), Name, InsertAtEnd);
1908 Op->
getType(), Name, InsertBefore);
1915 Op->
getType(), Name, InsertAtEnd);
1921 if (
const Constant *C = dyn_cast<Constant>(V))
1922 return C->isAllOnesValue();
1928 if (Bop->getOpcode() == Instruction::Sub)
1929 if (
Constant* C = dyn_cast<Constant>(Bop->getOperand(0)))
1930 return C->isNegativeZeroValue();
1936 if (Bop->getOpcode() == Instruction::FSub)
1937 if (
Constant* C = dyn_cast<Constant>(Bop->getOperand(0))) {
1938 if (!IgnoreZeroSign)
1940 return !IgnoreZeroSign ? C->isNegativeZeroValue() : C->isZeroValue();
1954 return cast<BinaryOperator>(BinOp)->
getOperand(1);
1962 return cast<BinaryOperator>(BinOp)->
getOperand(1);
1970 assert(
isNot(BinOp) &&
"getNotArgument on non-'not' instruction!");
1993 Op<0>().
swap(Op<1>());
2006 cast<PossiblyExactOperator>(
this)->
setIsExact(b);
2018 return cast<PossiblyExactOperator>(
this)->
isExact();
2042 void CastInst::anchor() {}
2047 default:
return false;
2048 case Instruction::ZExt:
2049 case Instruction::SExt:
2050 case Instruction::Trunc:
2052 case Instruction::BitCast:
2060 if (
getOpcode() != Instruction::BitCast)
2089 case Instruction::Trunc:
2090 case Instruction::ZExt:
2091 case Instruction::SExt:
2092 case Instruction::FPTrunc:
2093 case Instruction::FPExt:
2094 case Instruction::UIToFP:
2095 case Instruction::SIToFP:
2096 case Instruction::FPToUI:
2097 case Instruction::FPToSI:
2098 case Instruction::AddrSpaceCast:
2101 case Instruction::BitCast:
2103 case Instruction::PtrToInt:
2106 case Instruction::IntToPtr:
2128 Type *DstIntPtrTy) {
2159 const unsigned numCastOps =
2160 Instruction::CastOpsEnd - Instruction::CastOpsBegin;
2161 static const uint8_t CastResults[numCastOps][numCastOps] = {
2167 { 1, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0},
2168 { 8, 1, 9,99,99, 2, 0,99,99,99, 2, 3, 0},
2169 { 8, 0, 1,99,99, 0, 2,99,99,99, 0, 3, 0},
2170 { 0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0},
2171 { 0, 0, 0,99,99, 0, 0,99,99,99, 0, 3, 0},
2172 { 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0},
2173 { 99,99,99, 0, 0,99,99, 0, 0,99,99, 4, 0},
2174 { 99,99,99, 0, 0,99,99, 1, 0,99,99, 4, 0},
2175 { 99,99,99, 2, 2,99,99,10, 2,99,99, 4, 0},
2176 { 1, 0, 0,99,99, 0, 0,99,99,99, 7, 3, 0},
2177 { 99,99,99,99,99,99,99,99,99,11,99,15, 0},
2178 { 5, 5, 5, 6, 6, 5, 5, 6, 6,16, 5, 1,14},
2179 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,13,12},
2184 bool isFirstBitcast = (firstOp == Instruction::BitCast);
2185 bool isSecondBitcast = (secondOp == Instruction::BitCast);
2186 bool chainedBitcast = (SrcTy == DstTy && isFirstBitcast && isSecondBitcast);
2189 if ((isFirstBitcast && isa<VectorType>(SrcTy) != isa<VectorType>(MidTy)) ||
2190 (isSecondBitcast && isa<VectorType>(MidTy) != isa<VectorType>(DstTy)))
2192 if (!chainedBitcast)
return 0;
2194 int ElimCase = CastResults[firstOp-Instruction::CastOpsBegin]
2195 [secondOp-Instruction::CastOpsBegin];
2242 return Instruction::BitCast;
2245 if (!SrcIntPtrTy || DstIntPtrTy != SrcIntPtrTy)
2248 if (MidSize >= PtrSize)
2249 return Instruction::BitCast;
2258 if (SrcSize == DstSize)
2259 return Instruction::BitCast;
2260 else if (SrcSize < DstSize)
2266 return Instruction::ZExt;
2271 return Instruction::BitCast;
2280 if (SrcSize <= PtrSize && SrcSize == DstSize)
2281 return Instruction::BitCast;
2288 return Instruction::AddrSpaceCast;
2289 return Instruction::BitCast;
2301 "Illegal addrspacecast, bitcast sequence!");
2314 "Illegal bitcast, addrspacecast sequence!");
2326 "Illegal inttoptr, bitcast sequence!");
2338 "Illegal bitcast, ptrtoint sequence!");
2352 assert(
castIsValid(op, S, Ty) &&
"Invalid cast!");
2355 case Trunc:
return new TruncInst (S, Ty, Name, InsertBefore);
2356 case ZExt:
return new ZExtInst (S, Ty, Name, InsertBefore);
2357 case SExt:
return new SExtInst (S, Ty, Name, InsertBefore);
2358 case FPTrunc:
return new FPTruncInst (S, Ty, Name, InsertBefore);
2359 case FPExt:
return new FPExtInst (S, Ty, Name, InsertBefore);
2360 case UIToFP:
return new UIToFPInst (S, Ty, Name, InsertBefore);
2361 case SIToFP:
return new SIToFPInst (S, Ty, Name, InsertBefore);
2362 case FPToUI:
return new FPToUIInst (S, Ty, Name, InsertBefore);
2363 case FPToSI:
return new FPToSIInst (S, Ty, Name, InsertBefore);
2364 case PtrToInt:
return new PtrToIntInst (S, Ty, Name, InsertBefore);
2365 case IntToPtr:
return new IntToPtrInst (S, Ty, Name, InsertBefore);
2366 case BitCast:
return new BitCastInst (S, Ty, Name, InsertBefore);
2374 assert(
castIsValid(op, S, Ty) &&
"Invalid cast!");
2377 case Trunc:
return new TruncInst (S, Ty, Name, InsertAtEnd);
2378 case ZExt:
return new ZExtInst (S, Ty, Name, InsertAtEnd);
2379 case SExt:
return new SExtInst (S, Ty, Name, InsertAtEnd);
2380 case FPTrunc:
return new FPTruncInst (S, Ty, Name, InsertAtEnd);
2381 case FPExt:
return new FPExtInst (S, Ty, Name, InsertAtEnd);
2382 case UIToFP:
return new UIToFPInst (S, Ty, Name, InsertAtEnd);
2383 case SIToFP:
return new SIToFPInst (S, Ty, Name, InsertAtEnd);
2384 case FPToUI:
return new FPToUIInst (S, Ty, Name, InsertAtEnd);
2385 case FPToSI:
return new FPToSIInst (S, Ty, Name, InsertAtEnd);
2386 case PtrToInt:
return new PtrToIntInst (S, Ty, Name, InsertAtEnd);
2387 case IntToPtr:
return new IntToPtrInst (S, Ty, Name, InsertAtEnd);
2388 case BitCast:
return new BitCastInst (S, Ty, Name, InsertAtEnd);
2398 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
2399 return Create(Instruction::ZExt, S, Ty, Name, InsertBefore);
2406 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
2407 return Create(Instruction::ZExt, S, Ty, Name, InsertAtEnd);
2414 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
2415 return Create(Instruction::SExt, S, Ty, Name, InsertBefore);
2422 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
2423 return Create(Instruction::SExt, S, Ty, Name, InsertAtEnd);
2430 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
2431 return Create(Instruction::Trunc, S, Ty, Name, InsertBefore);
2438 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
2439 return Create(Instruction::Trunc, S, Ty, Name, InsertAtEnd);
2454 return Create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd);
2458 return Create(Instruction::AddrSpaceCast, S, Ty, Name, InsertAtEnd);
2460 return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
2476 return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
2480 return Create(Instruction::AddrSpaceCast, S, Ty, Name, InsertBefore);
2482 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
2486 bool isSigned,
const Twine &Name,
2489 "Invalid integer cast");
2493 (SrcBits == DstBits ? Instruction::BitCast :
2494 (SrcBits > DstBits ? Instruction::Trunc :
2495 (isSigned ? Instruction::SExt : Instruction::ZExt)));
2496 return Create(opcode, C, Ty, Name, InsertBefore);
2500 bool isSigned,
const Twine &Name,
2507 (SrcBits == DstBits ? Instruction::BitCast :
2508 (SrcBits > DstBits ? Instruction::Trunc :
2509 (isSigned ? Instruction::SExt : Instruction::ZExt)));
2510 return Create(opcode, C, Ty, Name, InsertAtEnd);
2521 (SrcBits == DstBits ? Instruction::BitCast :
2522 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
2523 return Create(opcode, C, Ty, Name, InsertBefore);
2534 (SrcBits == DstBits ? Instruction::BitCast :
2535 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
2536 return Create(opcode, C, Ty, Name, InsertAtEnd);
2545 if (SrcTy == DestTy)
2548 if (
VectorType *SrcVecTy = dyn_cast<VectorType>(SrcTy))
2549 if (
VectorType *DestVecTy = dyn_cast<VectorType>(DestTy))
2550 if (SrcVecTy->getNumElements() == DestVecTy->getNumElements()) {
2552 SrcTy = SrcVecTy->getElementType();
2553 DestTy = DestVecTy->getElementType();
2567 return DestBits == SrcBits;
2577 return DestBits == SrcBits;
2582 return DestBits == SrcBits;
2593 return DestBits == SrcBits;
2606 if (SrcTy == DestTy)
2609 if (
VectorType *SrcVecTy = dyn_cast<VectorType>(SrcTy)) {
2610 if (
VectorType *DestVecTy = dyn_cast<VectorType>(DestTy)) {
2611 if (SrcVecTy->getNumElements() == DestVecTy->getNumElements()) {
2613 SrcTy = SrcVecTy->getElementType();
2614 DestTy = DestVecTy->getElementType();
2619 if (
PointerType *DestPtrTy = dyn_cast<PointerType>(DestTy)) {
2620 if (
PointerType *SrcPtrTy = dyn_cast<PointerType>(SrcTy)) {
2621 return SrcPtrTy->getAddressSpace() == DestPtrTy->getAddressSpace();
2630 if (SrcBits == 0 || DestBits == 0)
2633 if (SrcBits != DestBits)
2651 const Value *Src,
bool SrcIsSigned,
Type *DestTy,
bool DestIsSigned) {
2655 "Only first class types are castable!");
2657 if (SrcTy == DestTy)
2661 if (
VectorType *SrcVecTy = dyn_cast<VectorType>(SrcTy))
2662 if (
VectorType *DestVecTy = dyn_cast<VectorType>(DestTy))
2663 if (SrcVecTy->getNumElements() == DestVecTy->getNumElements()) {
2666 SrcTy = SrcVecTy->getElementType();
2667 DestTy = DestVecTy->getElementType();
2677 if (DestBits < SrcBits)
2679 else if (DestBits > SrcBits) {
2693 assert(DestBits == SrcBits &&
2694 "Casting vector to integer of different width");
2698 "Casting from a value that is not first-class type");
2708 if (DestBits < SrcBits) {
2710 }
else if (DestBits > SrcBits) {
2716 assert(DestBits == SrcBits &&
2717 "Casting vector to floating point of different width");
2722 assert(DestBits == SrcBits &&
2723 "Illegal cast to vector (wrong type or size)");
2728 return AddrSpaceCast;
2736 assert(DestBits == SrcBits &&
"Casting vector of wrong width to X86_MMX");
2774 cast<VectorType>(SrcTy)->getNumElements() : 0;
2776 cast<VectorType>(DstTy)->getNumElements() : 0;
2780 default:
return false;
2781 case Instruction::Trunc:
2783 SrcLength == DstLength && SrcBitSize > DstBitSize;
2784 case Instruction::ZExt:
2786 SrcLength == DstLength && SrcBitSize < DstBitSize;
2787 case Instruction::SExt:
2789 SrcLength == DstLength && SrcBitSize < DstBitSize;
2790 case Instruction::FPTrunc:
2792 SrcLength == DstLength && SrcBitSize > DstBitSize;
2793 case Instruction::FPExt:
2795 SrcLength == DstLength && SrcBitSize < DstBitSize;
2796 case Instruction::UIToFP:
2797 case Instruction::SIToFP:
2799 SrcLength == DstLength;
2800 case Instruction::FPToUI:
2801 case Instruction::FPToSI:
2803 SrcLength == DstLength;
2804 case Instruction::PtrToInt:
2805 if (isa<VectorType>(SrcTy) != isa<VectorType>(DstTy))
2807 if (
VectorType *VT = dyn_cast<VectorType>(SrcTy))
2808 if (VT->getNumElements() != cast<VectorType>(DstTy)->getNumElements())
2812 case Instruction::IntToPtr:
2813 if (isa<VectorType>(SrcTy) != isa<VectorType>(DstTy))
2815 if (
VectorType *VT = dyn_cast<VectorType>(SrcTy))
2816 if (VT->getNumElements() != cast<VectorType>(DstTy)->getNumElements())
2820 case Instruction::BitCast:
2838 case Instruction::AddrSpaceCast:
2849 ) :
CastInst(Ty, Trunc, S, Name, InsertBefore) {
2855 ) :
CastInst(Ty, Trunc, S, Name, InsertAtEnd) {
2861 ) :
CastInst(Ty, ZExt, S, Name, InsertBefore) {
2867 ) :
CastInst(Ty, ZExt, S, Name, InsertAtEnd) {
2872 ) :
CastInst(Ty, SExt, S, Name, InsertBefore) {
2878 ) :
CastInst(Ty, SExt, S, Name, InsertAtEnd) {
2884 ) :
CastInst(Ty, FPTrunc, S, Name, InsertBefore) {
2890 ) :
CastInst(Ty, FPTrunc, S, Name, InsertAtEnd) {
2896 ) :
CastInst(Ty, FPExt, S, Name, InsertBefore) {
2902 ) :
CastInst(Ty, FPExt, S, Name, InsertAtEnd) {
2908 ) :
CastInst(Ty, UIToFP, S, Name, InsertBefore) {
2914 ) :
CastInst(Ty, UIToFP, S, Name, InsertAtEnd) {
2920 ) :
CastInst(Ty, SIToFP, S, Name, InsertBefore) {
2926 ) :
CastInst(Ty, SIToFP, S, Name, InsertAtEnd) {
2932 ) :
CastInst(Ty, FPToUI, S, Name, InsertBefore) {
2938 ) :
CastInst(Ty, FPToUI, S, Name, InsertAtEnd) {
2944 ) :
CastInst(Ty, FPToSI, S, Name, InsertBefore) {
2950 ) :
CastInst(Ty, FPToSI, S, Name, InsertAtEnd) {
2956 ) :
CastInst(Ty, PtrToInt, S, Name, InsertBefore) {
2962 ) :
CastInst(Ty, PtrToInt, S, Name, InsertAtEnd) {
2968 ) :
CastInst(Ty, IntToPtr, S, Name, InsertBefore) {
2974 ) :
CastInst(Ty, IntToPtr, S, Name, InsertAtEnd) {
2980 ) :
CastInst(Ty, BitCast, S, Name, InsertBefore) {
2986 ) :
CastInst(Ty, BitCast, S, Name, InsertAtEnd) {
2992 ) :
CastInst(Ty, AddrSpaceCast, S, Name, InsertBefore) {
2998 ) :
CastInst(Ty, AddrSpaceCast, S, Name, InsertAtEnd) {
3038 if (Op == Instruction::ICmp) {
3058 if (Op == Instruction::ICmp) {
3067 if (
ICmpInst *IC = dyn_cast<ICmpInst>(
this))
3074 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(
this))
3075 return IC->isCommutative();
3080 if (
const ICmpInst *IC = dyn_cast<ICmpInst>(
this))
3081 return IC->isEquality();
3239 switch (predicate) {
3240 default:
return false;
3247 switch (predicate) {
3248 default:
return false;
3255 switch (predicate) {
3256 default:
return false;
3264 switch (predicate) {
3265 default:
return false;
3274 default:
return false;
3284 default:
return false;
3294 assert(Value && Default && NumReserved);
3295 ReservedSpace = NumReserved;
3299 OperandList[0] = Value;
3310 0, 0, InsertBefore) {
3311 init(Value, Default, 2+NumCases*2);
3321 0, 0, InsertAtEnd) {
3322 init(Value, Default, 2+NumCases*2);
3332 OL[i+1] = InOL[i+1];
3347 if (OpNo+2 > ReservedSpace)
3350 assert(OpNo+1 < ReservedSpace &&
"Growing didn't work!");
3351 NumOperands = OpNo+2;
3352 CaseIt Case(
this, NewCaseIdx);
3362 assert(2 + idx*2 <
getNumOperands() &&
"Case index out of range!!!");
3368 if (2 + (idx + 1) * 2 != NumOps) {
3369 OL[2 + idx * 2] = OL[NumOps - 2];
3370 OL[2 + idx * 2 + 1] = OL[NumOps - 1];
3374 OL[NumOps-2].
set(0);
3375 OL[NumOps-2+1].
set(0);
3376 NumOperands = NumOps-2;
3382 void SwitchInst::growOperands() {
3384 unsigned NumOps = e*3;
3386 ReservedSpace = NumOps;
3389 for (
unsigned i = 0; i != e; ++i) {
3390 NewOps[i] = OldOps[i];
3392 OperandList = NewOps;
3393 Use::zap(OldOps, OldOps + e,
true);
3397 BasicBlock *SwitchInst::getSuccessorV(
unsigned idx)
const {
3400 unsigned SwitchInst::getNumSuccessorsV()
const {
3403 void SwitchInst::setSuccessorV(
unsigned idx,
BasicBlock *B) {
3411 void IndirectBrInst::init(
Value *Address,
unsigned NumDests) {
3413 "Address of indirectbr must be a pointer");
3414 ReservedSpace = 1+NumDests;
3418 OperandList[0] = Address;
3425 void IndirectBrInst::growOperands() {
3427 unsigned NumOps = e*2;
3429 ReservedSpace = NumOps;
3432 for (
unsigned i = 0; i != e; ++i)
3433 NewOps[i] = OldOps[i];
3434 OperandList = NewOps;
3435 Use::zap(OldOps, OldOps + e,
true);
3438 IndirectBrInst::IndirectBrInst(
Value *Address,
unsigned NumCases,
3441 0, 0, InsertBefore) {
3442 init(Address, NumCases);
3445 IndirectBrInst::IndirectBrInst(
Value *Address,
unsigned NumCases,
3448 0, 0, InsertAtEnd) {
3449 init(Address, NumCases);
3454 allocHungoffUses(IBI.getNumOperands()),
3455 IBI.getNumOperands()) {
3470 if (OpNo+1 > ReservedSpace)
3473 assert(OpNo < ReservedSpace &&
"Growing didn't work!");
3474 NumOperands = OpNo+1;
3475 OperandList[OpNo] = DestBB;
3481 assert(idx <
getNumOperands()-1 &&
"Successor index out of range!");
3487 OL[idx+1] = OL[NumOps-1];
3490 OL[NumOps-1].
set(0);
3491 NumOperands = NumOps-1;
3494 BasicBlock *IndirectBrInst::getSuccessorV(
unsigned idx)
const {
3497 unsigned IndirectBrInst::getNumSuccessorsV()
const {
3500 void IndirectBrInst::setSuccessorV(
unsigned idx,
BasicBlock *B) {
static int getMaskValue(Constant *Mask, unsigned i)
IntToPtrInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
static Instruction * createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize, Function *MallocF, const Twine &Name)
BasicBlock * getSuccessor(unsigned i) const
void removeAttribute(unsigned i, Attribute attr)
removeAttribute - removes the attribute from the list of attributes.
void setAttributes(const AttributeSet &Attrs)
virtual LandingPadInst * clone_impl() const
void push_back(const T &Elt)
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
virtual PHINode * clone_impl() const
void setHasNoSignedWrap(bool b=true)
Abstract base class of comparison instructions.
static IntegerType * getInt1Ty(LLVMContext &C)
AtomicOrdering getOrdering() const
Returns the ordering constraint on this cmpxchg.
virtual StoreInst * clone_impl() const
static bool IsConstantOne(Value *val)
IsConstantOne - Return true only if val is constant int 1.
PointerIntPair< User *, 1, unsigned > UserRef
static const Value * getFNegArgument(const Value *BinOp)
void init(BinaryOps iType)
AddrSpaceCastInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
SynchronizationScope getSynchScope() const
void swapSuccessors()
Swap the successors of this branch instruction.
unsigned getScalarSizeInBits()
static bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
The main container class for the LLVM Intermediate Representation.
void setOrdering(AtomicOrdering Ordering)
Set the ordering constraint on this RMW.
void setAlignment(unsigned Align)
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=0)
Use * allocHungoffUses(unsigned) const
virtual LoadInst * clone_impl() const
void setSynchScope(SynchronizationScope xthread)
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
This class represents zero extension of integer types.
unsigned getNumOperands() const
unsigned getNumSuccessors() const
void setSuccessor(BasicBlock *S)
Sets the new successor for current case.
static bool isOrdered(unsigned short predicate)
Determine if the predicate is an ordered operation.
void addCase(ConstantInt *OnVal, BasicBlock *Dest)
virtual AtomicRMWInst * clone_impl() const
Predicate getInversePredicate() const
Return the inverse of the instruction's predicate.
bool indexValid(const Value *V) const
Function * getCalledFunction() const
virtual TruncInst * clone_impl() const
Clone an identical TruncInst.
bool isSigned() const
Determine if this instruction is using a signed comparison.
0 1 0 0 True if ordered and less than
void setOrdering(AtomicOrdering Ordering)
Set the ordering constraint on this cmpxchg.
1 1 1 0 True if unordered or not equal
bool isPtrOrPtrVectorTy() const
const Function * getParent() const
Return the enclosing method, or null if none.
void setSuccessor(unsigned i, BasicBlock *NewSucc)
FPTruncInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
MDNode - a tuple of other values.
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
This class represents a sign extension of integer types.
virtual FPTruncInst * clone_impl() const
Clone an identical FPTruncInst.
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
static Instruction * CreateFree(Value *Source, Instruction *InsertBefore)
CreateFree - Generate the IR for a call to the builtin free function.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
FenceInst(LLVMContext &C, AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread, Instruction *InsertBefore=0)
void setSynchScope(SynchronizationScope SynchScope)
virtual VAArgInst * clone_impl() const
virtual void anchor() LLVM_OVERRIDE
bool isEquality() const
Determine if this is an equals/not equals predicate.
static BinaryOperator * CreateNUWNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=0)
FPToUIInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
static MDNode * get(LLVMContext &Context, ArrayRef< Value * > Vals)
virtual InsertValueInst * clone_impl() const
block_iterator block_end()
void swap(OwningPtr< T > &a, OwningPtr< T > &b)
void setCallingConv(CallingConv::ID CC)
Value * getOperand(unsigned i) const LLVM_READONLY
getOperand - Return specified operand.
bool isArrayAllocation() const
1 0 0 1 True if unordered or equal
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
static const Value * getNegArgument(const Value *BinOp)
This class represents a conversion between pointers from one address space to another.
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy)
Determine if a cast is valid without creating one.
void push_back(NodeTy *val)
virtual CallInst * clone_impl() const
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
unsigned getSubclassDataFromInstruction() const
Base class of casting instructions.
#define llvm_unreachable(msg)
virtual SelectInst * clone_impl() const
void setHasNoUnsignedWrap(bool b=true)
void setOrdering(AtomicOrdering Ordering)
void setIsInBounds(bool b=true)
static CastInst * CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Create a Trunc or BitCast cast instruction.
Instruction * getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
static bool isNoopCast(Instruction::CastOps Opcode, Type *SrcTy, Type *DstTy, Type *IntPtrTy)
Determine if the described cast is a no-op cast.
virtual BranchInst * clone_impl() const
0 1 0 1 True if ordered and less than or equal
virtual ShuffleVectorInst * clone_impl() const
Type * getAllocatedType() const
void setName(const Twine &Name)
static ConstantInt * ExtractElement(Constant *V, Constant *Idx)
LandingPadInst * getLandingPadInst() const
block_iterator block_begin()
unsigned getNumSuccessors() const
virtual SIToFPInst * clone_impl() const
Clone an identical SIToFPInst.
SynchronizationScope getSynchScope() const
This class represents a cast from a pointer to an integer.
static bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
void setAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
AtomicOrdering getOrdering() const
Returns the ordering constraint on this RMW.
void setCleanup(bool V)
setCleanup - Indicate that this landingpad instruction is a cleanup.
void setValue(ConstantInt *V)
Sets the new value for current case.
virtual AddrSpaceCastInst * clone_impl() const
Clone an identical AddrSpaceCastInst.
virtual PtrToIntInst * clone_impl() const
Clone an identical PtrToIntInst.
Represents a floating point comparison operator.
BasicBlock * getSuccessor(unsigned i) const
bool isIntegerCast() const
Determine if this is an integer-only cast.
static LandingPadInst * Create(Type *RetTy, Value *PersonalityFn, unsigned NumReservedClauses, const Twine &NameStr="", Instruction *InsertBefore=0)
bool isFirstClassType() const
This class represents a no-op cast from one type to another.
bool isFloatingPointTy() const
virtual InsertElementInst * clone_impl() const
Predicate getUnsignedPredicate() const
Return the unsigned version of the predicate.
virtual SwitchInst * clone_impl() const
virtual ZExtInst * clone_impl() const
Clone an identical ZExtInst.
void replaceAllUsesWith(Value *V)
This class represents a cast from floating point to signed integer.
unsigned getNumElements() const
Return the number of elements in the Vector type.
void addClause(Value *ClauseVal)
addClause - Add a catch or filter clause to the landing pad.
This class represents a truncation of integer types.
Type * getElementType() const
size_t size() const
size - Get the array size.
static const Value * getNotArgument(const Value *BinOp)
bool isInBounds() const
isInBounds - Determine whether the GEP has the inbounds flag.
void addAttribute(unsigned i, Attribute::AttrKind attr)
addAttribute - adds the attribute to the list of attributes.
unsigned getNumIncomingValues() const
AllocaInst(Type *Ty, Value *ArraySize=0, const Twine &Name="", Instruction *InsertBefore=0)
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Construct any of the CastInst subclasses.
void removeAttribute(unsigned i, Attribute attr)
removeAttribute - removes the attribute from the list of attributes.
bool isX86_MMXTy() const
isX86_MMXTy - Return true if this is X86 MMX.
bool isIntOrIntVectorTy() const
SIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
initializer< Ty > init(const Ty &Val)
bool isLosslessCast() const
Determine if this is a lossless cast.
unsigned getAlignment() const
unsigned getCaseIndex() const
Returns number of current case.
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=0)
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeSet AttributeList)
SynchronizationScope getSynchScope() const
LLVM Basic Block Representation.
Value * hasConstantValue() const
Instruction * getInstruction() const
virtual UnreachableInst * clone_impl() const
LLVM Constant Representation.
PointerType * getType() const
static Use * initTags(Use *Start, Use *Stop)
virtual SExtInst * clone_impl() const
Clone an identical SExtInst.
virtual IndirectBrInst * clone_impl() const
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
unsigned getAlignment() const
virtual ICmpInst * clone_impl() const
Clone an identical ICmpInst.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
static CastInst * CreateFPCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
virtual ResumeInst * clone_impl() const
bool paramHasAttr(unsigned i, Attribute::AttrKind A) const
Determine whether the call or the callee has the given attributes.
static bool isBitCastable(Type *SrcTy, Type *DestTy)
Check whether a bitcast between these types is valid.
bool hasAllZeroIndices() const
static Type * getVoidTy(LLVMContext &C)
ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const Twine &NameStr="", Instruction *InsertBefor=0)
Type * getTypeAtIndex(const Value *V)
const InstListType & getInstList() const
Return the underlying instruction list container.
bool isFalseWhenEqual() const
Determine if this is false when both operands are the same.
Represent an integer comparison operator.
unsigned getBitWidth() const
Return the number of bits in the APInt.
NUW NUW NUW NUW Exact static Exact BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=0)
Value * getOperand(unsigned i) const
0 1 1 1 True if ordered (no nans)
bool isCommutative() const
virtual AllocaInst * clone_impl() const
static bool isNot(const Value *V)
void addAttribute(unsigned i, Attribute::AttrKind attr)
addAttribute - adds the attribute to the list of attributes.
Predicate getPredicate() const
Return the predicate for this instruction.
static CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast or a PtrToInt cast instruction.
virtual AtomicCmpXchgInst * clone_impl() const
bool empty() const
empty - Check if the array is empty.
Constant * getAggregateElement(unsigned Elt) const
void setAlignment(unsigned Align)
This class represents a cast from an integer to a pointer.
static Constant * getAllOnesValue(Type *Ty)
Get the all ones value.
1 1 1 1 Always true (always folded)
void append(in_iter in_start, in_iter in_end)
static CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Create a ZExt or BitCast cast instruction.
void setTailCall(bool isTC=true)
static UndefValue * get(Type *T)
bool isCommutative() const
Determine if this CmpInst is commutative.
void setAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
bool hasAllConstantIndices() const
LLVMContext & getContext() const
All values hold a context through their type.
bool isFPOrFPVectorTy() const
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
bool hasNoSignedWrap() const
hasNoSignedWrap - Determine whether the no signed wrap flag is set.
1 1 0 1 True if unordered, less than, or equal
void setMetadata(unsigned KindID, MDNode *Node)
void swapOperands()
Swap the operands and adjust predicate accordingly to retain the same comparison. ...
unsigned char SubclassOptionalData
virtual InvokeInst * clone_impl() const
unsigned getNumSuccessors() const
float getFPAccuracy() const
Get the maximum error permitted by this operation in ULPs. An accuracy of 0.0 means that the operatio...
CallingConv::ID getCallingConv() const
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
BasicBlock * getSuccessor(unsigned i) const
void setIsExact(bool b=true)
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=0)
ZExtInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
bool isConditional() const
static CastInst * CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Create a SExt or BitCast cast instruction.
0 0 1 0 True if ordered and greater than
BinaryOps getOpcode() const
virtual FPToSIInst * clone_impl() const
Clone an identical FPToSIInst.
BasicBlock * getUnwindDest() const
AtomicOrdering getOrdering() const
Returns the ordering effect of this store.
virtual ReturnInst * clone_impl() const
static PointerType * getUnqual(Type *ElementType)
Class for constant integers.
Value * getIncomingValue(unsigned i) const
unsigned getVectorNumElements() const
UnreachableInst(LLVMContext &C, Instruction *InsertBefore=0)
AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal, AtomicOrdering Ordering, SynchronizationScope SynchScope, Instruction *InsertBefore=0)
unsigned getNumSuccessors() const
virtual BitCastInst * clone_impl() const
Clone an identical BitCastInst.
virtual IntToPtrInst * clone_impl() const
Clone an identical IntToPtrInst.
1 1 0 0 True if unordered or less than
bool isStaticAlloca() const
MDNode * getMetadata(unsigned KindID) const
static bool isCastable(Type *SrcTy, Type *DestTy)
Check whether it is valid to call getCastOpcode for these types.
LoadInst(Value *Ptr, const Twine &NameStr, Instruction *InsertBefore)
bool isTrueWhenEqual() const
Determine if this is true when both operands are the same.
This class represents a cast from floating point to unsigned integer.
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.
Predicate getSwappedPredicate() const
Return the predicate as if the operands were swapped.
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
Function * getCalledFunction() const
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
bool isExact() const
isExact - Determine whether the exact flag is set.
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
BinOp getOperation() const
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
unsigned Log2_32(uint32_t Value)
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
SynchronizationScope getSynchScope() const
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list. Since attribute list...
static bool isNeg(const Value *V)
Class for arbitrary precision integers.
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, const Twine &Name, Instruction *InsertBefore)
static Type * getIndexedTypeInternal(Type *Ptr, ArrayRef< IndexTy > IdxList)
AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, AtomicOrdering Ordering, SynchronizationScope SynchScope, Instruction *InsertBefore=0)
PtrToIntInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
FCmpInst(Instruction *InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-before-instruction semantics.
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.
virtual GetElementPtrInst * clone_impl() const
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
Value * getCondition() const
const AttributeSet & getAttributes() const
static bool isConstantAllOnes(const Value *V)
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
static Instruction * createFree(Value *Source, Instruction *InsertBefore, BasicBlock *InsertAtEnd)
static CmpInst * Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, const Twine &Name="", Instruction *InsertBefore=0)
Create a CmpInst.
BitCastInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
BasicBlock * getSuccessor(unsigned idx) const
Value * getCondition() const
const AttributeSet & getAttributes() const
BasicBlock * getDefaultDest() const
AttributeSet addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Add an attribute to the attribute set at the given index. Since attribute sets are immutable...
bool isAggregateType() const
virtual FCmpInst * clone_impl() const
Clone an identical FCmpInst.
unsigned getNumSuccessors() const
static IntegerType * getInt32Ty(LLVMContext &C)
FPExtInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
unsigned greater or equal
unsigned getAlignment() const
static bool isFNeg(const Value *V, bool IgnoreZeroSign=false)
void setOperation(BinOp Operation)
static Instruction::CastOps getCastOpcode(const Value *Val, bool SrcIsSigned, Type *Ty, bool DstIsSigned)
Infer the opcode for cast operand and type.
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
static Constant * getZeroValueForNegation(Type *Ty)
This class represents a cast unsigned integer to floating point.
0 1 1 0 True if ordered and operands are unequal
float convertToFloat() const
virtual BinaryOperator * clone_impl() const LLVM_OVERRIDE
static ConstantRange makeConstantRange(Predicate pred, const APInt &C)
Make a ConstantRange for a relation with a constant value.
unsigned getNumSuccessors() const
VAArgInst(Value *List, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
VectorType * getType() const
const Type * getScalarType() const
bool paramHasAttr(unsigned i, Attribute::AttrKind A) const
Determine whether the call or the callee has the given attributes.
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=0)
unsigned getPrimitiveSizeInBits() const
void removeCase(CaseIt i)
1 0 1 0 True if unordered or greater than
virtual FenceInst * clone_impl() const
virtual FPToUIInst * clone_impl() const
Clone an identical FPToUIInst.
unsigned getNumCases() const
void addDestination(BasicBlock *Dest)
const APFloat & getValueAPF() const
This class represents a cast from signed integer to floating point.
bool isUnsigned() const
Determine if this instruction is using an unsigned comparison.
void setAttributes(const AttributeSet &Attrs)
static Type * getIndexedType(Type *Ptr, ArrayRef< Value * > IdxList)
virtual FPExtInst * clone_impl() const
Clone an identical FPExtInst.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
const BasicBlock & front() const
This class represents a truncation of floating point types.
0 0 0 1 True if ordered and equal
FPToSIInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
LLVM Value Representation.
void setAlignment(unsigned Align)
bool hasNoUnsignedWrap() const
hasNoUnsignedWrap - Determine whether the no unsigned wrap flag is set.
1 0 1 1 True if unordered, greater than, or equal
Use * allocHungoffUses(unsigned) const
const Value * getArraySize() const
static bool isUnordered(unsigned short predicate)
Determine if the predicate is an unordered operation.
static Value * getAISize(LLVMContext &Context, Value *Amt)
StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore)
UIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
void setSynchScope(SynchronizationScope SynchScope)
Predicate getSignedPredicate() const
Return the signed version of the predicate.
ICmpInst(Instruction *InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-before-instruction semantics.
CallingConv::ID getCallingConv() const
virtual UIToFPInst * clone_impl() const
Clone an identical UIToFPInst.
static BinaryOperator * CreateFNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=0)
static BinaryOperator * CreateNSWNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=0)
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
TruncInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", Instruction *InsertBefore=0)
This class represents an extension of floating point types.
0 0 1 1 True if ordered and greater than or equal
SynchronizationScope getSynchScope() const
SExtInst(Value *S, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=0)
Constructor with insert-before-instruction semantics.
unsigned getNumSuccessors() const
void removeDestination(unsigned i)
const BasicBlock * getParent() const
static Instruction * CreateMalloc(Instruction *InsertBefore, Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize=0, Function *MallocF=0, const Twine &Name="")
SmallVector< int, 16 > getShuffleMask() const
0 0 0 0 Always false (always folded)
LLVMContext & getContext() const
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
static void zap(Use *Start, const Use *Stop, bool del=false)
static const char * areInvalidOperands(Value *Cond, Value *True, Value *False)