aarch64: make some setups for aarch64 support
authorDongju Chae <dongju.chae@samsung.com>
Mon, 21 Oct 2019 10:31:14 +0000 (19:31 +0900)
committerMarek Vasut <marex@denx.de>
Wed, 16 Sep 2020 12:27:27 +0000 (14:27 +0200)
This commit adds the setup codes for aarch64 support including meson build and aarch64 selection.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
meson.build
orc/meson.build
orc/orcarm.c
orc/orccpu-arm.c
orc/orcprogram-neon.c
orc/orctarget.h
orc/orcutils.c
orc/orcutils.h

index 674af96..a7c7e4c 100644 (file)
@@ -62,6 +62,8 @@ elif cpu_family == 'ppc' or cpu_family == 'ppc64'
   cdata.set('HAVE_POWERPC', true)
 elif cpu_family == 'arm'
   cdata.set('HAVE_ARM', true)
+elif cpu_family == 'aarch64'
+  cdata.set('HAVE_AARCH64', true)
 elif cpu_family == 'mips' and host_machine.endian() == 'little'
   cdata.set('HAVE_MIPSEL', true)
 else
index 1995f36..0213ed8 100644 (file)
@@ -91,7 +91,7 @@ if cpu_family.startswith('x86')
   orc_sources += ['orccpu-x86.c']
 elif cpu_family == 'ppc' or cpu_family == 'ppc64'
   orc_sources += ['orccpu-powerpc.c']
-elif cpu_family == 'arm'
+elif cpu_family == 'arm' or cpu_family == 'aarch64'
   orc_sources += ['orccpu-arm.c']
 elif cpu_family == 'mips' and host_machine.endian() == 'little'
   orc_sources += ['orccpu-mips.c']
index d3452d4..424597e 100644 (file)
@@ -14,7 +14,7 @@
 #include <orc/orcarm.h>
 #include <orc/orcutils.h>
 
-#ifdef HAVE_ARM
+#if defined(HAVE_ARM) || defined(HAVE_AARCH64)
 #if defined(__APPLE__)
 #include  <libkern/OSCacheControl.h>
 #endif
@@ -775,7 +775,7 @@ orc_arm_emit_rv (OrcCompiler *p, int op, OrcArmCond cond,
 void
 orc_arm_flush_cache (OrcCode *code)
 {
-#ifdef HAVE_ARM
+#if defined (HAVE_ARM) || defined (HAVE_AARCH64)
 #ifdef __APPLE__
   sys_dcache_flush(code->code, code->code_size);
   sys_icache_invalidate(code->exec, code->code_size);
index 5431e0d..d1d436e 100644 (file)
@@ -45,7 +45,7 @@
 
 /***** arm *****/
 
-#ifdef __arm__
+#if defined (__arm__) || defined (__aarch64__)
 #if 0
 static unsigned long
 orc_profile_stamp_xscale(void)
@@ -80,10 +80,19 @@ orc_check_neon_proc_auxv (void)
     }
 
     if (aux[0] == AT_HWCAP) {
+#ifdef __arm__
       /* if (aux[1] & 64) flags |= ORC_TARGET_NEON_VFP; */
       /* if (aux[1] & 512) flags |= ORC_TARGET_NEON_IWMMXT; */
       if (aux[1] & 4096) flags |= ORC_TARGET_NEON_NEON;
       if (aux[1] & 128) flags |= ORC_TARGET_ARM_EDSP;
+#elif __aarch64__
+      /**
+       * Use HWCAP_ASIMD (1 << 1) to make sure Advanced SIMD (ASIMD) units exist in AArch64.
+       * Note that some ARMv7 features including HWCAP_NEON are always supported by ARMv8 CPUs.
+       */
+      if (aux[1] & (1 << 1))
+        flags |= ORC_TARGET_NEON_NEON | ORC_TARGET_ARM_EDSP; /** reuse 32bit flags */
+#endif
       ORC_INFO("arm hwcap %08x", aux[1]);
     } if (aux[0] == AT_PLATFORM) {
       ORC_INFO("arm platform %s", (char *)aux[1]);
index cecbcc0..cf87249 100644 (file)
@@ -107,7 +107,7 @@ orc_neon_emit_epilogue (OrcCompiler *compiler)
 
 static OrcTarget neon_target = {
   "neon",
-#ifdef HAVE_ARM
+#if defined(HAVE_ARM) || defined(HAVE_AARCH64)
   TRUE,
 #else
   FALSE,
@@ -126,7 +126,7 @@ static OrcTarget neon_target = {
 void
 orc_neon_init (void)
 {
-#if defined(HAVE_ARM)
+#if defined(HAVE_ARM) || defined(HAVE_AARCH64)
   if (!(orc_arm_get_cpu_flags () & ORC_TARGET_NEON_NEON)) {
     ORC_INFO("marking neon backend non-executable");
     neon_target.executable = FALSE;
@@ -141,7 +141,14 @@ orc_neon_init (void)
 static unsigned int
 orc_compiler_neon_get_default_flags (void)
 {
-  return ORC_TARGET_NEON_NEON;
+  unsigned int flags = 0;
+
+#if defined(HAVE_AARCH64)
+  flags |= ORC_TARGET_NEON_64BIT;
+#endif
+  flags |= ORC_TARGET_NEON_NEON;
+
+  return flags;
 }
 
 static void
index 53000b3..49f6cad 100644 (file)
@@ -30,7 +30,8 @@ typedef enum {
 enum {
   ORC_TARGET_NEON_CLEAN_COMPILE = (1<<0),
   ORC_TARGET_NEON_NEON = (1<<1),
-  ORC_TARGET_NEON_EDSP = (1<<2)
+  ORC_TARGET_NEON_EDSP = (1<<2),
+  ORC_TARGET_NEON_64BIT = (1<<3)
 };
 
 enum {
index 5b58c60..f0b77f6 100644 (file)
@@ -45,7 +45,7 @@
  * @short_description: Orc utility functions
  */
 
-#if defined(__arm__) || defined(__mips__)
+#if defined(__arm__) || defined(__aarch64__) || defined(__mips__)
 char *
 get_proc_cpuinfo (void)
 {
index 59c2c9e..c20e27f 100644 (file)
@@ -227,7 +227,7 @@ ORC_BEGIN_DECLS
 #ifdef ORC_ENABLE_UNSTABLE_API
 
 /* FIXME: remove, these are internal functions that were never exported */
-#if defined(__arm__) || defined(__mips__)
+#if defined(__arm__) || defined(__aarch64__) || defined(__mips__)
 char * get_proc_cpuinfo (void);
 #endif