Index: llvm/include/llvm/IR/Intrinsics.h =================================================================== --- llvm/include/llvm/IR/Intrinsics.h +++ llvm/include/llvm/IR/Intrinsics.h @@ -103,17 +103,22 @@ Integer, Vector, Pointer, Struct, Argument, ExtendArgument, TruncArgument, HalfVecArgument, SameVecWidthArgument, PtrToArgument, PtrToElt, VecOfAnyPtrsToElt, - VecElementArgument, ScalableVecArgument, Subdivide2Argument, - Subdivide4Argument, VecOfBitcastsToInt + VecElementArgument, Subdivide2Argument, Subdivide4Argument, + VecOfBitcastsToInt } Kind; + struct VectorWidth { + unsigned NumElts : 30; + unsigned Scalable : 1; + }; + union { unsigned Integer_Width; unsigned Float_Width; - unsigned Vector_Width; unsigned Pointer_AddressSpace; unsigned Struct_NumElements; unsigned Argument_Info; + struct VectorWidth Vector_Width; }; enum ArgKind { @@ -165,6 +170,14 @@ IITDescriptor Result = {K, {Field}}; return Result; } + + static IITDescriptor getVector(unsigned Width, bool IsScalable) { + IITDescriptor Result; + Result.Kind = Vector; + Result.Vector_Width.NumElts = Width; + Result.Vector_Width.Scalable = IsScalable; + return Result; + } }; /// Return the IIT table descriptor for the specified intrinsic into an array Index: llvm/lib/IR/Function.cpp =================================================================== --- llvm/lib/IR/Function.cpp +++ llvm/lib/IR/Function.cpp @@ -748,6 +748,12 @@ SmallVectorImpl &OutputTable) { using namespace Intrinsic; + bool IsScalableVector = false; + if (NextElt > 0) { + IIT_Info LastInfo = IIT_Info(Infos[NextElt - 1]); + IsScalableVector = (LastInfo == IIT_SCALABLE_VEC); + } + IIT_Info Info = IIT_Info(Infos[NextElt++]); unsigned StructElts = 2; @@ -798,43 +804,43 @@ OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 128)); return; case IIT_V1: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 1)); + OutputTable.push_back(IITDescriptor::getVector(1, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_V2: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 2)); + OutputTable.push_back(IITDescriptor::getVector(2, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_V4: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 4)); + OutputTable.push_back(IITDescriptor::getVector(4, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_V8: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 8)); + OutputTable.push_back(IITDescriptor::getVector(8, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_V16: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 16)); + OutputTable.push_back(IITDescriptor::getVector(16, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_V32: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 32)); + OutputTable.push_back(IITDescriptor::getVector(32, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_V64: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 64)); + OutputTable.push_back(IITDescriptor::getVector(64, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_V128: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 128)); + OutputTable.push_back(IITDescriptor::getVector(128, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_V512: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 512)); + OutputTable.push_back(IITDescriptor::getVector(512, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_V1024: - OutputTable.push_back(IITDescriptor::get(IITDescriptor::Vector, 1024)); + OutputTable.push_back(IITDescriptor::getVector(1024, IsScalableVector)); DecodeIITType(NextElt, Infos, OutputTable); return; case IIT_PTR: @@ -929,8 +935,6 @@ return; } case IIT_SCALABLE_VEC: { - OutputTable.push_back(IITDescriptor::get(IITDescriptor::ScalableVecArgument, - 0)); DecodeIITType(NextElt, Infos, OutputTable); return; } @@ -1002,7 +1006,8 @@ case IITDescriptor::Integer: return IntegerType::get(Context, D.Integer_Width); case IITDescriptor::Vector: - return VectorType::get(DecodeFixedType(Infos, Tys, Context),D.Vector_Width); + return VectorType::get(DecodeFixedType(Infos, Tys, Context), + D.Vector_Width.NumElts, D.Vector_Width.Scalable); case IITDescriptor::Pointer: return PointerType::get(DecodeFixedType(Infos, Tys, Context), D.Pointer_AddressSpace); @@ -1075,10 +1080,6 @@ case IITDescriptor::VecOfAnyPtrsToElt: // Return the overloaded type (which determines the pointers address space) return Tys[D.getOverloadArgNumber()]; - case IITDescriptor::ScalableVecArgument: { - auto *Ty = cast(DecodeFixedType(Infos, Tys, Context)); - return ScalableVectorType::get(Ty->getElementType(), Ty->getNumElements()); - } } llvm_unreachable("unhandled"); } @@ -1181,10 +1182,9 @@ case IITDescriptor::Quad: return !Ty->isFP128Ty(); case IITDescriptor::Integer: return !Ty->isIntegerTy(D.Integer_Width); case IITDescriptor::Vector: { - // FIXME: We shouldn't be assuming all Vector types are fixed width. - // This will be fixed soon in another future patch. - FixedVectorType *VT = dyn_cast(Ty); - return !VT || VT->getNumElements() != D.Vector_Width || + VectorType *VT = dyn_cast(Ty); + ElementCount EltCnt(D.Vector_Width.NumElts, D.Vector_Width.Scalable); + return !VT || VT->getElementCount() != EltCnt || matchIntrinsicType(VT->getElementType(), Infos, ArgTys, DeferredChecks, IsDeferredCheck); } @@ -1357,16 +1357,6 @@ } return true; } - case IITDescriptor::ScalableVecArgument: { - if (!isa(Ty)) - return true; - ScalableVectorType *STy = cast(Ty); - unsigned MinElts = STy->getMinNumElements(); - FixedVectorType *FVTy = - FixedVectorType::get(STy->getElementType(), MinElts); - return matchIntrinsicType(FVTy, Infos, ArgTys, DeferredChecks, - IsDeferredCheck); - } case IITDescriptor::VecOfBitcastsToInt: { if (D.getArgumentNumber() >= ArgTys.size()) return IsDeferredCheck || DeferCheck(Ty);