aboutsummaryrefslogtreecommitdiff
path: root/gdb/arch
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2022-07-12 10:33:28 +0800
committerTiezhu Yang <yangtiezhu@loongson.cn>2022-07-12 20:14:48 +0800
commit657a50227bbd835c83aadc2405e649c4b982c241 (patch)
tree3ca4f73c0d7133aaefae84f50c57a6d774d513a7 /gdb/arch
parent75948417af8f86d1b9b0e3b51f904e1345927885 (diff)
downloadgdb-657a50227bbd835c83aadc2405e649c4b982c241.zip
gdb-657a50227bbd835c83aadc2405e649c4b982c241.tar.gz
gdb-657a50227bbd835c83aadc2405e649c4b982c241.tar.bz2
gdb: LoongArch: Add floating-point support
This commit adds floating-point support for LoongArch gdb. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Diffstat (limited to 'gdb/arch')
-rw-r--r--gdb/arch/loongarch.c9
-rw-r--r--gdb/arch/loongarch.h17
2 files changed, 25 insertions, 1 deletions
diff --git a/gdb/arch/loongarch.c b/gdb/arch/loongarch.c
index 11310c1..c48c200 100644
--- a/gdb/arch/loongarch.c
+++ b/gdb/arch/loongarch.c
@@ -24,6 +24,7 @@
#include "../features/loongarch/base32.c"
#include "../features/loongarch/base64.c"
+#include "../features/loongarch/fpu.c"
#ifndef GDBSERVER
#define STATIC_IN_GDB static
@@ -44,6 +45,11 @@ loongarch_create_target_description (const struct loongarch_gdbarch_features fea
else if (features.xlen == 8)
arch_name.append ("64");
+ if (features.fputype == SINGLE_FLOAT)
+ arch_name.append ("f");
+ else if (features.fputype == DOUBLE_FLOAT)
+ arch_name.append ("d");
+
set_tdesc_architecture (tdesc.get (), arch_name.c_str ());
long regnum = 0;
@@ -54,6 +60,9 @@ loongarch_create_target_description (const struct loongarch_gdbarch_features fea
else if (features.xlen == 8)
regnum = create_feature_loongarch_base64 (tdesc.get (), regnum);
+ /* For now we only support creating single float and double float. */
+ regnum = create_feature_loongarch_fpu (tdesc.get (), regnum);
+
return tdesc;
}
diff --git a/gdb/arch/loongarch.h b/gdb/arch/loongarch.h
index 5cf5498..799595b 100644
--- a/gdb/arch/loongarch.h
+++ b/gdb/arch/loongarch.h
@@ -23,7 +23,7 @@
#include "gdbsupport/tdesc.h"
/* Register numbers of various important registers. */
-enum
+enum loongarch_regnum
{
LOONGARCH_RA_REGNUM = 1, /* Return Address. */
LOONGARCH_SP_REGNUM = 3, /* Stack Pointer. */
@@ -36,6 +36,16 @@ enum
LOONGARCH_LINUX_NUM_GREGSET = 45, /* 32 GPR, ORIG_A0, PC, BADV, RESERVED 10. */
LOONGARCH_ARG_REGNUM = 8, /* r4-r11: general-purpose argument registers.
f0-f7: floating-point argument registers. */
+ LOONGARCH_FIRST_FP_REGNUM = LOONGARCH_LINUX_NUM_GREGSET,
+ LOONGARCH_FCC_REGNUM = LOONGARCH_FIRST_FP_REGNUM + 32,
+ LOONGARCH_FCSR_REGNUM = LOONGARCH_FCC_REGNUM + 1,
+ LOONGARCH_LINUX_NUM_FPREGSET = 34,
+};
+
+enum loongarch_fputype
+{
+ SINGLE_FLOAT = 1,
+ DOUBLE_FLOAT = 2,
};
/* The set of LoongArch architectural features that we track that impact how
@@ -56,6 +66,11 @@ struct loongarch_gdbarch_features
0 value so we can spot if one of these is used uninitialised. */
int xlen = 0;
+ /* The type of floating-point. This is either 1 (single float) or 2
+ (double float). No other value is valid. Initialise to the invalid
+ 0 value so we can spot if one of these is used uninitialised. */
+ int fputype = 0;
+
/* Equality operator. */
bool operator== (const struct loongarch_gdbarch_features &rhs) const
{