[clang] [CIR][NFC] Add infrastructure for AArch64 builtins (PR #170386)

2025-12-03 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-ppc64le-linux` 
running on `ppc64le-sanitizer` while building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/72/builds/16557


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure) (timed out)
...

Testing Time: 858.97s

Total Discovered Tests: 5052
  Skipped  :   11 (0.22%)
  Unsupported  : 1196 (23.67%)
  Passed   : 3803 (75.28%)
  Expectedly Failed:   42 (0.83%)
@@@BUILD_STEP build standalone compiler-rt@@@
+ /home/buildbots/llvm-external-buildbots/cmake-3.31.2/bin/cmake -B 
compiler_rt_build -GNinja 
-DCMAKE_C_COMPILER=/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/clang
 
-DCMAKE_CXX_COMPILER=/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/clang++
 -DCOMPILER_RT_INCLUDE_TESTS=ON -DCOMPILER_RT_ENABLE_WERROR=ON 
-DLLVM_CMAKE_DIR=/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/..
 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/llvm/../compiler-rt
command timed out: 1800 seconds without output running [b'python', 
b'../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'],
 attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=5676.894338
Step 13 (build standalone compiler-rt) failure: build standalone compiler-rt 
(failure)
@@@BUILD_STEP build standalone compiler-rt@@@
+ /home/buildbots/llvm-external-buildbots/cmake-3.31.2/bin/cmake -B 
compiler_rt_build -GNinja 
-DCMAKE_C_COMPILER=/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/clang
 
-DCMAKE_CXX_COMPILER=/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/clang++
 -DCOMPILER_RT_INCLUDE_TESTS=ON -DCOMPILER_RT_ENABLE_WERROR=ON 
-DLLVM_CMAKE_DIR=/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/bin/..
 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/llvm/../compiler-rt

command timed out: 1800 seconds without output running [b'python', 
b'../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'],
 attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=5676.894338

```



https://github.com/llvm/llvm-project/pull/170386
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR][NFC] Add infrastructure for AArch64 builtins (PR #170386)

2025-12-03 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-m68k-linux-cross` 
running on `suse-gary-m68k-cross` while building `clang` at step 5 "ninja check 
1".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/27/builds/19804


Here is the relevant piece of the build log for the reference

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
...
[132/1217] Building CXX object 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/DiagnosticsTests.cpp.o
[133/1217] Building CXX object 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/SymbolCollectorTests.cpp.o
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp:
 In member function ‘virtual void 
clang::clangd::{anonymous}::SymbolCollectorTest_SpelledReferences_Test::TestBody()’:
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp:1148:8:
 warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
 1148 | if (!SpelledRanges.empty())
  |^
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp:1151:8:
 warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
 1151 | if (!ImplicitRanges.empty())
  |^
[134/1217] Building CXX object 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o
FAILED: 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o
 
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/tools/extra/clangd/unittests
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang-tools-extra/clangd/unittests
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang-tools-extra/clangd/../include-cleaner/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/tools/extra/clangd/../clang-tidy
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang-tools-extra/clangd
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/tools/extra/clangd
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googletest/include
 
-I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googlemock/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess 
-Wno-dangling-reference -Wno-redundant-move -Wno-pessimizing-move 
-Wno-array-bounds -Wno-stringop-overread -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -O3 
-DNDEBUG -std=c++17  -Wno-variadic-macros -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o
 -MF 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o.d
 -o 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o
 -c 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
[135/1217] Building CXX object 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/TestWorkspace.cpp.o
[136/1217] Building CXX object 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/tweaks/DumpSymbolTests.cpp.o
[137/1217] Building CXX object 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/tweaks/SpecialMembersTests.cpp.o
[138/1217] Building CXX object 
tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/tweaks/PopulateSwitchTests.cpp.o
[139/1217] Building CXX 

[clang] [CIR][NFC] Add infrastructure for AArch64 builtins (PR #170386)

2025-12-03 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor closed 
https://github.com/llvm/llvm-project/pull/170386
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR][NFC] Add infrastructure for AArch64 builtins (PR #170386)

2025-12-03 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper approved this pull request.


https://github.com/llvm/llvm-project/pull/170386
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR][NFC] Add infrastructure for AArch64 builtins (PR #170386)

2025-12-02 Thread Bruno Cardoso Lopes via cfe-commits

https://github.com/bcardosolopes approved this pull request.

Awesome, LGTM

https://github.com/llvm/llvm-project/pull/170386
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR][NFC] Add infrastructure for AArch64 builtins (PR #170386)

2025-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Andy Kaylor (andykaylor)


Changes

This change adds the basic code structure for handling AArch64 builtins. The 
structure of this code is brought over from classic codegen to make 
implementing missing builtins easier. In some cases, the handling involved too 
much logic for a simple NFC change, so those parts were replaced with a 
MissingFeature assert.

The actual handling for all builtins is left for later changes.

---

Patch is 65.62 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/170386.diff


5 Files Affected:

- (modified) clang/include/clang/CIR/MissingFeatures.h (+5) 
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+4) 
- (added) clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp (+1583) 
- (modified) clang/lib/CIR/CodeGen/CIRGenFunction.h (+8) 
- (modified) clang/lib/CIR/CodeGen/CMakeLists.txt (+1) 


``diff
diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index 3d3251adae279..5075071661fb5 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -190,6 +190,10 @@ struct MissingFeatures {
   static bool globalCtorAssociatedData() { return false; }
 
   // Misc
+  static bool aarch64SIMDIntrinsics() { return false; }
+  static bool aarch64SMEIntrinsics() { return false; }
+  static bool aarch64SVEIntrinsics() { return false; }
+  static bool aarch64TblBuiltinExpr() { return false; }
   static bool abiArgInfo() { return false; }
   static bool addAutoInitAnnotation() { return false; }
   static bool addHeapAllocSiteMetadata() { return false; }
@@ -293,6 +297,7 @@ struct MissingFeatures {
   static bool metaDataNode() { return false; }
   static bool moduleNameHash() { return false; }
   static bool msabi() { return false; }
+  static bool neonSISDIntrinsics() { return false; }
   static bool nrvo() { return false; }
   static bool objCBlocks() { return false; }
   static bool objCGC() { return false; }
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index e14b5f8aac337..0a6b36984b187 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -1322,9 +1322,13 @@ static mlir::Value 
emitTargetArchBuiltinExpr(CIRGenFunction *cgf,
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
+// These are actually NYI, but that will be reported by emitBuiltinExpr.
+// At this point, we don't even know that the builtin is target-specific.
+return nullptr;
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_32:
   case llvm::Triple::aarch64_be:
+return cgf->emitAArch64BuiltinExpr(builtinID, e, returnValue, arch);
   case llvm::Triple::bpfeb:
   case llvm::Triple::bpfel:
 // These are actually NYI, but that will be reported by emitBuiltinExpr.
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
new file mode 100644
index 0..5a9ae59ca253a
--- /dev/null
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
@@ -0,0 +1,1583 @@
+//=== CIRGenBuiltinAArch64.cpp - Emit CIR for AArch64 builtins 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This contains code to emit ARM64 Builtin calls as CIR or a function call
+// to be later resolved.
+//
+//===--===//
+
+#include "CIRGenFunction.h"
+#include "clang/CIR/MissingFeatures.h"
+
+// TODO(cir): once all builtins are covered, decide whether we still
+// need to use LLVM intrinsics or if there's a better approach to follow. Right
+// now the intrinsics are reused to make it convenient to encode all thousands
+// of them and passing down to LLVM lowering.
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/IntrinsicsAArch64.h"
+
+#include "mlir/IR/Value.h"
+#include "clang/AST/GlobalDecl.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/TargetBuiltins.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+using namespace llvm;
+
+mlir::Value CIRGenFunction::emitAArch64SVEBuiltinExpr(unsigned builtinID,
+  const CallExpr *expr) {
+  if (builtinID >= SVE::BI__builtin_sve_reinterpret_s8_s8 &&
+  builtinID <= SVE::BI__builtin_sve_reinterpret_f64_f64_x4) {
+cgm.errorNYI(expr->getSourceRange(),
+ std::string("unimplemented AArch64 builtin call: ") +
+ getContext().BuiltinInfo.getName(builtinID));
+return {};
+  }
+
+  assert(!cir::MissingFeatures::aarch64SVEIntrinsics());
+
+  switch (builtinID) {
+  

[clang] [CIR][NFC] Add infrastructure for AArch64 builtins (PR #170386)

2025-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Andy Kaylor (andykaylor)


Changes

This change adds the basic code structure for handling AArch64 builtins. The 
structure of this code is brought over from classic codegen to make 
implementing missing builtins easier. In some cases, the handling involved too 
much logic for a simple NFC change, so those parts were replaced with a 
MissingFeature assert.

The actual handling for all builtins is left for later changes.

---

Patch is 65.62 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/170386.diff


5 Files Affected:

- (modified) clang/include/clang/CIR/MissingFeatures.h (+5) 
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+4) 
- (added) clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp (+1583) 
- (modified) clang/lib/CIR/CodeGen/CIRGenFunction.h (+8) 
- (modified) clang/lib/CIR/CodeGen/CMakeLists.txt (+1) 


``diff
diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index 3d3251adae279..5075071661fb5 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -190,6 +190,10 @@ struct MissingFeatures {
   static bool globalCtorAssociatedData() { return false; }
 
   // Misc
+  static bool aarch64SIMDIntrinsics() { return false; }
+  static bool aarch64SMEIntrinsics() { return false; }
+  static bool aarch64SVEIntrinsics() { return false; }
+  static bool aarch64TblBuiltinExpr() { return false; }
   static bool abiArgInfo() { return false; }
   static bool addAutoInitAnnotation() { return false; }
   static bool addHeapAllocSiteMetadata() { return false; }
@@ -293,6 +297,7 @@ struct MissingFeatures {
   static bool metaDataNode() { return false; }
   static bool moduleNameHash() { return false; }
   static bool msabi() { return false; }
+  static bool neonSISDIntrinsics() { return false; }
   static bool nrvo() { return false; }
   static bool objCBlocks() { return false; }
   static bool objCGC() { return false; }
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index e14b5f8aac337..0a6b36984b187 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -1322,9 +1322,13 @@ static mlir::Value 
emitTargetArchBuiltinExpr(CIRGenFunction *cgf,
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
+// These are actually NYI, but that will be reported by emitBuiltinExpr.
+// At this point, we don't even know that the builtin is target-specific.
+return nullptr;
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_32:
   case llvm::Triple::aarch64_be:
+return cgf->emitAArch64BuiltinExpr(builtinID, e, returnValue, arch);
   case llvm::Triple::bpfeb:
   case llvm::Triple::bpfel:
 // These are actually NYI, but that will be reported by emitBuiltinExpr.
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
new file mode 100644
index 0..5a9ae59ca253a
--- /dev/null
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
@@ -0,0 +1,1583 @@
+//=== CIRGenBuiltinAArch64.cpp - Emit CIR for AArch64 builtins 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This contains code to emit ARM64 Builtin calls as CIR or a function call
+// to be later resolved.
+//
+//===--===//
+
+#include "CIRGenFunction.h"
+#include "clang/CIR/MissingFeatures.h"
+
+// TODO(cir): once all builtins are covered, decide whether we still
+// need to use LLVM intrinsics or if there's a better approach to follow. Right
+// now the intrinsics are reused to make it convenient to encode all thousands
+// of them and passing down to LLVM lowering.
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/IntrinsicsAArch64.h"
+
+#include "mlir/IR/Value.h"
+#include "clang/AST/GlobalDecl.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/TargetBuiltins.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+using namespace llvm;
+
+mlir::Value CIRGenFunction::emitAArch64SVEBuiltinExpr(unsigned builtinID,
+  const CallExpr *expr) {
+  if (builtinID >= SVE::BI__builtin_sve_reinterpret_s8_s8 &&
+  builtinID <= SVE::BI__builtin_sve_reinterpret_f64_f64_x4) {
+cgm.errorNYI(expr->getSourceRange(),
+ std::string("unimplemented AArch64 builtin call: ") +
+ getContext().BuiltinInfo.getName(builtinID));
+return {};
+  }
+
+  assert(!cir::MissingFeatures::aarch64SVEIntrinsics());
+
+  switch (builtinID) {
+  

[clang] [CIR][NFC] Add infrastructure for AArch64 builtins (PR #170386)

2025-12-02 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor created 
https://github.com/llvm/llvm-project/pull/170386

This change adds the basic code structure for handling AArch64 builtins. The 
structure of this code is brought over from classic codegen to make 
implementing missing builtins easier. In some cases, the handling involved too 
much logic for a simple NFC change, so those parts were replaced with a 
MissingFeature assert.

The actual handling for all builtins is left for later changes.

>From 8e26de4124245c556ca902e1c3f424313aecc522 Mon Sep 17 00:00:00 2001
From: Andy Kaylor 
Date: Tue, 2 Dec 2025 14:29:24 -0800
Subject: [PATCH] [CIR][NFC] Add infrastructure for AArch64 builtins

This change adds the basic code structure for handling AArch64 builtins.
The structure of this code is brought over from classic codegen to make
implementing missing builtins easier. In some cases, the handling involved
too much logic for a simple NFC change, so those parts were replaced with
a MissingFeature assert.

The actual handling for all builtins is left for later changes.
---
 clang/include/clang/CIR/MissingFeatures.h |5 +
 clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp   |4 +
 .../lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp  | 1583 +
 clang/lib/CIR/CodeGen/CIRGenFunction.h|8 +
 clang/lib/CIR/CodeGen/CMakeLists.txt  |1 +
 5 files changed, 1601 insertions(+)
 create mode 100644 clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index 3d3251adae279..5075071661fb5 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -190,6 +190,10 @@ struct MissingFeatures {
   static bool globalCtorAssociatedData() { return false; }
 
   // Misc
+  static bool aarch64SIMDIntrinsics() { return false; }
+  static bool aarch64SMEIntrinsics() { return false; }
+  static bool aarch64SVEIntrinsics() { return false; }
+  static bool aarch64TblBuiltinExpr() { return false; }
   static bool abiArgInfo() { return false; }
   static bool addAutoInitAnnotation() { return false; }
   static bool addHeapAllocSiteMetadata() { return false; }
@@ -293,6 +297,7 @@ struct MissingFeatures {
   static bool metaDataNode() { return false; }
   static bool moduleNameHash() { return false; }
   static bool msabi() { return false; }
+  static bool neonSISDIntrinsics() { return false; }
   static bool nrvo() { return false; }
   static bool objCBlocks() { return false; }
   static bool objCGC() { return false; }
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index e14b5f8aac337..0a6b36984b187 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -1322,9 +1322,13 @@ static mlir::Value 
emitTargetArchBuiltinExpr(CIRGenFunction *cgf,
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
+// These are actually NYI, but that will be reported by emitBuiltinExpr.
+// At this point, we don't even know that the builtin is target-specific.
+return nullptr;
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_32:
   case llvm::Triple::aarch64_be:
+return cgf->emitAArch64BuiltinExpr(builtinID, e, returnValue, arch);
   case llvm::Triple::bpfeb:
   case llvm::Triple::bpfel:
 // These are actually NYI, but that will be reported by emitBuiltinExpr.
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
new file mode 100644
index 0..5a9ae59ca253a
--- /dev/null
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
@@ -0,0 +1,1583 @@
+//=== CIRGenBuiltinAArch64.cpp - Emit CIR for AArch64 builtins 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This contains code to emit ARM64 Builtin calls as CIR or a function call
+// to be later resolved.
+//
+//===--===//
+
+#include "CIRGenFunction.h"
+#include "clang/CIR/MissingFeatures.h"
+
+// TODO(cir): once all builtins are covered, decide whether we still
+// need to use LLVM intrinsics or if there's a better approach to follow. Right
+// now the intrinsics are reused to make it convenient to encode all thousands
+// of them and passing down to LLVM lowering.
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/IntrinsicsAArch64.h"
+
+#include "mlir/IR/Value.h"
+#include "clang/AST/GlobalDecl.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/TargetBuiltins.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+using namespace llvm;
+
+mlir::Value