[clang] [Clang][AArch64] Add customisable immediate range checking to NEON (PR #100278)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 25 08:21:30 PDT 2024
================
@@ -403,6 +369,63 @@ enum ArmSMEState : unsigned {
ArmZT0Mask = 0b11 << 2
};
+bool SemaARM::ParseNeonImmChecks(
+ CallExpr *TheCall, SmallVector<std::tuple<int, int, int>, 2> &ImmChecks,
+ int OverloadType = -1) {
+ int ArgIdx, CheckTy, ElementType;
+ bool hasError = false;
+
+ for (auto &I : ImmChecks) {
+ std::tie(ArgIdx, CheckTy, ElementType) = I;
+
+ NeonTypeFlags Type = (OverloadType != -1) ? NeonTypeFlags(OverloadType)
+ : NeonTypeFlags(ElementType);
+
+ switch ((ArmImmCheckType)CheckTy) {
+ case ArmImmCheckType::ImmCheck0_3:
+ hasError |= SemaRef.BuiltinConstantArgRange(TheCall, ArgIdx, 0, 3);
+ break;
+ case ArmImmCheckType::ImmCheck0_63:
+ hasError |= SemaRef.BuiltinConstantArgRange(TheCall, ArgIdx, 0, 63);
+ break;
+ case ArmImmCheckType::ImmCheck0_7:
+ hasError |= SemaRef.BuiltinConstantArgRange(TheCall, ArgIdx, 0, 7);
+ break;
+ case ArmImmCheckType::ImmCheck1_16:
+ hasError |= SemaRef.BuiltinConstantArgRange(TheCall, ArgIdx, 1, 16);
+ break;
+ case ArmImmCheckType::ImmCheck1_32:
+ hasError |= SemaRef.BuiltinConstantArgRange(TheCall, ArgIdx, 1, 32);
+ break;
+ case ArmImmCheckType::ImmCheck1_64:
+ hasError |= SemaRef.BuiltinConstantArgRange(TheCall, ArgIdx, 1, 64);
+ break;
+ case ArmImmCheckType::ImmCheckLaneIndex:
+ hasError |= SemaRef.BuiltinConstantArgRange(
+ TheCall, ArgIdx, 0,
+ (64 << Type.isQuad()) / Type.getEltSizeInBits() - 1);
+ break;
+ case ArmImmCheckType::ImmCheckLaneQIndex: // force to use quad
+ hasError |= SemaRef.BuiltinConstantArgRange(
+ TheCall, ArgIdx, 0, (128 / Type.getEltSizeInBits()) - 1);
----------------
Lukacma wrote:
Once we stop relying on TV for base type we can move Type.getEltSizeInBits() into NeonEmitter and have the elements determined there. This will make it more similiar to SVE and enable merging of ParseNeon and ParseSVE
https://github.com/llvm/llvm-project/pull/100278
More information about the cfe-commits
mailing list