summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorWANG Xuerui <git@xen0n.name>2022-10-25 14:36:52 +0800
committerWANG Xuerui <git@xen0n.name>2022-12-04 16:14:43 +0800
commitbdc16f086f1664b56d8add0691c9a80d7997efd9 (patch)
tree13bd26ccab93fe2623f161ec21712dfcc7c076e8 /src/corelib
parent6da057d811fd9494e1c173ba38d54bc3e9810f41 (diff)
Add LoongArch detectionHEADdev
- detect the LoongArch architecture, define Q_PROCESSOR_LOONGARCH and Q_PROCESSOR_LOONGARCH_{32,64} appropriately - document the macros as being available starting from 6.5 - add LoongArch ELF support in QElfParser Change-Id: I438146af49ec3adacacec84c27c9f4abaa542830 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/archdetect.cpp4
-rw-r--r--src/corelib/global/qprocessordetection.h14
-rw-r--r--src/corelib/global/qprocessordetection.qdoc34
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp5
4 files changed, 57 insertions, 0 deletions
diff --git a/src/corelib/global/archdetect.cpp b/src/corelib/global/archdetect.cpp
index 188ec2d176..0c08393ab9 100644
--- a/src/corelib/global/archdetect.cpp
+++ b/src/corelib/global/archdetect.cpp
@@ -25,6 +25,10 @@
# define ARCH_PROCESSOR "x86_64"
#elif defined(Q_PROCESSOR_IA64)
# define ARCH_PROCESSOR "ia64"
+#elif defined(Q_PROCESSOR_LOONGARCH_32)
+# define ARCH_PROCESSOR "loongarch32"
+#elif defined(Q_PROCESSOR_LOONGARCH_64)
+# define ARCH_PROCESSOR "loongarch64"
#elif defined(Q_PROCESSOR_M68K)
# define ARCH_PROCESSOR "m68k"
#elif defined(Q_PROCESSOR_MIPS_64)
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index 1b6139152e..6ca1d23933 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -200,6 +200,20 @@
// Q_BYTE_ORDER not defined, use endianness auto-detection
/*
+ LoongArch family, known variants: 32- and 64-bit
+
+ LoongArch is little-endian.
+*/
+#elif defined(__loongarch__)
+# define Q_PROCESSOR_LOONGARCH
+# if __loongarch_grlen == 64
+# define Q_PROCESSOR_LOONGARCH_64
+# else
+# define Q_PROCESSOR_LOONGARCH_32
+# endif
+# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
+
+/*
Motorola 68000 family, no revisions or variants
M68K is big-endian.
diff --git a/src/corelib/global/qprocessordetection.qdoc b/src/corelib/global/qprocessordetection.qdoc
index 08486a4433..e6605fb9b9 100644
--- a/src/corelib/global/qprocessordetection.qdoc
+++ b/src/corelib/global/qprocessordetection.qdoc
@@ -106,6 +106,40 @@
*/
/*!
+ \macro Q_PROCESSOR_LOONGARCH
+ \relates <QtProcessorDetection>
+ \since 6.5
+
+ Defined if the application is compiled for LoongArch processors.
+
+ \sa QSysInfo::buildCpuArchitecture()
+*/
+
+/*!
+ \macro Q_PROCESSOR_LOONGARCH_32
+ \relates <QtProcessorDetection>
+ \since 6.5
+
+ Defined if the application is compiled for 32-bit LoongArch processors.
+ The \l Q_PROCESSOR_LOONGARCH macro is also defined when
+ Q_PROCESSOR_LOONGARCH_32 is defined.
+
+ \sa QSysInfo::buildCpuArchitecture()
+*/
+
+/*!
+ \macro Q_PROCESSOR_LOONGARCH_64
+ \relates <QtProcessorDetection>
+ \since 6.5
+
+ Defined if the application is compiled for 64-bit LoongArch processors.
+ The \l Q_PROCESSOR_LOONGARCH macro is also defined when
+ Q_PROCESSOR_LOONGARCH_64 is defined.
+
+ \sa QSysInfo::buildCpuArchitecture()
+*/
+
+/*!
\macro Q_PROCESSOR_M68K
\relates <QtProcessorDetection>
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
index 4388c6babe..b7c6760864 100644
--- a/src/corelib/plugin/qelfparser_p.cpp
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -122,6 +122,8 @@ struct ElfMachineCheck
EM_PARISC
#elif defined(Q_PROCESSOR_IA64)
EM_IA_64
+#elif defined(Q_PROCESSOR_LOONGARCH)
+ EM_LOONGARCH
#elif defined(Q_PROCESSOR_M68K)
EM_68K
#elif defined(Q_PROCESSOR_MIPS)
@@ -387,6 +389,9 @@ Q_DECL_UNUSED Q_DECL_COLD_FUNCTION static QDebug &operator<<(QDebug &d, ElfHeade
case EM_BLACKFIN: d << ", Blackfin"; break;
#endif
case EM_IA_64: d << ", IA-64"; break;
+#ifdef EM_LOONGARCH
+ case EM_LOONGARCH: d << ", LoongArch"; break;
+#endif
case EM_MIPS: d << ", MIPS"; break;
case EM_PARISC: d << ", HPPA"; break;
case EM_PPC: d << ", PowerPC"; break;