Add LoongArch detection

- 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>
This commit is contained in:
WANG Xuerui 2022-10-25 14:36:52 +08:00
parent 6da057d811
commit bdc16f086f
4 changed files with 57 additions and 0 deletions

View File

@ -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)

View File

@ -199,6 +199,20 @@
# define Q_PROCESSOR_WORDSIZE 8
// 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

View File

@ -105,6 +105,40 @@
\sa QSysInfo::buildCpuArchitecture()
*/
/*!
\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>

View File

@ -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;