[clang] [llvm] [Clang][AArch64] Add customisable immediate range checking to NEON (PR #100278)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 2 08:44:38 PDT 2024
================
@@ -2142,85 +2178,58 @@ void NeonEmitter::genOverloadTypeCheckCode(raw_ostream &OS,
OS << "#endif\n\n";
}
-void NeonEmitter::genIntrinsicRangeCheckCode(raw_ostream &OS,
- SmallVectorImpl<Intrinsic *> &Defs) {
- OS << "#ifdef GET_NEON_IMMEDIATE_CHECK\n";
+inline bool
+NeonEmitter::areRangeChecksCompatable(const ArrayRef<ImmCheck> ChecksA,
+ const ArrayRef<ImmCheck> ChecksB) {
+ // If multiple intrinsics map to the same builtin, we must ensure that the
+ // intended range checks performed in SemaArm.cpp do not contradict each
+ // other, as these are emitted once per-buitlin.
+ //
+ // The arguments to be checked and type of each check to be performed must be
+ // the same. The element types may differ as they will be resolved
+ // per-intrinsic as overloaded types by SemaArm.cpp, though the vector sizes
+ // are not and so must be the same.
+ bool compat =
+ std::equal(ChecksA.begin(), ChecksA.end(), ChecksB.begin(), ChecksB.end(),
+ [](const auto A, const auto B) {
+ return A.getImmArgIdx() == B.getImmArgIdx() &&
+ A.getKind() == B.getKind() &&
+ A.getVecSizeInBits() == B.getVecSizeInBits();
+ });
+
+ return compat;
+}
- std::set<std::string> Emitted;
+void NeonEmitter::genIntrinsicRangeCheckCode(
+ raw_ostream &OS, SmallVectorImpl<Intrinsic *> &Defs) {
+ std::unordered_map<std::string, ArrayRef<ImmCheck>> Emitted;
----------------
SpencerAbson wrote:
Good point, unfortunately there is no standard implementation of `DenseMapInfo<std::string>` (required to have `std::string` as a key for `DenseMap`) - I'm not sure that this use would justify defining one here?
https://github.com/llvm/llvm-project/pull/100278
More information about the cfe-commits
mailing list