[llvm] r373437 - [IntrinsicEmitter] Add overloaded type VecOfBitcastsToInt for SVE intrinsics
Kerry McLaughlin via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 2 02:25:02 PDT 2019
Author: kmclaughlin
Date: Wed Oct 2 02:25:02 2019
New Revision: 373437
URL: http://llvm.org/viewvc/llvm-project?rev=373437&view=rev
Log:
[IntrinsicEmitter] Add overloaded type VecOfBitcastsToInt for SVE intrinsics
Summary:
This allows intrinsics such as the following to be defined:
- declare <n x 4 x i32> @llvm.something.nxv4f32(<n x 4 x i32>, <n x 4 x i1>, <n x 4 x float>)
...where <n x 4 x i32> is derived from <n x 4 x float>, but
the element needs bitcasting to int.
Reviewers: c-rhodes, sdesmalen, rovka
Reviewed By: c-rhodes
Subscribers: tschuett, hiraditya, jdoerfert, llvm-commits, cfe-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68021
Modified:
llvm/trunk/include/llvm/IR/Intrinsics.h
llvm/trunk/include/llvm/IR/Intrinsics.td
llvm/trunk/lib/IR/Function.cpp
llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
Modified: llvm/trunk/include/llvm/IR/Intrinsics.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Intrinsics.h?rev=373437&r1=373436&r2=373437&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Intrinsics.h (original)
+++ llvm/trunk/include/llvm/IR/Intrinsics.h Wed Oct 2 02:25:02 2019
@@ -101,7 +101,7 @@ namespace Intrinsic {
Argument, ExtendArgument, TruncArgument, HalfVecArgument,
SameVecWidthArgument, PtrToArgument, PtrToElt, VecOfAnyPtrsToElt,
VecElementArgument, ScalableVecArgument, Subdivide2Argument,
- Subdivide4Argument
+ Subdivide4Argument, VecOfBitcastsToInt
} Kind;
union {
@@ -127,7 +127,8 @@ namespace Intrinsic {
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 @@ namespace Intrinsic {
Kind == TruncArgument || Kind == HalfVecArgument ||
Kind == SameVecWidthArgument || Kind == PtrToArgument ||
Kind == VecElementArgument || Kind == Subdivide2Argument ||
- Kind == Subdivide4Argument);
+ Kind == Subdivide4Argument || Kind == VecOfBitcastsToInt);
return (ArgKind)(Argument_Info & 7);
}
Modified: llvm/trunk/include/llvm/IR/Intrinsics.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Intrinsics.td?rev=373437&r1=373436&r2=373437&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Intrinsics.td (original)
+++ llvm/trunk/include/llvm/IR/Intrinsics.td Wed Oct 2 02:25:02 2019
@@ -193,6 +193,10 @@ class LLVMHalfElementsVectorType<int num
class LLVMSubdivide2VectorType<int num> : LLVMMatchType<num>;
class LLVMSubdivide4VectorType<int num> : LLVMMatchType<num>;
+// Match the element count and bit width of another intrinsic parameter, but
+// change the element type to an integer.
+class LLVMVectorOfBitcastsToInt<int num> : LLVMMatchType<num>;
+
def llvm_void_ty : LLVMType<isVoid>;
let isAny = 1 in {
def llvm_any_ty : LLVMType<Any>;
Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=373437&r1=373436&r2=373437&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Wed Oct 2 02:25:02 2019
@@ -706,7 +706,8 @@ enum IIT_Info {
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<unsigned char> Infos,
@@ -895,6 +896,12 @@ static void DecodeIITType(unsigned &Next
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 @@ static Type *DecodeFixedType(ArrayRef<In
return VTy->getElementType();
llvm_unreachable("Expected an argument of Vector Type");
}
+ case IITDescriptor::VecOfBitcastsToInt: {
+ Type *Ty = Tys[D.getArgumentNumber()];
+ VectorType *VTy = dyn_cast<VectorType>(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()];
@@ -1314,6 +1327,15 @@ static bool matchIntrinsicType(
return matchIntrinsicType(VTy, Infos, ArgTys, DeferredChecks,
IsDeferredCheck);
}
+ case IITDescriptor::VecOfBitcastsToInt: {
+ if (D.getArgumentNumber() >= ArgTys.size())
+ return IsDeferredCheck || DeferCheck(Ty);
+ auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
+ auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
+ if (!ThisArgVecTy || !ReferenceType)
+ return true;
+ return ThisArgVecTy != VectorType::getInteger(ReferenceType);
+ }
}
llvm_unreachable("unhandled");
}
Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=373437&r1=373436&r2=373437&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Wed Oct 2 02:25:02 2019
@@ -223,7 +223,8 @@ enum IIT_Info {
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 @@ static void EncodeFixedType(Record *R, s
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*/);
More information about the llvm-commits
mailing list