llvm.org GIT mirror llvm / 9d10770
[TargetLowering] getValueType - use dyn_cast directly to find VectorType. NFCI. Matches what we do in other getValueType functions and fixes a null dereference warning in scan-build. Also cleans up the rest of the function - use auto and standardize the variable names. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360000 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 1 year, 5 months ago
1 changed file(s) with 9 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
11631163 EVT getValueType(const DataLayout &DL, Type *Ty,
11641164 bool AllowUnknown = false) const {
11651165 // Lower scalar pointers to native pointer types.
1166 if (PointerType *PTy = dyn_cast(Ty))
1166 if (auto *PTy = dyn_cast(Ty))
11671167 return getPointerTy(DL, PTy->getAddressSpace());
11681168
1169 if (Ty->isVectorTy()) {
1170 VectorType *VTy = cast(Ty);
1171 Type *Elm = VTy->getElementType();
1169 if (auto *VTy = dyn_cast(Ty)) {
1170 Type *EltTy = VTy->getElementType();
11721171 // Lower vectors of pointers to native pointer types.
1173 if (PointerType *PT = dyn_cast(Elm)) {
1174 EVT PointerTy(getPointerTy(DL, PT->getAddressSpace()));
1175 Elm = PointerTy.getTypeForEVT(Ty->getContext());
1172 if (auto *PTy = dyn_cast(EltTy)) {
1173 EVT PointerTy(getPointerTy(DL, PTy->getAddressSpace()));
1174 EltTy = PointerTy.getTypeForEVT(Ty->getContext());
11761175 }
1177
1178 return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(Elm, false),
1179 VTy->getNumElements());
1176 return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(EltTy, false),
1177 VTy->getNumElements());
11801178 }
1179
11811180 return EVT::getEVT(Ty, AllowUnknown);
11821181 }
11831182