about summary refs log tree commit diff
path: root/sysdeps/loongarch
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/loongarch')
-rw-r--r--sysdeps/loongarch/Implies3
-rw-r--r--sysdeps/loongarch/Makefile15
-rw-r--r--sysdeps/loongarch/configure5
-rw-r--r--sysdeps/loongarch/configure.ac6
-rw-r--r--sysdeps/loongarch/lp64/Implies-after1
-rw-r--r--sysdeps/loongarch/preconfigure53
-rw-r--r--sysdeps/loongarch/preconfigure.ac47
-rw-r--r--sysdeps/loongarch/sys/regdef.h93
8 files changed, 223 insertions, 0 deletions
diff --git a/sysdeps/loongarch/Implies b/sysdeps/loongarch/Implies
new file mode 100644
index 0000000000..1945b1f4bb
--- /dev/null
+++ b/sysdeps/loongarch/Implies
@@ -0,0 +1,3 @@
+ieee754/ldbl-128
+ieee754/dbl-64
+ieee754/flt-32
diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile
new file mode 100644
index 0000000000..41c3449670
--- /dev/null
+++ b/sysdeps/loongarch/Makefile
@@ -0,0 +1,15 @@
+ifeq ($(subdir),misc)
+sysdep_headers += sys/asm.h
+endif
+
+# LoongArch's assembler also needs to know about PIC as it changes the
+# definition of some assembler macros.
+ASFLAGS-.os += $(pic-ccflag)
+
+abi-variants := lp64
+
+ifeq (,$(filter $(default-abi),$(abi-variants)))
+$(error Unknown ABI $(default-abi), must be one of $(abi-variants))
+endif
+
+abi-lp64-condition    := defined __loongarch_lp64
diff --git a/sysdeps/loongarch/configure b/sysdeps/loongarch/configure
new file mode 100644
index 0000000000..43b54d4965
--- /dev/null
+++ b/sysdeps/loongarch/configure
@@ -0,0 +1,5 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/loongarch/elf.
+
+$as_echo "#define HIDDEN_VAR_NEEDS_DYNAMIC_RELOC 1" >>confdefs.h
+
diff --git a/sysdeps/loongarch/configure.ac b/sysdeps/loongarch/configure.ac
new file mode 100644
index 0000000000..f744367bf3
--- /dev/null
+++ b/sysdeps/loongarch/configure.ac
@@ -0,0 +1,6 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/loongarch/elf.
+
+dnl It is always possible to access static and hidden symbols in an
+dnl position independent way.
+AC_DEFINE(HIDDEN_VAR_NEEDS_DYNAMIC_RELOC)
diff --git a/sysdeps/loongarch/lp64/Implies-after b/sysdeps/loongarch/lp64/Implies-after
new file mode 100644
index 0000000000..a8cae95f9d
--- /dev/null
+++ b/sysdeps/loongarch/lp64/Implies-after
@@ -0,0 +1 @@
+wordsize-64
diff --git a/sysdeps/loongarch/preconfigure b/sysdeps/loongarch/preconfigure
new file mode 100644
index 0000000000..118963cda6
--- /dev/null
+++ b/sysdeps/loongarch/preconfigure
@@ -0,0 +1,53 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+# Local preconfigure fragment for sysdeps/loongarch
+
+case "$machine" in
+loongarch*)
+
+    abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __loongarch_\(lp64\|ilp32\).*/\1/p'`
+    float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __loongarch_\(soft\|single\|double\)_float.*/\1/p'`
+
+    with_fp_cond="!defined __loongarch_soft_float"
+
+    case "$float_abi" in
+    soft)
+	abi_flen=0
+	as_fn_error 1 "loongarch does not yet support soft floating-point  ABI!!" "$LINENO" 5
+	;;
+    single)
+	as_fn_error 1 "glibc does not yet support the single floating-point ABI!!" "$LINENO" 5
+	;;
+    double)
+	abi_flen=64
+	;;
+    *)
+	as_fn_error 1 "Unable to determine floating-point ABI!!" "$LINENO" 5
+	;;
+    esac
+
+    case "$abi" in
+    ilp32)
+	as_fn_error 1 "loongarch does not yet support ilp32 ABI!!" "$LINENO" 5
+	;;
+    lp64)
+	grlen=64
+	machine=loongarch/lp64
+	;;
+    *)
+	as_fn_error 1 "Unable to determine GRLEN!!" "$LINENO" 5
+	;;
+    esac
+
+    cat >>confdefs.h <<_ACEOF
+#define LOONGARCH_ABI_GRLEN $grlen
+_ACEOF
+
+    cat >>confdefs.h <<_ACEOF
+#define LOONGARCH_ABI_FRLEN $abi_flen
+_ACEOF
+
+
+    base_machine=loongarch
+    ;;
+esac
+
diff --git a/sysdeps/loongarch/preconfigure.ac b/sysdeps/loongarch/preconfigure.ac
new file mode 100644
index 0000000000..1aba743c15
--- /dev/null
+++ b/sysdeps/loongarch/preconfigure.ac
@@ -0,0 +1,47 @@
+GLIBC_PROVIDES[]dnl See aclocal.m4 in the top level source directory.
+# Local preconfigure fragment for sysdeps/loongarch
+
+case "$machine" in
+loongarch*)
+
+    abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __loongarch_\(lp64\|ilp32\).*/\1/p'`
+    float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __loongarch_\(soft\|single\|double\)_float.*/\1/p'`
+
+    with_fp_cond="!defined __loongarch_soft_float"
+
+    case "$float_abi" in
+    soft)
+	abi_flen=0
+	AC_MSG_ERROR([loongarch does not yet support soft floating-point  ABI!!], 1)
+	;;
+    single)
+	AC_MSG_ERROR([glibc does not yet support the single floating-point ABI!!], 1)
+	;;
+    double)
+	abi_flen=64
+	;;
+    *)
+	AC_MSG_ERROR([Unable to determine floating-point ABI!!], 1)
+	;;
+    esac
+
+    case "$abi" in
+    ilp32)
+	AC_MSG_ERROR([loongarch does not yet support ilp32 ABI!!], 1)
+	;;
+    lp64)
+	grlen=64
+	machine=loongarch/lp64
+	;;
+    *)
+	AC_MSG_ERROR([Unable to determine GRLEN!!], 1)
+	;;
+    esac
+
+    AC_DEFINE_UNQUOTED([LOONGARCH_ABI_GRLEN], [$grlen])
+    AC_DEFINE_UNQUOTED([LOONGARCH_ABI_FRLEN], [$abi_flen])
+
+    base_machine=loongarch
+    ;;
+esac
+
diff --git a/sysdeps/loongarch/sys/regdef.h b/sysdeps/loongarch/sys/regdef.h
new file mode 100644
index 0000000000..d266df372d
--- /dev/null
+++ b/sysdeps/loongarch/sys/regdef.h
@@ -0,0 +1,93 @@
+/* Register Macro definitions
+   Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SYS_REGDEF_H
+#define _SYS_REGDEF_H
+
+#define zero $r0
+#define ra $r1
+#define tp $r2
+#define sp $r3
+#define a0 $r4
+#define a1 $r5
+#define a2 $r6
+#define a3 $r7
+#define a4 $r8
+#define a5 $r9
+#define a6 $r10
+#define a7 $r11
+#define v0 $r4
+#define v1 $r5
+#define t0 $r12
+#define t1 $r13
+#define t2 $r14
+#define t3 $r15
+#define t4 $r16
+#define t5 $r17
+#define t6 $r18
+#define t7 $r19
+#define t8 $r20
+#define x $r21
+#define fp $r22
+#define s0 $r23
+#define s1 $r24
+#define s2 $r25
+#define s3 $r26
+#define s4 $r27
+#define s5 $r28
+#define s6 $r29
+#define s7 $r30
+#define s8 $r31
+
+#define fa0 $f0
+#define fa1 $f1
+#define fa2 $f2
+#define fa3 $f3
+#define fa4 $f4
+#define fa5 $f5
+#define fa6 $f6
+#define fa7 $f7
+#define fv0 $f0
+#define fv1 $f1
+#define ft0 $f8
+#define ft1 $f9
+#define ft2 $f10
+#define ft3 $f11
+#define ft4 $f12
+#define ft5 $f13
+#define ft6 $f14
+#define ft7 $f15
+#define ft8 $f16
+#define ft9 $f17
+#define ft10 $f18
+#define ft11 $f19
+#define ft12 $f20
+#define ft13 $f21
+#define ft14 $f22
+#define ft15 $f23
+#define fs0 $f24
+#define fs1 $f25
+#define fs2 $f26
+#define fs3 $f27
+#define fs4 $f28
+#define fs5 $f29
+#define fs6 $f30
+#define fs7 $f31
+
+#endif /* _SYS_REGDEF_H */