From e10915230855c59f80fbe667b00d8f9ca6565d8b Mon Sep 17 00:00:00 2001 From: Dongju Chae Date: Mon, 21 Oct 2019 19:31:14 +0900 Subject: [PATCH] aarch64: make some setups for aarch64 support This commit adds the setup codes for aarch64 support including meson build and aarch64 selection. Signed-off-by: Dongju Chae --- meson.build | 2 ++ orc/meson.build | 2 +- orc/orcarm.c | 4 ++-- orc/orccpu-arm.c | 11 ++++++++++- orc/orcprogram-neon.c | 13 ++++++++++--- orc/orctarget.h | 3 ++- orc/orcutils.c | 2 +- orc/orcutils.h | 2 +- 8 files changed, 29 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index 674af96..a7c7e4c 100644 --- a/meson.build +++ b/meson.build @@ -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 diff --git a/orc/meson.build b/orc/meson.build index 1995f36..0213ed8 100644 --- a/orc/meson.build +++ b/orc/meson.build @@ -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'] diff --git a/orc/orcarm.c b/orc/orcarm.c index d3452d4..424597e 100644 --- a/orc/orcarm.c +++ b/orc/orcarm.c @@ -14,7 +14,7 @@ #include #include -#ifdef HAVE_ARM +#if defined(HAVE_ARM) || defined(HAVE_AARCH64) #if defined(__APPLE__) #include #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); diff --git a/orc/orccpu-arm.c b/orc/orccpu-arm.c index 5431e0d..d1d436e 100644 --- a/orc/orccpu-arm.c +++ b/orc/orccpu-arm.c @@ -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]); diff --git a/orc/orcprogram-neon.c b/orc/orcprogram-neon.c index cecbcc0..cf87249 100644 --- a/orc/orcprogram-neon.c +++ b/orc/orcprogram-neon.c @@ -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 diff --git a/orc/orctarget.h b/orc/orctarget.h index 53000b3..49f6cad 100644 --- a/orc/orctarget.h +++ b/orc/orctarget.h @@ -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 { diff --git a/orc/orcutils.c b/orc/orcutils.c index 5b58c60..f0b77f6 100644 --- a/orc/orcutils.c +++ b/orc/orcutils.c @@ -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) { diff --git a/orc/orcutils.h b/orc/orcutils.h index 59c2c9e..c20e27f 100644 --- a/orc/orcutils.h +++ b/orc/orcutils.h @@ -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 -- 2.7.4