From fcc471e420525dbd4a1dda59ed51487d5ead5921 Mon Sep 17 00:00:00 2001 From: loongson Date: Fri, 31 Mar 2023 15:13:48 +0800 Subject: [PATCH] Add LoongArch support --- builds/posix/prefix.linux_loongarch | 28 +++++++++++++++++++ configure.ac | 12 ++++++++ extern/editline/config.guess | 3 ++ extern/editline/config.sub | 1 + .../libcds/cds/compiler/gcc/compiler_macro.h | 5 ++++ extern/libcds/cds/details/defs.h | 2 ++ src/common/classes/DbImplementation.cpp | 28 ++++++++++--------- src/common/common.h | 4 +++ src/jrd/license.h | 4 +++ 9 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 builds/posix/prefix.linux_loongarch diff --git a/builds/posix/prefix.linux_loongarch b/builds/posix/prefix.linux_loongarch new file mode 100644 index 0000000000..0158106db3 --- /dev/null +++ b/builds/posix/prefix.linux_loongarch @@ -0,0 +1,28 @@ +# The contents of this file are subject to the Interbase Public +# License Version 1.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy +# of the License at http://www.Inprise.com/IPL.html +# +# Software distributed under the License is distributed on an +# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express +# or implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code was created by Inprise Corporation +# and its predecessors. Portions created by Inprise Corporation are +# Copyright (C) Inprise Corporation. +# +# All Rights Reserved. +# Contributor(s): ______________________________________. +# Start of file prefix.linux: $(VERSION) $(PLATFORM) +# 14 Apr 2008 Alan Barclay alan AT escribe.co.uk +# 2018, "Manuel A. Fernandez Montecelo" + + +#LD=@CXX@ + +#PROD_FLAGS=-ggdb -O3 -fno-omit-frame-pointer -DLINUX -pipe -MMD -fPIC +#DEV_FLAGS=-ggdb -DLINUX -DDEBUG_GDS_ALLOC -pipe -MMD -p -fPIC -Werror=delete-incomplete -Wall -Wno-switch + +PROD_FLAGS=-O3 -DLINUX -DLOONGARCH -pipe -p -MMD -fPIC -fsigned-char -fmessage-length=0 -std=gnu++03 -fno-delete-null-pointer-checks +DEV_FLAGS=-ggdb -DLINUX -DLOONGARCH -pipe -p -MMD -fPIC -Werror=delete-incomplete -Wall -fsigned-char -fmessage-length=0 -Wno-non-virtual-dtor diff --git a/configure.ac b/configure.ac index 7534ba5bfe..8cdabafd15 100644 --- a/configure.ac +++ b/configure.ac @@ -325,6 +325,18 @@ dnl CPU_TYPE=ppc64 libdir=/usr/lib64 ;; + loongarch*-*-linux*) + MAKEFILE_PREFIX=linux_loongarch + INSTALL_PREFIX=linux + PLATFORM=LINUX + AC_DEFINE(LINUX, 1, [Define this if OS is Linux]) + EDITLINE_FLG=Y + SHRLIB_EXT=so + STD_EDITLINE=true + STD_ICU=true + libdir=/usr/lib64 + ;; + riscv64*-*-linux*) MAKEFILE_PREFIX=linux_riscv64 INSTALL_PREFIX=linux diff --git a/extern/editline/config.guess b/extern/editline/config.guess index 9afd676206..a7cdcc297b 100755 --- a/extern/editline/config.guess +++ b/extern/editline/config.guess @@ -944,6 +944,9 @@ EOF ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; diff --git a/extern/editline/config.sub b/extern/editline/config.sub index 61cb4bc22d..0bbb2248a5 100755 --- a/extern/editline/config.sub +++ b/extern/editline/config.sub @@ -268,6 +268,7 @@ case $basic_machine in | k1om \ | le32 | le64 \ | lm32 \ + | loongarch32 | loongarch64 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ diff --git a/extern/libcds/cds/compiler/gcc/compiler_macro.h b/extern/libcds/cds/compiler/gcc/compiler_macro.h index 44ddc79f06..c36c6f9c05 100644 --- a/extern/libcds/cds/compiler/gcc/compiler_macro.h +++ b/extern/libcds/cds/compiler/gcc/compiler_macro.h @@ -127,6 +127,11 @@ # else # define CDS_BUILD_BITS 32 # endif +#elif defined(__loongarch__) +# define CDS_PROCESSOR_ARCH CDS_PROCESSOR_LOONGARCH +# define CDS_PROCESSOR__NAME "LOONGARCH" +# define CDS_PROCESSOR__NICK "loongarch" +# define CDS_BUILD_BITS 64 #else # if defined(CDS_USE_LIBCDS_ATOMIC) # error "Libcds does not support atomic implementation for the processor architecture. Try to use C++11-compatible compiler and remove CDS_USE_LIBCDS_ATOMIC flag from compiler command line" diff --git a/extern/libcds/cds/details/defs.h b/extern/libcds/cds/details/defs.h index 54095e5c29..82f8502f6b 100644 --- a/extern/libcds/cds/details/defs.h +++ b/extern/libcds/cds/details/defs.h @@ -222,6 +222,7 @@ namespace cds {} - CDS_PROCESSOR_PPC64 PowerPC64 - CDS_PROCESSOR_ARM7 ARM v7 - CDS_PROCESSOR_ARM8 ARM v8 + - CDS_PROCESSOR_LOONGARCH LoongArch - CDS_PROCESSOR_UNKNOWN undefined processor architecture CDS_PROCESSOR__NAME The name (string) of processor architecture @@ -278,6 +279,7 @@ namespace cds {} #define CDS_PROCESSOR_PPC64 5 // PowerPC 64bit #define CDS_PROCESSOR_ARM7 7 #define CDS_PROCESSOR_ARM8 8 +#define CDS_PROCESSOR_LOONGARCH 9 #define CDS_PROCESSOR_UNKNOWN -1 // Supported OS interfaces diff --git a/src/common/classes/DbImplementation.cpp b/src/common/classes/DbImplementation.cpp index 67a2acefc6..7c58ee9eb9 100644 --- a/src/common/classes/DbImplementation.cpp +++ b/src/common/classes/DbImplementation.cpp @@ -51,6 +51,7 @@ static const UCHAR CpuPowerPc64el = 16; static const UCHAR CpuM68k = 17; static const UCHAR CpuRiscV64 = 18; static const UCHAR CpuMips64el = 19; +static const UCHAR CpuLoongArch = 20; static const UCHAR OsWindows = 0; static const UCHAR OsLinux = 1; @@ -93,7 +94,8 @@ const char* hardware[] = { "PowerPC64el", "M68k", "RiscV64", - "MIPS64EL" + "MIPS64EL", + "LOONGARCH" }; const char* operatingSystem[] = { @@ -120,23 +122,23 @@ const char* compiler[] = { // This table lists pre-fb3 implementation codes const UCHAR backwardTable[FB_NELEM(hardware) * FB_NELEM(operatingSystem)] = { -// Intel AMD Sparc PPC PPC64 MIPSEL MIPS ARM IA64 s390 s390x SH SHEB HPPA Alpha ARM64 PPC64el M68k RiscV64 MIPS64EL -/* Windows */ 50, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* Linux */ 60, 66, 65, 69, 86, 71, 72, 75, 76, 79, 78, 80, 81, 82, 83, 84, 85, 87, 88, 90, -/* Darwin */ 70, 73, 0, 63, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* Solaris */ 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* HPUX */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, -/* AIX */ 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* MVS */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* FreeBSD */ 61, 67, 0, 92, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, -/* NetBSD */ 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +// Intel AMD Sparc PPC PPC64 MIPSEL MIPS ARM IA64 s390 s390x SH SHEB HPPA Alpha ARM64 PPC64el M68k RiscV64 MIPS64EL LoongArch +/* Windows */ 50, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* Linux */ 60, 66, 65, 69, 86, 71, 72, 75, 76, 79, 78, 80, 81, 82, 83, 84, 85, 87, 88, 90, 93, +/* Darwin */ 70, 73, 0, 63, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* Solaris */ 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* HPUX */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, +/* AIX */ 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* MVS */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +/* FreeBSD */ 61, 67, 0, 92, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, +/* NetBSD */ 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; const UCHAR backEndianess[FB_NELEM(hardware)] = { -// Intel AMD Sparc PPC PPC64 MIPSEL MIPS ARM IA64 s390 s390x SH SHEB HPPA Alpha ARM64 PPC64el M68k RiscV64 MIPS64EL - 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, +// Intel AMD Sparc PPC PPC64 MIPSEL MIPS ARM IA64 s390 s390x SH SHEB HPPA Alpha ARM64 PPC64el M68k RiscV64 MIPS64EL LoongArch + 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, }; } // anonymous namespace diff --git a/src/common/common.h b/src/common/common.h index 3fb451e0c7..2eac429923 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -143,6 +143,10 @@ #define FB_CPU CpuRiscV64 #endif /* RISCV64 */ +#ifdef LOONGARCH +#define FB_CPU CpuLoongArch +#endif /* LOONGARCH */ + #ifdef sparc #define FB_CPU CpuUltraSparc #define RISC_ALIGNMENT diff --git a/src/jrd/license.h b/src/jrd/license.h index c162f1d3bc..3bf58b6adb 100644 --- a/src/jrd/license.h +++ b/src/jrd/license.h @@ -107,8 +107,12 @@ #endif #ifdef LINUX +#if defined(__loongarch__) +#define FB_PLATFORM "LL" // Linux/LoongArch +#else #define FB_PLATFORM "LI" // Linux on Intel #endif +#endif #ifdef FREEBSD #define FB_PLATFORM "FB" // FreeBSD/i386