Index: llvm/include/llvm/IR/Intrinsics.h =================================================================== --- llvm/include/llvm/IR/Intrinsics.h +++ llvm/include/llvm/IR/Intrinsics.h @@ -101,7 +101,7 @@ Argument, ExtendArgument, TruncArgument, HalfVecArgument, SameVecWidthArgument, PtrToArgument, PtrToElt, VecOfAnyPtrsToElt, VecElementArgument, ScalableVecArgument, Subdivide2Argument, - Subdivide4Argument + Subdivide4Argument, VecOfBitcastsToInt } Kind; union { @@ -127,7 +127,8 @@ Kind == TruncArgument || Kind == HalfVecArgument || Kind == SameVecWidthArgument || Kind == PtrToArgument || Kind == PtrToElt || Kind == VecElementArgument || - Kind == Subdivide2Argument || Kind == Subdivide4Argument); + Kind == Subdivide2Argument || Kind == Subdivide4Argument || + Kind == VecOfBitcastsToInt); return Argument_Info >> 3; } ArgKind getArgumentKind() const { @@ -135,7 +136,7 @@ Kind == TruncArgument || Kind == HalfVecArgument || Kind == SameVecWidthArgument || Kind == PtrToArgument || Kind == VecElementArgument || Kind == Subdivide2Argument || - Kind == Subdivide4Argument); + Kind == Subdivide4Argument || Kind == VecOfBitcastsToInt); return (ArgKind)(Argument_Info & 7); } Index: llvm/include/llvm/IR/Intrinsics.td =================================================================== --- llvm/include/llvm/IR/Intrinsics.td +++ llvm/include/llvm/IR/Intrinsics.td @@ -193,6 +193,10 @@ class LLVMSubdivide2VectorType : LLVMMatchType; class LLVMSubdivide4VectorType : LLVMMatchType; +// Match the element count and bit width of another intrinsic parameter, but +// change the element type to an integer. +class LLVMVectorOfBitcastsToInt : LLVMMatchType; + def llvm_void_ty : LLVMType; let isAny = 1 in { def llvm_any_ty : LLVMType; Index: llvm/lib/IR/Function.cpp =================================================================== --- llvm/lib/IR/Function.cpp +++ llvm/lib/IR/Function.cpp @@ -706,7 +706,8 @@ IIT_VEC_ELEMENT = 42, IIT_SCALABLE_VEC = 43, IIT_SUBDIVIDE2_ARG = 44, - IIT_SUBDIVIDE4_ARG = 45 + IIT_SUBDIVIDE4_ARG = 45, + IIT_VEC_OF_BITCASTS_TO_INT = 46 }; static void DecodeIITType(unsigned &NextElt, ArrayRef Infos, @@ -895,6 +896,12 @@ DecodeIITType(NextElt, Infos, OutputTable); return; } + case IIT_VEC_OF_BITCASTS_TO_INT: { + unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]); + OutputTable.push_back(IITDescriptor::get(IITDescriptor::VecOfBitcastsToInt, + ArgInfo)); + return; + } } llvm_unreachable("unhandled"); } @@ -1021,6 +1028,12 @@ return VTy->getElementType(); llvm_unreachable("Expected an argument of Vector Type"); } + case IITDescriptor::VecOfBitcastsToInt: { + Type *Ty = Tys[D.getArgumentNumber()]; + VectorType *VTy = dyn_cast(Ty); + assert(VTy && "Expected an argument of Vector Type"); + return VectorType::getInteger(VTy); + } case IITDescriptor::VecOfAnyPtrsToElt: // Return the overloaded type (which determines the pointers address space) return Tys[D.getOverloadArgNumber()]; @@ -1313,6 +1326,15 @@ return matchIntrinsicType(VTy, Infos, ArgTys, DeferredChecks, IsDeferredCheck); } + case IITDescriptor::VecOfBitcastsToInt: { + if (D.getArgumentNumber() >= ArgTys.size()) + return IsDeferredCheck || DeferCheck(Ty); + auto *ReferenceType = dyn_cast(ArgTys[D.getArgumentNumber()]); + auto *ThisArgVecTy = dyn_cast(Ty); + if (!ThisArgVecTy || !ReferenceType) + return true; + return ThisArgVecTy != VectorType::getInteger(ReferenceType); + } } llvm_unreachable("unhandled"); } Index: llvm/utils/TableGen/IntrinsicEmitter.cpp =================================================================== --- llvm/utils/TableGen/IntrinsicEmitter.cpp +++ llvm/utils/TableGen/IntrinsicEmitter.cpp @@ -223,7 +223,8 @@ IIT_VEC_ELEMENT = 42, IIT_SCALABLE_VEC = 43, IIT_SUBDIVIDE2_ARG = 44, - IIT_SUBDIVIDE4_ARG = 45 + IIT_SUBDIVIDE4_ARG = 45, + IIT_VEC_OF_BITCASTS_TO_INT = 46 }; static void EncodeFixedValueType(MVT::SimpleValueType VT, @@ -299,6 +300,8 @@ Sig.push_back(IIT_SUBDIVIDE2_ARG); else if (R->isSubClassOf("LLVMSubdivide4VectorType")) Sig.push_back(IIT_SUBDIVIDE4_ARG); + else if (R->isSubClassOf("LLVMVectorOfBitcastsToInt")) + Sig.push_back(IIT_VEC_OF_BITCASTS_TO_INT); else Sig.push_back(IIT_ARG); return Sig.push_back((Number << 3) | 7 /*IITDescriptor::AK_MatchType*/);