From 9b0c993ba884149028a52cde61b13bfa2770286f Mon Sep 17 00:00:00 2001 From: Dandan Zhang Date: Tue, 2 Jan 2024 12:32:19 +0000 Subject: [PATCH] add loongarch64 support --- .../rapidyaml/rapidyaml/ext/c4core/src/c4/cpu.hpp | 5 +++++ .../ext/c4core/src/c4/ext/debugbreak/debugbreak.h | 9 +++++++++ .../c4/ext/fast_float/include/fast_float/float_common.h | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/cpu.hpp b/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/cpu.hpp index ca3f78816..c9831c5da 100644 --- a/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/cpu.hpp +++ b/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/cpu.hpp @@ -84,6 +84,11 @@ # define C4_CPU_PPC # define C4_WORDSIZE 4 # endif + +#elif defined(__loongarch64) +# define C4_CPU_LOONGARCH64 +# define C4_WORDSIZE 8 +# define C4_BYTE_ORDER _C4EL #elif defined(SWIG) #else # error "unknown CPU architecture" diff --git a/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/ext/debugbreak/debugbreak.h b/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/ext/debugbreak/debugbreak.h index f570bf845..e55d418cb 100644 --- a/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/ext/debugbreak/debugbreak.h +++ b/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/ext/debugbreak/debugbreak.h @@ -100,6 +100,15 @@ __inline__ static void trap_instruction(void) * 'aarch64_default_breakpoint' */ __asm__ volatile(".inst 0xd4200000"); } +#elif defined(__loongarch64) +enum { HAVE_TRAP_INSTRUCTION = 1, }; +__attribute__((gnu_inline, always_inline)) +__inline__ static void trap_instruction(void) +{ + /* See 'loongarch-tdep.c' in GDB source, + * 'loongarch_default_breakpoint' */ + __asm__ volatile(".word 0x002a0005" ::: "memory"); +} #else enum { HAVE_TRAP_INSTRUCTION = 0, }; #endif diff --git a/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/ext/fast_float/include/fast_float/float_common.h b/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/ext/fast_float/include/fast_float/float_common.h index cb15ac23f..39d391102 100644 --- a/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/ext/fast_float/include/fast_float/float_common.h +++ b/third_party/rapidyaml/rapidyaml/ext/c4core/src/c4/ext/fast_float/include/fast_float/float_common.h @@ -9,6 +9,7 @@ || defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) \ || defined(__MINGW64__) \ || defined(__s390x__) \ + || defined(__loongarch64) \ || (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__))) #define FASTFLOAT_64BIT #elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) \ @@ -337,4 +338,4 @@ inline OStream& operator<<(OStream &out, const fast_float::decimal &d) { return out; } -#endif \ No newline at end of file +#endif