mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-28 06:32:09 +00:00
Intrinsics: add LLVMHalfElementsVectorType constraint
This is like the LLVMMatchType, except the verifier checks that the second argument is a vector with the same base type and half the number of elements. This will be used by the ARM64 backend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205079 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
224dbf4aec
commit
7c3e057ff4
@ -400,6 +400,26 @@ public:
|
||||
return VectorType::get(EltTy, VTy->getNumElements());
|
||||
}
|
||||
|
||||
/// VectorType::getHalfElementsVectorType - This static method returns
|
||||
/// a VectorType with half as many elements as the input type and the
|
||||
/// same element type.
|
||||
///
|
||||
static VectorType *getHalfElementsVectorType(VectorType *VTy) {
|
||||
unsigned NumElts = VTy->getNumElements();
|
||||
assert ((NumElts & 1) == 0 &&
|
||||
"Cannot halve vector with odd number of elements.");
|
||||
return VectorType::get(VTy->getElementType(), NumElts/2);
|
||||
}
|
||||
|
||||
/// VectorType::getDoubleElementsVectorType - This static method returns
|
||||
/// a VectorType with twice as many elements as the input type and the
|
||||
/// same element type.
|
||||
///
|
||||
static VectorType *getDoubleElementsVectorType(VectorType *VTy) {
|
||||
unsigned NumElts = VTy->getNumElements();
|
||||
return VectorType::get(VTy->getElementType(), NumElts*2);
|
||||
}
|
||||
|
||||
/// isValidElementType - Return true if the specified type is valid as a
|
||||
/// element type.
|
||||
static bool isValidElementType(Type *ElemTy);
|
||||
|
@ -79,7 +79,7 @@ namespace Intrinsic {
|
||||
enum IITDescriptorKind {
|
||||
Void, VarArg, MMX, Metadata, Half, Float, Double,
|
||||
Integer, Vector, Pointer, Struct,
|
||||
Argument, ExtendArgument, TruncArgument,
|
||||
Argument, ExtendArgument, TruncArgument, HalfVecArgument
|
||||
} Kind;
|
||||
|
||||
union {
|
||||
@ -99,12 +99,12 @@ namespace Intrinsic {
|
||||
};
|
||||
unsigned getArgumentNumber() const {
|
||||
assert(Kind == Argument || Kind == ExtendArgument ||
|
||||
Kind == TruncArgument);
|
||||
Kind == TruncArgument || Kind == HalfVecArgument);
|
||||
return Argument_Info >> 2;
|
||||
}
|
||||
ArgKind getArgumentKind() const {
|
||||
assert(Kind == Argument || Kind == ExtendArgument ||
|
||||
Kind == TruncArgument);
|
||||
Kind == TruncArgument || Kind == HalfVecArgument);
|
||||
return (ArgKind)(Argument_Info&3);
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,10 @@ class LLVMMatchType<int num>
|
||||
class LLVMExtendedType<int num> : LLVMMatchType<num>;
|
||||
class LLVMTruncatedType<int num> : LLVMMatchType<num>;
|
||||
|
||||
// Match the type of another intrinsic parameter that is expected to be a
|
||||
// vector type, but change the element count to be half as many
|
||||
class LLVMHalfElementsVectorType<int num> : LLVMMatchType<num>;
|
||||
|
||||
def llvm_void_ty : LLVMType<isVoid>;
|
||||
def llvm_anyint_ty : LLVMType<iAny>;
|
||||
def llvm_anyfloat_ty : LLVMType<fAny>;
|
||||
|
@ -470,7 +470,8 @@ enum IIT_Info {
|
||||
IIT_TRUNC_ARG = 24,
|
||||
IIT_ANYPTR = 25,
|
||||
IIT_V1 = 26,
|
||||
IIT_VARARG = 27
|
||||
IIT_VARARG = 27,
|
||||
IIT_HALF_VEC_ARG = 28
|
||||
};
|
||||
|
||||
|
||||
@ -568,6 +569,12 @@ static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
|
||||
ArgInfo));
|
||||
return;
|
||||
}
|
||||
case IIT_HALF_VEC_ARG: {
|
||||
unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
|
||||
OutputTable.push_back(IITDescriptor::get(IITDescriptor::HalfVecArgument,
|
||||
ArgInfo));
|
||||
return;
|
||||
}
|
||||
case IIT_EMPTYSTRUCT:
|
||||
OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
|
||||
return;
|
||||
@ -672,6 +679,9 @@ static Type *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos,
|
||||
assert(ITy->getBitWidth() % 2 == 0);
|
||||
return IntegerType::get(Context, ITy->getBitWidth() / 2);
|
||||
}
|
||||
case IITDescriptor::HalfVecArgument:
|
||||
return VectorType::getHalfElementsVectorType(cast<VectorType>(
|
||||
Tys[D.getArgumentNumber()]));
|
||||
}
|
||||
llvm_unreachable("unhandled");
|
||||
}
|
||||
|
@ -2206,6 +2206,12 @@ bool Verifier::VerifyIntrinsicType(Type *Ty,
|
||||
|
||||
return Ty != NewTy;
|
||||
}
|
||||
case IITDescriptor::HalfVecArgument:
|
||||
// This may only be used when referring to a previous vector argument.
|
||||
return D.getArgumentNumber() >= ArgTys.size() ||
|
||||
!isa<VectorType>(ArgTys[D.getArgumentNumber()]) ||
|
||||
VectorType::getHalfElementsVectorType(
|
||||
cast<VectorType>(ArgTys[D.getArgumentNumber()])) != Ty;
|
||||
}
|
||||
llvm_unreachable("unhandled");
|
||||
}
|
||||
|
@ -250,7 +250,8 @@ enum IIT_Info {
|
||||
IIT_TRUNC_ARG = 24,
|
||||
IIT_ANYPTR = 25,
|
||||
IIT_V1 = 26,
|
||||
IIT_VARARG = 27
|
||||
IIT_VARARG = 27,
|
||||
IIT_HALF_VEC_ARG = 28
|
||||
};
|
||||
|
||||
|
||||
@ -296,6 +297,8 @@ static void EncodeFixedType(Record *R, std::vector<unsigned char> &ArgCodes,
|
||||
Sig.push_back(IIT_EXTEND_ARG);
|
||||
else if (R->isSubClassOf("LLVMTruncatedType"))
|
||||
Sig.push_back(IIT_TRUNC_ARG);
|
||||
else if (R->isSubClassOf("LLVMHalfElementsVectorType"))
|
||||
Sig.push_back(IIT_HALF_VEC_ARG);
|
||||
else
|
||||
Sig.push_back(IIT_ARG);
|
||||
return Sig.push_back((Number << 2) | ArgCodes[Number]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user