Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AArch64 specific builtins/intrinsics #589

Open
bcardosolopes opened this issue May 6, 2024 · 10 comments
Open

AArch64 specific builtins/intrinsics #589

bcardosolopes opened this issue May 6, 2024 · 10 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@bcardosolopes
Copy link
Member

We currently don't emit ARM64 specific intrinsics/builtins, nor none for other arches as well. See clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp for the paths full of asserts. The suggested way to tackle these are by incrementally adding support to the missing pieces - there's a huge number of them.

@bcardosolopes bcardosolopes changed the title ARM specific builtins/intrinsics AArch64 specific builtins/intrinsics May 6, 2024
@bcardosolopes bcardosolopes added the good first issue Good for newcomers label May 6, 2024
@khoipkv
Copy link

khoipkv commented Jun 3, 2024

Hey, is this issue still open?

@bcardosolopes
Copy link
Member Author

Yep, and there's enough work for multiple folks!

@bcardosolopes
Copy link
Member Author

bcardosolopes commented Jun 3, 2024

See commented tests in clang/test/CIR/CodeGen/aarch64-neon-intrinsics.c. This is just a subset, there is even more if you search in clang/test/CodeGen.

@khoipkv
Copy link

khoipkv commented Jun 4, 2024

If so, could you please assign this one to me? If anyone wants to join in, we add more.

@bcardosolopes
Copy link
Member Author

bcardosolopes commented Jul 8, 2024

@khoipkv Here's a list of ones I'd give priority:

Start with:
NEON::BI__builtin_neon_vld1_lane_v
NEON::BI__builtin_neon_vld1q_lane_v
NEON::BI__builtin_neon_vst1_lane_v
NEON::BI__builtin_neon_vst1q_lane_v
NEON::BI__builtin_neon_vld1_dup_v
NEON::BI__builtin_neon_vld1q_dup_v

Next ones:
NEON::BI__builtin_neon_vsetq_lane_f64
NEON::BI__builtin_neon_vdups_lane_i32
NEON::BI__builtin_neon_vrshrn_n_v
NEON::BI__builtin_neon_vget_lane_i8
NEON::BI__builtin_neon_vdupb_lane_i8
clang::AArch64::BI__builtin_arm_ldrex
clang::AArch64::BI__builtin_arm_ldaex
NEON::BI__builtin_neon_vqrshrun_n_v
NEON::BI__builtin_neon_vsra_n_v
NEON::BI__builtin_neon_vsraq_n_v
NEON::BI__builtin_neon_vget_lane_i64
NEON::BI__builtin_neon_vdupd_lane_i64
NEON::BI__builtin_neon_vgetq_lane_i64
NEON::BI__builtin_neon_vdupd_laneq_i64

I suggest you try to get one PR for each individually (or few relevant ones together), incremental is best to make progress and ramp up.

After you complete this list, you might gain a bit more familiarity with how builtins work. Then, you could go for the other bulk ones (table driven), like in clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp:2242:

  // Not all intrinsics handled by the common case work for AArch64 yet, so only
  // defer to common code if it's been added to our special map.
  Builtin = findARMVectorIntrinsicInMap(AArch64SIMDIntrinsicMap, BuiltinID,
                                        AArch64SIMDIntrinsicsProvenSorted);
  if (Builtin) {
    llvm_unreachable("NYI");
  }

(cc: @dkolsen-pgi)

@NoumanAmir657
Copy link

Is there work still left to be done on this?

@AmrDeveloper
Copy link
Member

AmrDeveloper commented Dec 25, 2024

@NoumanAmir657 There is a lot of work still left, you can check the file clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp and search for llvm_unreachable or case NEON::BI__builtin

@bcardosolopes
Copy link
Member Author

@AmrDeveloper thanks a bunch for working on this, really appreciate your contributions :)

@AmrDeveloper
Copy link
Member

@AmrDeveloper thanks a bunch for working on this, really appreciate your contributions :)

Thank you @bcardosolopes 🙏🏻

@bcardosolopes
Copy link
Member Author

FWIW, just hit this NYI in our codebase: BI__builtin_neon_vzipq_v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants