gn build: Add support for building the AArch64 LSE builtins.
authorPeter Collingbourne <peter@pcc.me.uk>
Sat, 11 Jun 2022 05:07:39 +0000 (22:07 -0700)
committerPeter Collingbourne <peter@pcc.me.uk>
Mon, 13 Jun 2022 20:15:29 +0000 (13:15 -0700)
Differential Revision: https://reviews.llvm.org/D127560

llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn

index 0248511..6a78b2b 100644 (file)
@@ -6,6 +6,54 @@ declare_args() {
   compiler_rt_exclude_atomic_builtin = true
 }
 
+lse_targets = []
+
+if (current_cpu == "arm64") {
+  foreach(pat,
+          [
+            "cas",
+            "swp",
+            "ldadd",
+            "ldclr",
+            "ldeor",
+            "ldset",
+          ]) {
+    foreach(size,
+            [
+              "1",
+              "2",
+              "4",
+              "8",
+              "16",
+            ]) {
+      foreach(model,
+              [
+                "1",
+                "2",
+                "3",
+                "4",
+              ]) {
+        if (pat == "cas" || size != "16") {
+          source_set("lse_${pat}_${size}_${model}") {
+            # Assign to sources like this to hide from
+            # sync_source_lists_from_cmake.py which won't find the source file
+            # on the CMake side.
+            lse_file = "aarch64/lse.S"
+            sources = [ lse_file ]
+            include_dirs = [ "." ]
+            defines = [
+              "L_$pat",
+              "SIZE=$size",
+              "MODEL=$model",
+            ]
+          }
+          lse_targets += [ ":lse_${pat}_${size}_${model}" ]
+        }
+      }
+    }
+  }
+}
+
 static_library("builtins") {
   output_dir = crt_current_out_dir
   if (current_os == "mac") {
@@ -518,6 +566,8 @@ static_library("builtins") {
   if (!compiler_rt_exclude_atomic_builtin) {
     sources += [ "atomic.c" ]
   }
+
+  deps = lse_targets
 }
 
 # Currently unused but necessary to make sync_source_lists_from_cmake.py happy.