llvm.org GIT mirror llvm / 0973b7d
Reduce dyn_cast<> to isa<> or cast<> where possible. No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234586 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 4 years ago
22 changed file(s) with 62 addition(s) and 66 deletion(s). Raw diff Collapse all Expand all
693693 // We're running this loop for once for each value queried resulting in a
694694 // runtime of ~O(#assumes * #values).
695695
696 assert(isa(I) &&
697 dyn_cast(I)->getIntrinsicID() == Intrinsic::assume &&
696 assert(I->getCalledFunction()->getIntrinsicID() == Intrinsic::assume &&
698697 "must be an assume intrinsic");
699
698
700699 Value *Arg = I->getArgOperand(0);
701700
702701 if (Arg == V && isValidAssumeForContext(I, Q)) {
19831983 N0IsConst = isConstantSplatVector(N0.getNode(), ConstValue0);
19841984 N1IsConst = isConstantSplatVector(N1.getNode(), ConstValue1);
19851985 } else {
1986 N0IsConst = dyn_cast(N0) != nullptr;
1987 ConstValue0 = N0IsConst ? (dyn_cast(N0))->getAPIntValue()
1988 : APInt();
1989 N1IsConst = dyn_cast(N1) != nullptr;
1990 ConstValue1 = N1IsConst ? (dyn_cast(N1))->getAPIntValue()
1991 : APInt();
1986 N0IsConst = isa(N0);
1987 if (N0IsConst)
1988 ConstValue0 = cast(N0)->getAPIntValue();
1989 N1IsConst = isa(N1);
1990 if (N1IsConst)
1991 ConstValue1 = cast(N1)->getAPIntValue();
19921992 }
19931993
19941994 // fold (mul c1, c2) -> c1*c2
1166111661 // type.
1166211662 if (V->getOperand(0).getValueType() != NVT)
1166311663 return SDValue();
11664 unsigned Idx = dyn_cast(N->getOperand(1))->getZExtValue();
11664 unsigned Idx = N->getConstantOperandVal(1);
1166511665 unsigned NumElems = NVT.getVectorNumElements();
1166611666 assert((Idx % NumElems) == 0 &&
1166711667 "IDX in concat is not a multiple of the result vector length.");
625625 // Add a leading constant argument with the Flags and the calling convention
626626 // masked together
627627 CallingConv::ID CallConv = CS.getCallingConv();
628 int Flags = dyn_cast(CS.getArgument(2))->getZExtValue();
628 int Flags = cast(CS.getArgument(2))->getZExtValue();
629629 assert(Flags == 0 && "not expected to be used");
630630 Ops.push_back(DAG.getTargetConstant(StackMaps::ConstantOp, MVT::i64));
631631 Ops.push_back(
315315
316316 #define IMPLEMENT_VECTOR_FCMP(OP) \
317317 case Type::VectorTyID: \
318 if(dyn_cast(Ty)->getElementType()->isFloatTy()) { \
318 if (cast(Ty)->getElementType()->isFloatTy()) { \
319319 IMPLEMENT_VECTOR_FCMP_T(OP, Float); \
320320 } else { \
321321 IMPLEMENT_VECTOR_FCMP_T(OP, Double); \
362362
363363 #define MASK_VECTOR_NANS(TY, X,Y, FLAG) \
364364 if (TY->isVectorTy()) { \
365 if (dyn_cast(TY)->getElementType()->isFloatTy()) { \
365 if (cast(TY)->getElementType()->isFloatTy()) { \
366366 MASK_VECTOR_NANS_T(X, Y, Float, FLAG) \
367367 } else { \
368368 MASK_VECTOR_NANS_T(X, Y, Double, FLAG) \
535535 if(Ty->isVectorTy()) {
536536 assert(Src1.AggregateVal.size() == Src2.AggregateVal.size());
537537 Dest.AggregateVal.resize( Src1.AggregateVal.size() );
538 if(dyn_cast(Ty)->getElementType()->isFloatTy()) {
538 if (cast(Ty)->getElementType()->isFloatTy()) {
539539 for( size_t _i=0;_i
540540 Dest.AggregateVal[_i].IntVal = APInt(1,
541541 ( (Src1.AggregateVal[_i].FloatVal ==
566566 if(Ty->isVectorTy()) {
567567 assert(Src1.AggregateVal.size() == Src2.AggregateVal.size());
568568 Dest.AggregateVal.resize( Src1.AggregateVal.size() );
569 if(dyn_cast(Ty)->getElementType()->isFloatTy()) {
569 if (cast(Ty)->getElementType()->isFloatTy()) {
570570 for( size_t _i=0;_i
571571 Dest.AggregateVal[_i].IntVal = APInt(1,
572572 ( (Src1.AggregateVal[_i].FloatVal !=
712712 // Macros to choose appropriate TY: float or double and run operation
713713 // execution
714714 #define FLOAT_VECTOR_OP(OP) { \
715 if (dyn_cast(Ty)->getElementType()->isFloatTy()) \
715 if (cast(Ty)->getElementType()->isFloatTy()) \
716716 FLOAT_VECTOR_FUNCTION(OP, FloatVal) \
717717 else { \
718 if (dyn_cast(Ty)->getElementType()->isDoubleTy()) \
718 if (cast(Ty)->getElementType()->isDoubleTy()) \
719719 FLOAT_VECTOR_FUNCTION(OP, DoubleVal) \
720720 else { \
721721 dbgs() << "Unhandled type for OP instruction: " << *Ty << "\n"; \
744744 case Instruction::FMul: FLOAT_VECTOR_OP(*) break;
745745 case Instruction::FDiv: FLOAT_VECTOR_OP(/) break;
746746 case Instruction::FRem:
747 if (dyn_cast(Ty)->getElementType()->isFloatTy())
747 if (cast(Ty)->getElementType()->isFloatTy())
748748 for (unsigned i = 0; i < R.AggregateVal.size(); ++i)
749749 R.AggregateVal[i].FloatVal =
750750 fmod(Src1.AggregateVal[i].FloatVal, Src2.AggregateVal[i].FloatVal);
751751 else {
752 if (dyn_cast(Ty)->getElementType()->isDoubleTy())
752 if (cast(Ty)->getElementType()->isDoubleTy())
753753 for (unsigned i = 0; i < R.AggregateVal.size(); ++i)
754754 R.AggregateVal[i].DoubleVal =
755755 fmod(Src1.AggregateVal[i].DoubleVal, Src2.AggregateVal[i].DoubleVal);
20392039 /// to CurRec's name.
20402040 Init *llvm::QualifyName(Record &CurRec, MultiClass *CurMultiClass,
20412041 Init *Name, const std::string &Scoper) {
2042 RecTy *Type = dyn_cast(Name)->getType();
2042 RecTy *Type = cast(Name)->getType();
20432043
20442044 BinOpInit *NewName =
20452045 BinOpInit::get(BinOpInit::STRCONCAT,
847847 // MOV X0, WideImmediate
848848 // LDR X2, [BaseReg, X0]
849849 if (isa(RHS)) {
850 int64_t ImmOff = (int64_t)dyn_cast(RHS)->getZExtValue();
850 int64_t ImmOff = (int64_t)cast(RHS)->getZExtValue();
851851 unsigned Scale = Log2_32(Size);
852852 // Skip the immediate can be seleced by load/store addressing mode.
853853 // Also skip the immediate can be encoded by a single ADD (SUB is also
131131 }
132132
133133 case ISD::FrameIndex: {
134 int FI = dyn_cast(Node)->getIndex();
134 int FI = cast(Node)->getIndex();
135135 EVT VT = Node->getValueType(0);
136136 SDValue TFI = CurDAG->getTargetFrameIndex(FI, VT);
137137 unsigned Opc = BPF::MOV_rr;
21052105 // is Big Endian.
21062106 unsigned OpIdx = NElts - i - 1;
21072107 SDValue Operand = BVN->getOperand(OpIdx);
2108 if (dyn_cast(Operand))
2108 if (isa(Operand))
21092109 // This operand is already in ConstVal.
21102110 continue;
21112111
439439
440440 bool MipsFastISel::computeCallAddress(const Value *V, Address &Addr) {
441441 const GlobalValue *GV = dyn_cast(V);
442 if (GV && isa(GV) && dyn_cast(GV)->isIntrinsic())
442 if (GV && isa(GV) && cast(GV)->isIntrinsic())
443443 return false;
444444 if (!GV)
445445 return false;
17641764 case Type::IntegerTyID: {
17651765 const Type *ETy = CPV->getType();
17661766 if (ETy == Type::getInt8Ty(CPV->getContext())) {
1767 unsigned char c =
1768 (unsigned char)(dyn_cast(CPV))->getZExtValue();
1767 unsigned char c = (unsigned char)cast(CPV)->getZExtValue();
17691768 ptr = &c;
17701769 aggBuffer->addBytes(ptr, 1, Bytes);
17711770 } else if (ETy == Type::getInt16Ty(CPV->getContext())) {
1772 short int16 = (short)(dyn_cast(CPV))->getZExtValue();
1771 short int16 = (short)cast(CPV)->getZExtValue();
17731772 ptr = (unsigned char *)&int16;
17741773 aggBuffer->addBytes(ptr, 2, Bytes);
17751774 } else if (ETy == Type::getInt32Ty(CPV->getContext())) {
38923892 const SDNode *left = N0.getOperand(0).getNode();
38933893 const SDNode *right = N0.getOperand(1).getNode();
38943894
3895 if (dyn_cast(left) || dyn_cast(right))
3895 if (isa(left) || isa(right))
38963896 opIsLive = true;
38973897
38983898 if (!opIsLive)
6969
7070 // srcAddr and dstAddr are expected to be pointer types,
7171 // so no check is made here.
72 unsigned srcAS = dyn_cast(srcAddr->getType())->getAddressSpace();
73 unsigned dstAS = dyn_cast(dstAddr->getType())->getAddressSpace();
72 unsigned srcAS = cast(srcAddr->getType())->getAddressSpace();
73 unsigned dstAS = cast(dstAddr->getType())->getAddressSpace();
7474
7575 // Cast pointers to (char *)
7676 srcAddr = builder.CreateBitCast(srcAddr, Type::getInt8PtrTy(Context, srcAS));
107107 origBB->getTerminator()->setSuccessor(0, loopBB);
108108 IRBuilder<> builder(origBB, origBB->getTerminator());
109109
110 unsigned dstAS = dyn_cast(dstAddr->getType())->getAddressSpace();
110 unsigned dstAS = cast(dstAddr->getType())->getAddressSpace();
111111
112112 // Cast pointer to the type of value getting stored
113113 dstAddr =
344344 unsigned NOps = N->getNumOperands();
345345 for (unsigned i = 0; i < NOps; i++) {
346346 // XXX: Why is this here?
347 if (dyn_cast(N->getOperand(i))) {
347 if (isa(N->getOperand(i))) {
348348 IsRegSeq = false;
349349 break;
350350 }
357357
358358 def mskor_global : PatFrag<(ops node:$val, node:$ptr),
359359 (AMDGPUstore_mskor node:$val, node:$ptr), [{
360 return dyn_cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;
360 return cast(N)->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS;
361361 }]>;
362362
363363
388388
389389 def mskor_flat : PatFrag<(ops node:$val, node:$ptr),
390390 (AMDGPUstore_mskor node:$val, node:$ptr), [{
391 return dyn_cast(N)->getAddressSpace() == AMDGPUAS::FLAT_ADDRESS;
391 return cast(N)->getAddressSpace() == AMDGPUAS::FLAT_ADDRESS;
392392 }]>;
393393
394394 class global_binary_atomic_op : PatFrag<
18101810
18111811 BuildVector = CompactSwizzlableVector(DAG, BuildVector, SwizzleRemap);
18121812 for (unsigned i = 0; i < 4; i++) {
1813 unsigned Idx = dyn_cast(Swz[i])->getZExtValue();
1813 unsigned Idx = cast(Swz[i])->getZExtValue();
18141814 if (SwizzleRemap.find(Idx) != SwizzleRemap.end())
18151815 Swz[i] = DAG.getConstant(SwizzleRemap[Idx], MVT::i32);
18161816 }
18181818 SwizzleRemap.clear();
18191819 BuildVector = ReorganizeVector(DAG, BuildVector, SwizzleRemap);
18201820 for (unsigned i = 0; i < 4; i++) {
1821 unsigned Idx = dyn_cast(Swz[i])->getZExtValue();
1821 unsigned Idx = cast(Swz[i])->getZExtValue();
18221822 if (SwizzleRemap.find(Idx) != SwizzleRemap.end())
18231823 Swz[i] = DAG.getConstant(SwizzleRemap[Idx], MVT::i32);
18241824 }
161161 Value *SamplerId = I.getArgOperand(2);
162162
163163 unsigned TextureType =
164 dyn_cast(I.getArgOperand(3))->getZExtValue();
164 cast(I.getArgOperand(3))->getZExtValue();
165165
166166 unsigned SrcSelect[4] = { 0, 1, 2, 3 };
167167 unsigned CT[4] = {1, 1, 1, 1};
185185 Value *SamplerId = I.getArgOperand(5);
186186
187187 unsigned TextureType =
188 dyn_cast(I.getArgOperand(6))->getZExtValue();
188 cast(I.getArgOperand(6))->getZExtValue();
189189
190190 unsigned SrcSelect[4] = { 0, 1, 2, 3 };
191191 unsigned CT[4] = {1, 1, 1, 1};
1196911969 // Now we have only mask extension
1197011970 assert(InVT.getVectorElementType() == MVT::i1);
1197111971 SDValue Cst = DAG.getTargetConstant(1, ExtVT.getScalarType());
11972 const Constant *C = (dyn_cast(Cst))->getConstantIntValue();
11972 const Constant *C = cast(Cst)->getConstantIntValue();
1197311973 SDValue CP = DAG.getConstantPool(C, TLI.getPointerTy());
1197411974 unsigned Alignment = cast(CP)->getAlignment();
1197511975 SDValue Ld = DAG.getLoad(Cst.getValueType(), DL, DAG.getEntryNode(), CP,
1204512045 }
1204612046
1204712047 SDValue Cst = DAG.getTargetConstant(1, InVT.getVectorElementType());
12048 const Constant *C = (dyn_cast(Cst))->getConstantIntValue();
12048 const Constant *C = cast(Cst)->getConstantIntValue();
1204912049 SDValue CP = DAG.getConstantPool(C, getPointerTy());
1205012050 unsigned Alignment = cast(CP)->getAlignment();
1205112051 SDValue Ld = DAG.getLoad(Cst.getValueType(), DL, DAG.getEntryNode(), CP,
1528615286 }
1528715287 case PREFETCH: {
1528815288 SDValue Hint = Op.getOperand(6);
15289 unsigned HintVal;
15290 if (dyn_cast (Hint) == nullptr ||
15291 (HintVal = dyn_cast (Hint)->getZExtValue()) > 1)
15292 llvm_unreachable("Wrong prefetch hint in intrinsic: should be 0 or 1");
15289 unsigned HintVal = cast(Hint)->getZExtValue();
15290 assert(HintVal < 2 && "Wrong prefetch hint in intrinsic: should be 0 or 1");
1529315291 unsigned Opcode = (HintVal ? IntrData->Opc1 : IntrData->Opc0);
1529415292 SDValue Chain = Op.getOperand(0);
1529515293 SDValue Mask = Op.getOperand(2);
2424124239 break;
2424224240 case 'G':
2424324241 case 'C':
24244 if (dyn_cast(CallOperandVal)) {
24242 if (isa(CallOperandVal)) {
2424524243 weight = CW_Constant;
2424624244 }
2424724245 break;
630630
631631 def masked_load_aligned128 : PatFrag<(ops node:$src1, node:$src2, node:$src3),
632632 (masked_load node:$src1, node:$src2, node:$src3), [{
633 if (dyn_cast(N))
634 return cast(N)->getAlignment() >= 16;
633 if (auto *Load = dyn_cast(N))
634 return Load->getAlignment() >= 16;
635635 return false;
636636 }]>;
637637
638638 def masked_load_aligned256 : PatFrag<(ops node:$src1, node:$src2, node:$src3),
639639 (masked_load node:$src1, node:$src2, node:$src3), [{
640 if (dyn_cast(N))
641 return cast(N)->getAlignment() >= 32;
640 if (auto *Load = dyn_cast(N))
641 return Load->getAlignment() >= 32;
642642 return false;
643643 }]>;
644644
645645 def masked_load_aligned512 : PatFrag<(ops node:$src1, node:$src2, node:$src3),
646646 (masked_load node:$src1, node:$src2, node:$src3), [{
647 if (dyn_cast(N))
648 return cast(N)->getAlignment() >= 64;
647 if (auto *Load = dyn_cast(N))
648 return Load->getAlignment() >= 64;
649649 return false;
650650 }]>;
651651
652652 def masked_load_unaligned : PatFrag<(ops node:$src1, node:$src2, node:$src3),
653653 (masked_load node:$src1, node:$src2, node:$src3), [{
654 return (dyn_cast(N) != 0);
654 return isa(N);
655655 }]>;
656656
657657 def masked_store_aligned128 : PatFrag<(ops node:$src1, node:$src2, node:$src3),
658658 (masked_store node:$src1, node:$src2, node:$src3), [{
659 if (dyn_cast(N))
660 return cast(N)->getAlignment() >= 16;
659 if (auto *Store = dyn_cast(N))
660 return Store->getAlignment() >= 16;
661661 return false;
662662 }]>;
663663
664664 def masked_store_aligned256 : PatFrag<(ops node:$src1, node:$src2, node:$src3),
665665 (masked_store node:$src1, node:$src2, node:$src3), [{
666 if (dyn_cast(N))
667 return cast(N)->getAlignment() >= 32;
666 if (auto *Store = dyn_cast(N))
667 return Store->getAlignment() >= 32;
668668 return false;
669669 }]>;
670670
671671 def masked_store_aligned512 : PatFrag<(ops node:$src1, node:$src2, node:$src3),
672672 (masked_store node:$src1, node:$src2, node:$src3), [{
673 if (dyn_cast(N))
674 return cast(N)->getAlignment() >= 64;
673 if (auto *Store = dyn_cast(N))
674 return Store->getAlignment() >= 64;
675675 return false;
676676 }]>;
677677
678678 def masked_store_unaligned : PatFrag<(ops node:$src1, node:$src2, node:$src3),
679679 (masked_store node:$src1, node:$src2, node:$src3), [{
680 return (dyn_cast(N) != 0);
681 }]>;
682
680 return isa(N);
681 }]>;
682
10521052 // path is rarely taken. This seems to be the case for SPEC benchmarks.
10531053 TerminatorInst *CheckTerm = SplitBlockAndInsertIfThen(
10541054 Cmp, InsertBefore, false, MDBuilder(*C).createBranchWeights(1, 100000));
1055 assert(dyn_cast(CheckTerm)->isUnconditional());
1055 assert(cast(CheckTerm)->isUnconditional());
10561056 BasicBlock *NextBB = CheckTerm->getSuccessor(0);
10571057 IRB.SetInsertPoint(CheckTerm);
10581058 Value *Cmp2 = createSlowPathCmp(IRB, AddrLong, ShadowValue, TypeSize);
307307 IRBuilder<> IRB(I);
308308 CallSite CS(I);
309309 Value *Callee = CS.getCalledValue();
310 if (dyn_cast(Callee)) continue;
310 if (isa(Callee)) continue;
311311 GlobalVariable *CalleeCache = new GlobalVariable(
312312 *F.getParent(), Ty, false, GlobalValue::PrivateLinkage,
313313 Constant::getNullValue(Ty), "__sancov_gen_callee_cache");
11821182 case Instruction::ICmp:
11831183 case Instruction::FCmp: {
11841184 // Check that all of the compares have the same predicate.
1185 CmpInst::Predicate P0 = dyn_cast(VL0)->getPredicate();
1185 CmpInst::Predicate P0 = cast(VL0)->getPredicate();
11861186 Type *ComparedTy = cast(VL[0])->getOperand(0)->getType();
11871187 for (unsigned i = 1, e = VL.size(); i < e; ++i) {
11881188 CmpInst *Cmp = cast(VL[i]);
22012201 if (Value *V = alreadyVectorized(E->Scalars))
22022202 return V;
22032203
2204 CmpInst::Predicate P0 = dyn_cast(VL0)->getPredicate();
2204 CmpInst::Predicate P0 = cast(VL0)->getPredicate();
22052205 Value *V;
22062206 if (Opcode == Instruction::FCmp)
22072207 V = Builder.CreateFCmp(P0, L, R);
116116 outs() << indent(Indent) << "}";
117117 } else if (yaml::AliasNode *an = dyn_cast(n)){
118118 outs() << "*" << an->getName();
119 } else if (dyn_cast(n)) {
119 } else if (isa(n)) {
120120 outs() << prettyTag(n) << " null";
121121 }
122122 }